[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
相关推荐
技术性摸鱼13 小时前
FPGA选型参数
fpga开发
FPGA_小田老师15 小时前
ibert 7 Series GT:IBERT远近端(内外)环回测试
fpga开发·ibert·gt测试·近端pcs环回·近端pma环回·远端pcs环回·远端pma环回
尤老师FPGA16 小时前
【无标题】
fpga开发
才鲸嵌入式18 小时前
香山CPU(国产开源)的 SoC SDK底层程序编写,以及其它开源SoC芯片介绍
c语言·单片机·嵌入式·arm·cpu·verilog·fpga
1750633194520 小时前
VIVADO VLA VIO 硬件调试 降采样
fpga开发
FPGA小迷弟20 小时前
基于FPGA开发高速ADC/DAC芯片笔记
图像处理·fpga开发·数据采集·fpga·adc
ZYNQRFSOC2 天前
基于XCKU5P纯逻辑 NVME测试
fpga开发
FPGA小迷弟2 天前
使用FPGA开发高速AD/DA芯片的接口学习
fpga开发
stars-he2 天前
FPGA学习笔记(6)逻辑设计小结与以太网发送前置
笔记·学习·fpga开发
燎原星火*2 天前
FPGA 逻辑级数
fpga开发