[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
相关推荐
szxinmai主板定制专家17 小时前
基于 RK3588+RK1820/28 算力卡的国产工控机,适用于机器视觉,机器人等边缘算力场景
人工智能·fpga开发·zynq·控制器·mpsoc·半导体设备
unicrom_深圳市由你创科技21 小时前
硬件在环(HIL)测试在FPGA项目中为什么重要?
fpga开发
嵌入式-老费1 天前
esp32开发与应用(和高云FPGA的配合)
fpga开发
156002548401 天前
基于3U VPX总线架构的VU37P FPGA高带宽HBM缓存数据处理卡(缓存带宽480GB/s)
fpga开发·架构
szxinmai主板定制专家1 天前
基于 RK3576 的智能割草机器人解决方案,从样机到量产
人工智能·嵌入式硬件·计算机视觉·fpga开发·机器人·rk3588+fpga·割草机器人
续写烂尾2 天前
SD NAND vs SPI NAND:接口协议、坏块管理与开发成本全面对比
fpga开发
叶子野格2 天前
《Verilog学习:数字系统设计基础》
学习·fpga开发
花 满 楼2 天前
TPWM — PWM 测量模式(TIM PWM Measurement Mode)
单片机·嵌入式硬件·fpga开发
叶子野格2 天前
《Verilog学习:前置知识》
学习·fpga开发
科恒盛远3 天前
RFSoC XCZU47DR 100G UDP高速数据传输的实现与调试(PCIE908 板卡技术系列三)
fpga开发