-
q5b
module top_module (
input clk,
input areset,
input x,
output z
);parameter A = 1'b0; parameter B = 1'b1; reg[1:0] state; reg[1:0] next_state; always@(*) begin case(state) A: if(x) next_state = B; else next_state = A; B: next_state = B; endcase end always@(posedge clk or posedge areset) begin if(areset) state = A; else state = next_state; end always@(*) begin if(state == A) begin if(x) z = 1'b1; else z = 1'b0; end else begin if(x) z = 1'b0; else z = 1'b1; end endendmodule
-
q3a
module top_module(
input clk,
input reset,
input s,
input w,
output z
);parameter A = 1'd0; parameter B = 1'd1; reg[1:0] state; reg[1:0] next_state; reg[1:0] count; reg[1:0] num; always @(*) begin case(state) A: begin if(s) next_state = B; else next_state = A; end B: begin next_state = B; end endcase end always @(posedge clk) begin if(reset) state <= A; else state <= next_state; end always @(posedge clk) begin if(reset) count <= 2'd0; else if(count == 2'd2) count <= 2'd0; else if(state == B) count <= count + 1'b1; end always @(posedge clk) begin if(reset) num <= 1'b0; else begin if(count == 2'd0) begin if(w) num <= 1'b1; else num <= 1'b0; end else if(state == B) begin if(w) num <= num + 1'b1; else num <= num; end end end assign z = (state == B && num == 2'd2 && count == 2'd0);endmodule
Circuits--Sequential--FSM--q5b~q3a
且听风吟5672024-05-27 9:52
相关推荐
YJlio14 分钟前
Active Directory 工具学习笔记(10.8):AdInsight——保存与导出(证据留存、共享与二次分析)xqqxqxxq1 小时前
背单词软件技术笔记(V2.0扩展版)yuxb731 小时前
Kubernetes核心组件详解与实践:controller受之以蒙3 小时前
Rust 与 dora-rs:吃透核心概念,手把手打造跨语言的机器人实时数据流应用2401_834517073 小时前
AD学习笔记-36 gerber文件输出hhhhhhh_hhhhhh_3 小时前
TC3x7-DEMO-V1.0原理图自学笔记气π3 小时前
【JavaWeb】——(若依 + AI)-基础学习笔记深蓝海拓3 小时前
PySide6从0开始学习的笔记(三) 布局管理器与尺寸策略暗然而日章3 小时前
C++基础:Stanford CS106L学习笔记 8 继承2401_834517074 小时前
AD学习笔记-34 PCBlogo的添加