-
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
相关推荐
RainCity17 小时前
Java Swing 自定义组件库分享(十二)LinXunFeng8 天前
Obsidian - 使用 Share Note 分享笔记并自部署坏孩子的诺亚方舟12 天前
FPGA系统架构设计实践15_高云Arora V系列时钟体系闪闪发亮的小星星12 天前
高斯光以及高斯光公式解释cqbzcsq12 天前
CellFlow虚拟细胞论文阅读阿米亚波13 天前
【Windows】QEMU 启动 openEuler aarch64/arm64 架构系统 + 离线软件源自传.13 天前
尚硅谷 Vibe Coding|第三章(1) Claude Code深度使用与进阶技巧 学习笔记.千余13 天前
【C++】模板进阶全解:非类型参数|全特化|偏特化|分离编译完全指南自传.13 天前
尚硅谷 Vibe Coding|第二章 AI编程工具生态 学习笔记秋波。未央13 天前
Java Agent 开发 · Day 1 学习笔记(含作业完整标准答案)