[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
相关推荐
虹科智能自动化1 小时前
虹科分享 | SocTek IP Cores:FPGA高端网络与时间同步解决方案
fpga开发·ip核·tsn时间敏感网络
秋风战士1 小时前
无线通信算法之340:信道均衡除法定标讨论
算法·fpga开发·信息与通信
FPGA小迷弟2 小时前
基于FPGA实现HDMI接口,选型/核心技术
学习·fpga开发·verilog·fpga·modelsim
szxinmai主板定制专家14 小时前
基于 PC 的控制技术+ethercat+linux实时系统,助力追踪标签规模化生产,支持国产化
arm开发·人工智能·嵌入式硬件·yolo·fpga开发
坏孩子的诺亚方舟21 小时前
modelsim基础2_modelsim仿真分析
fpga·modelsim·仿真分析
tiger1191 天前
FPGA 在大模型推理中的应用
人工智能·llm·fpga·大模型推理
博览鸿蒙1 天前
如何为春招的金三银四做好准备
fpga开发
FPGA小迷弟1 天前
FPGA处理图像需要用到的主流接口详解
学习·fpga开发·verilog·fpga·modelsim
LeoZY_1 天前
CH347 USB转JTAG功能使用笔记:CH347根据SVF文件实现任意FPGA下载
笔记·stm32·嵌入式硬件·fpga开发·硬件架构·硬件工程
博览鸿蒙1 天前
FPGA在高性能计算中的应用:数据流加速与优化
fpga开发