[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
相关推荐
minglie116 分钟前
zynq arm全局计时器和私有定时器
fpga开发
章咸鱼121386 小时前
nios simple soket tcp在面对arp洪流时崩溃的处理
fpga开发·tcp
望获linux7 小时前
望获实时Linux:亚微秒级时间控制
linux·运维·服务器·计算机·fpga开发·嵌入式软件·飞腾
嵌入式-老费1 天前
Zynq开发实践(FPGA之spi实现)
fpga开发
太爱学习了1 天前
FPGA雷达信号处理之:自适应门限阈值
fpga开发·信号处理
国科安芯2 天前
前沿探索:RISC-V 架构 MCU 在航天级辐射环境下的可靠性测试
网络·单片机·嵌入式硬件·fpga开发·硬件架构·risc-v
范纹杉想快点毕业2 天前
请创建一个视觉精美、交互流畅的进阶版贪吃蛇游戏
数据库·嵌入式硬件·算法·mongodb·游戏·fpga开发·交互
第二层皮-合肥2 天前
FPGA硬件设计-基础流程
fpga开发
第二层皮-合肥2 天前
FPGA硬件开发-Xilinx产品介绍
fpga开发
XINVRY-FPGA2 天前
XCVP1902-2MSEVSVA6865 AMD 赛灵思 XilinxVersal Premium FPGA
人工智能·嵌入式硬件·神经网络·fpga开发·云计算·腾讯云·fpga