【求助】:在ISE10.1功能仿真时正确,时序仿真结果出错

[复制链接]
1814|2
手机看帖
扫描二维码
随时随地手机跟帖
anshasha|  楼主 | 2010-5-9 19:29 | 显示全部楼层 |阅读模式
这是我的代码的一个模块,我拿来仿真了一下,在功能仿真时仿真结果正确,时序仿真的结果就不完全对,求达人帮忙看下有什么问题。
程序的主要功能就是把输入cmd的数据(cmd[4]=1时才会记录)记录在password里
module jlmm(password,cmd,clk,resetb
    );
input clk,resetb;
input[4:0]cmd;
reg[2:0]sub_state,next_sub_state;
output[15:0] password;
reg [15:0]password;
parameter      first=3'b000,
     second=3'b001,
     third=3'b010,
     fourth=3'b011,
     finish=3'b100;
[email=always@(posedge]always@(posedge[/email] clk or negedge resetb)
begin
if(!resetb)
  sub_state<=first;
else
  sub_state<=next_sub_state;
end
[email=always@(cmd]always@(cmd[/email] or sub_state)
begin
if(cmd[4]==1)
    case(sub_state)
    first:
     next_sub_state=second;
    second:
     next_sub_state=third;
    third:
     next_sub_state=fourth;
    fourth:
     next_sub_state=finish;
    finish:
     next_sub_state=finish;
    endcase
  else
   next_sub_state=sub_state;
end
[email=always@(posedge]always@(posedge[/email] clk or negedge resetb)
begin
if(!resetb)
  password<=0;
else if(cmd[4]==1)
  case(sub_state)
  first:
   password[15:12]<=cmd[3:0];
  second:
   password[11:8]<=cmd[3:0];
  third:
   password[7:4]<=cmd[3:0];
  fourth:
   password[3:0]<=cmd[3:0];
  default:
   password<=password;
  endcase
else
  password<=password;
end
endmodule

相关帖子

anshasha|  楼主 | 2010-5-9 19:30 | 显示全部楼层
module jlmm(password,cmd,clk,resetb
    );
input clk,resetb;
input[4:0]cmd;
reg[2:0]sub_state,next_sub_state;
output[15:0] password;
reg [15:0]password;
parameter      first=3'b000,
                                        second=3'b001,
                                        third=3'b010,
                                        fourth=3'b011,
                                        finish=3'b100;
always@(posedge clk or negedge resetb)
begin
        if(!resetb)
                sub_state<=first;
        else
                sub_state<=next_sub_state;
end

always@(cmd or sub_state)
begin
        if(cmd[4]==1)
                                case(sub_state)
                                first:
                                        next_sub_state=second;
                                second:
                                        next_sub_state=third;
                                third:
                                        next_sub_state=fourth;
                                fourth:
                                        next_sub_state=finish;
                                finish:
                                        next_sub_state=finish;       
                                endcase
                else
                        next_sub_state=sub_state;
end

always@(posedge clk or negedge resetb)
begin
        if(!resetb)
                password<=0;
        else if(cmd[4]==1)
                case(sub_state)
                first:
                        password[15:12]<=cmd[3:0];
                second:
                        password[11:8]<=cmd[3:0];
                third:
                        password[7:4]<=cmd[3:0];
                fourth:
                        password[3:0]<=cmd[3:0];
                default:
                        password<=password;
                endcase
        else
                password<=password;
end
endmodule

使用特权

评论回复
anshasha|  楼主 | 2010-5-9 19:31 | 显示全部楼层
之前代码出错了,重新发了一次

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

6

帖子

1

粉丝