-
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 end
endmodule
-
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
相关推荐
ljt27249606611 小时前
Compose笔记(二十六)--DatePicker早日退休!!!2 小时前
性能优化笔记love530love3 小时前
【PyCharm必会基础】正确移除解释器及虚拟环境(以 Poetry 为例 )普宁彭于晏4 小时前
元素水平垂直居中的方法m0_637146934 小时前
计算机网络基础总结:TCP/IP 模型、TCP vs UDP、DNS 查询过程Lester_11015 小时前
嵌入式学习笔记 - freeRTOS vTaskPlaceOnEventList()函数解析moxiaoran57536 小时前
uni-app学习笔记二十三--交互反馈showToast用法GateWorld10 小时前
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析LLP (二)scdifsn13 小时前
动手学深度学习12.7. 参数服务器-笔记&练习(PyTorch)jackson凌16 小时前
【Java学习笔记】SringBuffer类(重点)