[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
相关推荐
unicrom_深圳市由你创科技3 小时前
XDMA 技术及在 Windows 平台的应用实践
fpga开发
s090713619 小时前
【Agent】Claude code辅助verilog编程
fpga开发
3有青年20 小时前
altera fpga agilex 5 连接到HVIO BANK上的参考时钟,是否可以作为HSIO BANK内部IOPLL的输入时钟
fpga开发
FPGA_ADDA21 小时前
基于ZU47DR 的高性能射频卡
fpga开发
ooo-p1 天前
FPGA学习篇——Verilog学习之“流水灯”
学习·fpga开发
坏孩子的诺亚方舟1 天前
FPGA系统架构设计实践14_OTA升级
fpga·加载
FPGA小c鸡1 天前
【FPGA视频处理】帧缓冲设计完全指南:从单缓冲到三缓冲的深度解析与实战应用
fpga开发·音视频
hexiaoyan8271 天前
【无标题】高速信号处理设计原理图:413-基于双XCVU9P+C6678的100G光纤加速卡
fpga开发·高速信号处理·光纤加速·xcvu9p芯片·硬件加速卡
search71 天前
数字电子技术基础
fpga开发
ooo-p1 天前
FPGA学习篇——Verilog学习之“触摸按键控制LED灯”
学习·fpga开发