hdlbits_Fsm_onehot

  1. 1有error,但是我认为逻辑没错
module top_module(
    input in,
    input [9:0] state,
    output [9:0] next_state,
    output out1,
    output out2);
	
    parameter S0 = 10'h1,S1 =10'h2,S2=10'h4,S3=10'h8,S4=10'h10,S5=10'h20,S6=10'h40,S7=10'h80,S8=10'h100,S9=10'h200;
    
    always @(*)
        begin
            case(state)
                S0: next_state = in?S1:S0;
                S1: next_state = in?S2:S0;
                S2: next_state = in?S3:S0;
                S3: next_state = in?S4:S0;
                S4: next_state = in?S5:S0;
                S5: next_state = in?S6:S8;
                S6: next_state = in?S7:S9;
                S7: next_state = in?S7:S0;
                S8: next_state = in?S1:S0;
                S9: next_state = in?S1:S0;
                default: next_state = 0;
            endcase
        end
       /*         
    always @(*)
        begin
            state = next_state;
        end
    */
    assign out1 = (state ==S8) | (state ==S9);
    assign out2 = (state ==S7) | (state ==S9);
endmodule

module top_module(
    input in,
    input [9:0] state,
    output [9:0] next_state,
    output out1,
    output out2);
	
    parameter S0 = 0,S1 =1,S2=2,S3=3,S4=4,S5=5,S6=6,S7=7,S8=8,S9=9;
    
    assign next_state[0] = (state[0]==1& (~in)) | 
        (state[1]==1& (~in)) | 
        (state[2]==1& (~in)) | 
        (state[3]==1& (~in))|
        (state[4]==1& (~in)) |
        (state[7]==1& (~in)) |(state[8]==1& (~in)) |(state[9]==1& (~in));
    assign next_state[1] = (state[0]==1& (in)) | (state[8]==1& (in))|(state[9]==1& (in));
    assign next_state[2] = (state[1]==1& (in));
    assign next_state[3] = (state[2]==1& (in));
    assign next_state[4] = (state[3]==1& (in));
    assign next_state[5] = (state[4]==1& (in));
    assign next_state[6] = (state[5]==1& (in));
    assign next_state[7] = (state[6]==1& (in)) | (state[7]==1& (in));
    assign next_state[8] = (state[5]==1& (~in));
    assign next_state[9] = (state[6]==1& (~in));
    
    
    assign out1 = (state[8] ==1) | (state[9] ==1);
    assign out2 = (state[7] ==1) | (state[9] ==1);
endmodule

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值