[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
相关推荐
minglie11 小时前
cocotb 配合 iverilog 搭建 Verilog 仿真工程
fpga开发
minglie11 小时前
常用Verilog模板
fpga开发
weixin_437497771 小时前
学习笔记:用于EDA的LLMs专题会议论文
人工智能·笔记·搜索引擎·fpga开发
浩子智控2 天前
电子设备DevOps
fpga开发
cycf3 天前
CRC校验
fpga开发
landyjzlai3 天前
AMBA总线(15)关于AXI-stream(sg模式)
arm开发·fpga开发·amba
白狐_7983 天前
Quartus Prime 新手完全使用指南
fpga开发
Aaron15883 天前
三种主流接收机架构(超外差、零中频、射频直采)对比及发展趋势浅析
c语言·人工智能·算法·fpga开发·架构·硬件架构·信号处理
博览鸿蒙3 天前
一颗数字系统是如何在 FPGA 上“跑起来”的?
fpga开发
雨洛lhw3 天前
FPGA JTAG接口设计全解析
fpga开发·jtag