Circuits--Sequential--Finite4

  1. Simple FSM3 asy

    module top_module(
    input clk,
    input in,
    input areset,
    output out); //

    复制代码
     parameter A=2'd0;
     parameter B=2'd1;
     parameter C=2'd2;
     parameter D=2'd3;
     
     reg[1:0] state;
     reg[1:0] next_state;
     
     // State transition logic
     always@(*)
         begin
             case(state)
                 A:
                     begin
                         if(in==0) next_state = A;
                         else next_state = B;
                     end
                 B:
                     begin
                         if(in==0) next_state = C;
                         else next_state = B;
                     end
                 C:
                     begin
                         if(in==0) next_state = A;
                         else next_state = D;
                     end
                 D:
                     begin
                         if(in==0) next_state = C;
                         else next_state = B;
                     end
             endcase
         end
    
     // State flip-flops with asynchronous reset
     always@(posedge clk or posedge areset)
         begin
             if(areset)
                 state = A;
             else
                 state = next_state;
         end
    
     // Output logic
     assign out = (state == D);

    endmodule

  2. Simple FSM3 sy

    module top_module(
    input clk,
    input in,
    input reset,
    output out); //

    复制代码
     parameter A=2'd0;
     parameter B=2'd1;
     parameter C=2'd2;
     parameter D=2'd3;
     
     reg[1:0] state;
     reg[1:0] next_state;
     
     // State transition logic
     always@(*)
         begin
             case(state)
                 A:
                     begin
                         if(in==0) next_state = A;
                         else next_state = B;
                     end
                 B:
                     begin
                         if(in==0) next_state = C;
                         else next_state = B;
                     end
                 C:
                     begin
                         if(in==0) next_state = A;
                         else next_state = D;
                     end
                 D:
                     begin
                         if(in==0) next_state = C;
                         else next_state = B;
                     end
             endcase
         end
    
     // State flip-flops with asynchronous reset
     always@(posedge clk )
         begin
             if(reset)
                 state = A;
             else
                 state = next_state;
         end
    
     // Output logic
     assign out = (state == D);

    endmodule

相关推荐
ReedFoley7 小时前
【笔记】动手学Ollama 第五章 Ollama 在 LangChain 中的使用 - Python 集成
笔记·langchain
Mr Sorry13 小时前
Non-stationary Diffusion For Probabilistic Time Series Forecasting论文阅读笔记
论文阅读·笔记
南猿北者14 小时前
Cmake学习笔记
笔记·学习·策略模式
码小文15 小时前
Altium Designer 22使用笔记(8)---PCB电气约束设置
笔记·嵌入式硬件·硬件工程·ad22
UserNamezhangxi17 小时前
kotlin 协程笔记
java·笔记·kotlin·协程
9527华安19 小时前
FPGA实现Aurora 64B66B图像视频点对点传输,基于GTH高速收发器,提供2套工程源码和技术支持
fpga开发·音视频·aurora·gth·高速收发器·64b66b
翻滚的小@强20 小时前
数据挖掘笔记:点到线段的距离计算
人工智能·笔记·数据挖掘
会思考的猴子21 小时前
UE5 PCG 笔记(二) Difference 节点
笔记·ue5
yuxb7321 小时前
Linux 文本处理与 Shell 编程笔记:正则表达式、sed、awk 与变量脚本
linux·笔记·正则表达式
饕餮争锋1 天前
设计模式笔记_行为型_访问者模式
笔记·设计模式·访问者模式