[HDLBits] Exams/2012 q2fsm

Consider the state diagram shown below.

Write complete Verilog code that represents this FSM. Use separate always blocks for the state table and the state flip-flops, as done in lectures. Describe the FSM output, which is called z , using either continuous assignment statement(s) or an always block (at your discretion). Assign any state codes that you wish to use.

复制代码
module top_module (
    input clk,
    input reset,   // Synchronous active-high reset
    input w,
    output z
);
    parameter A=3'b000, B=3'b001, C=3'b010, D=3'b011, E=3'b100, F=3'b101;
    wire[2:0] state, next;
    
    // state transition logic
    always@(*)begin
        case(state)
            A: next = w? B:A;
            B: next = w? C:D;
            C: next = w? E:D;
            D: next = w? F:A;
            E: next = w? E:D;
            F: next = w? C:D;
        endcase
    end
    
    // flip-flop and reset
    always@(posedge clk)begin
        if(reset)
            state <= A;
        else
            state <= next;
    end
    
    // output
    assign z = (state == E || state == F);

endmodule
相关推荐
每月一号准时摆烂39 分钟前
数字电子技术基础(六十)——使用Digital软件绘制脉冲触发的触发器
fpga开发
可编程芯片开发12 小时前
基于FPGA的电子万年历系统开发,包含各模块testbench
fpga开发·fpga·电子万年历
爱学习的张哥15 小时前
UDP--DDR--SFP,FPGA实现之ddr读写控制模块
网络协议·fpga开发·udp
GateWorld1 天前
深入浅出IIC协议 - 从总线原理到FPGA实战开发 -- 第一篇:I2C总线协议深度解剖
fpga开发·开源协议
爱学习的张哥1 天前
UDP--DDR--SFP,FPGA实现之模块梳理及AXI读写DDR读写上板测试
单片机·fpga开发·udp·axi·ddr
白杨树田2 天前
【EDA软件】【联合Modelsim仿真使用方法】
fpga开发
搬砖的小码农_Sky2 天前
FPGA: XILINX Kintex 7系列器件的架构
fpga开发·架构·硬件架构
搬砖的小码农_Sky2 天前
FPGA:如何提高RTL编码能力?
fpga开发·硬件架构
晶台光耦2 天前
高速光耦在通信行业的应用(五) | 5Mbps通信光耦的特性
fpga开发
梓仁沐白2 天前
Verilog HDL 语言整理
fpga开发