[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
相关推荐
武汉凯迪正大电气3 小时前
武汉凯迪正大—变压器空负载特性参数测试仪 变压器容量及损耗参数测试仪
fpga开发
IM_DALLA3 小时前
【Verilog学习日常】—牛客网刷题—Verilog快速入门—VL16
学习·fpga开发
IM_DALLA3 小时前
【Verilog学习日常】—牛客网刷题—Verilog快速入门—VL18
学习·fpga开发
芯冰乐3 小时前
综合时如何计算net delay?
后端·fpga开发
落雨无风5 小时前
quartus pin 分配(三)
fpga开发
cycf9 小时前
深入浅出通信原理
fpga开发·信息与通信
IM_DALLA1 天前
【Verilog学习日常】—牛客网刷题—Verilog快速入门—VL21
学习·fpga开发
皇华ameya1 天前
AMEYA360:村田电子更适合薄型设计应用场景的3.3V输入、12A输出的DCDC转换IC
fpga开发
千穹凌帝1 天前
SpinalHDL之结构(二)
开发语言·前端·fpga开发
一口一口吃成大V2 天前
FPGA随记——FPGA时序优化小经验
fpga开发