[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 小时前
线阵相机坏点校正方案
fpga开发
cjie2215 小时前
安路Modelsim仿真库编译
fpga开发
QYR-分析6 小时前
全球及中国电源序列发生器行业市场发展现状与前景分析
fpga开发
alxraves8 小时前
超声图像前端信号处理的关键技术
前端·fpga开发·信号处理
木心术11 天前
基于FPGA+RFIC的5G基站设计方案与5G专用DFE芯片的设计方案区别及优劣势分析
5g·fpga开发
坏孩子的诺亚方舟1 天前
open_prj21_RGB LCD和HDMI
fpga开发·mpsoc
坏孩子的诺亚方舟1 天前
open_prj20_MPSOC概述
fpga开发·正点原子·mpsoc
nature_forest1 天前
DSP与FPGA之间EMIF接口之DSP参数配置下板测试问题总结
fpga开发
小麦嵌入式1 天前
FPGA入门(三):3-8 译码器 仿真波形解读
stm32·单片机·嵌入式硬件·mcu·fpga开发·硬件工程
upper20202 天前
从零开始动手做Verilog实验--04--11阶FIR滤波器
fpga开发