题解 | #根据状态转移表实现时序电路#

根据状态转移表实现时序电路

https://www.nowcoder.com/practice/455c911bee0741bf8544a75d958425f7

`timescale 1ns/1ns

module seq_circuit(
      input                A   ,
      input                clk ,
      input                rst_n,
 
      output   wire        Y   
);
reg [1:0]state; //QQ
reg [1:0]state_next;
assign Y = state[0]&state[1];
//assign Y = (state==2'b11);  这样写会不通过
always@(posedge clk or negedge rst_n)
begin 
    if(~rst_n)begin
   state <= 2'b00;end
    else
    state <= state_next;

end
always@(*)
begin
    case (state)
     2'b00:begin state_next = A?2'b11:2'b01;end
     2'b01:begin state_next = A?2'b00:2'b10;end
     2'b10:begin state_next = A?2'b01:2'b11;end
     2'b11:begin state_next = A?2'b10:2'b00;end
     default :begin  state_next = 2'b00; end
    endcase
end
endmodule

全部评论

相关推荐

点赞 评论 收藏
分享
用微笑面对困难:只要你保证项目和获奖都是真的就行尤其是“对战,总负责人”啊这些套职,基本上队员,打杂的都这么写
点赞 评论 收藏
分享
AC鸽想进大厂:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务