[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
相关推荐
XINVRY-FPGA1 天前
XC7VX690T-2FFG1157I Xilinx AMD Virtex-7 FPGA
arm开发·人工智能·嵌入式硬件·深度学习·fpga开发·硬件工程·fpga
R.X. NLOS1 天前
Zynq AXI DMA 环回测试调试指南:从 Cache 一致性到 Vitis 同步机制
fpga
Terasic友晶科技1 天前
【案例展示】友晶科技全息传感器桥接解决方案
科技·fpga开发·holoscan·agilex 5·terasic
学习永无止境@1 天前
Verilog中有符号数计算
图像处理·算法·fpga开发
FPGA-ADDA1 天前
第四篇:射频数据转换器(RF-DAC)——重构模拟信号的关键
ai·fpga·rfsoc·vu13p·xczu47dr
学习永无止境@1 天前
Sobel边缘检测的MATLAB实现
图像处理·opencv·算法·计算机视觉·fpga开发
fei_sun1 天前
数字芯片流程
fpga开发
YaraMemo1 天前
射频链的构成
5g·fpga开发·信息与通信·信号处理·射频工程
fei_sun1 天前
逻辑设计工程技术基础
fpga开发
fei_sun1 天前
有限状态机设计基础
fpga开发