[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
相关推荐
电院工程师3 小时前
ChipWhisperer教程(三)
笔记·python·嵌入式硬件·安全·fpga开发·安全架构
sz66cm3 小时前
FPGA基础 -- 什么是 Verilog 的模块(`module`)
fpga开发
anhuihbo19 小时前
FPGA实现VESA DSC编码功能
fpga开发·vesa dsc
ThreeYear_s20 小时前
基于fpga的疲劳驾驶检测
fpga开发
岁月磨吾少年志1 天前
【FPGA开发】DDS信号发生器设计
fpga开发
DQI-king1 天前
ZYNQ学习记录FPGA(三)状态机
学习·fpga开发
ThreeYear_s1 天前
基于FPGA的PID算法学习———实现PI比例控制算法
学习·算法·fpga开发
ThreeYear_s2 天前
基于FPGA的PID算法学习———实现PID比例控制算法
学习·算法·fpga开发
第二层皮-合肥2 天前
实战案例-FPGA如何实现JESD204B可重复的延迟
fpga开发
9527华安2 天前
国产安路FPGA实现图像视频采集转HDMI输出,提供5套TD工程源码和技术支持
fpga开发·音视频·安路·安路fpga·tangdynasty