-
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
相关推荐
Aaron158811 分钟前
无人机反制中AOA+TDOA联合定位技术与雷达探测定位技术的应用对比分析三品吉他手会点灯1 小时前
C语言学习笔记 - 43.运算符与表达式 - 运算符1 - 运算符的分类和简单介绍疯狂打码的少年1 小时前
中断处理过程与中断优先级likerhood1 小时前
WSL 下安装 Miniconda 笔记喜欢打篮球的普通人3 小时前
LLVM 后端流程与关键数据结构:从 IR 到机器码的入门笔记烛之武3 小时前
Pytorch学习笔记(1)chushiyunen4 小时前
业务模型笔记searchforAI4 小时前
2026年AI笔记工具对比实测:NotebookLM、通义听悟、Ai好记怎么选?飞翔中文网5 小时前
Java学习笔记之反射衫水6 小时前
关于 AI 工程化 Harness 的一些笔记(2026/6/5)