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

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

http://www.nowcoder.com/practice/e405fe8975e844c3ab843d72f168f9f4

`timescale 1ns/1ns

module seq_circuit( input C , input clk , input rst_n, output wire Y
); reg [1:0] cur_state; reg [1:0] nex_state; reg y1;

assign Y=y1;

always @(posedge clk or negedge rst_n)begin
    if(~rst_n)begin
        cur_state<=0;
    end
    else begin
        cur_state<=nex_state;
    end
end

always @(*)begin
    y1=cur_state[1]&(cur_state[0]|C);
end

always @(*)begin
    nex_state[1]=cur_state[1]&(cur_state[0]|C) | ~cur_state[1]&cur_state[0]&~C;
    nex_state[0]=~cur_state[1]&cur_state[0] | cur_state[0]&~C | ~cur_state[1]&C; 
end

endmodule

全部评论

相关推荐

西松屋:说明原部门有机会把
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务