-
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
相关推荐
aloha_7893 小时前
从零记录搭建一个干净的mybatis环境dsywws4 小时前
Linux学习笔记之vim入门A-超7 小时前
vue3展示pag格式动态图u0101526587 小时前
STM32F103C8T6学习笔记2--LED流水灯与蜂鸣器weixin_518285057 小时前
深度学习笔记10-多分类丘狸尾7 小时前
ubuntu【桌面】 配置NAT模式固定IPbigbig猩猩7 小时前
FPGA(现场可编程门阵列)的时序分析王俊山IT8 小时前
C++学习笔记----10、模块、头文件及各种主题(二)---- 预处理指令慕卿扬8 小时前
基于python的机器学习(二)—— 使用Scikit-learn库齐 飞10 小时前
MongoDB笔记02-MongoDB基本常用命令