[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 小时前
基于FPGA的卷积神经网络实现-Step2 卷积模块设计
人工智能·fpga开发·cnn
fantasy_arch3 小时前
fpga demo测试hello world
fpga开发
黑猫学长呀4 小时前
存储宝典第6篇:测试机台的PE板和PPB板有什么区别?
测试工具·fpga开发·ssd·芯片测试·ate·存储芯片·测试机台
GateWorld8 小时前
LCD显示技术完全指南:原理·制造·驱动·FPGA实现之基础一
fpga开发·lcd显示·fpga点亮屏幕·minilvds
Coder-hong19 小时前
TopJTAG Probe连接zynq
fpga开发
Aaron15881 天前
RFSOC+VU13P/VU9P+GPU多通道同步一体化解决方案
人工智能·嵌入式硬件·算法·matlab·fpga开发·硬件架构·基带工程
ALINX技术博客1 天前
【黑金云课堂】FPGA技术教程Linux开发:串行通信接口与实时时钟模块
linux·fpga开发
Felven1 天前
国产ZYNQ multiboot功能介绍与实现
linux·fpga开发·multiboot·国产zynq
cjie2211 天前
DDR3速率分档
fpga开发
坏孩子的诺亚方舟2 天前
open_prj22_IIC读写EEPROM、AD/DA、PLSYSMON
fpga开发·mpsoc