在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 1488|回复: 2

[求助] 很简单的逻辑,Vivado simulator和Modelsim仿真结果不一致

[复制链接]
发表于 2023-2-5 12:02:37 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 xyloophone 于 2023-2-5 12:07 编辑

Vivado版本是2019.2,Modelsim是10.4版本。实际上板测试结果和Modelsim的仿真结果一致。
-----------------------------------------------------------------------------------
// test.v
`timescale 1ns / 1ps

module test(
    input                clk,
    input                rst,
    input                veri_en,

    output      reg[127:0]  shift,
    output      reg[15:0]   circnt,
    output               veri_valid
);

localparam CIRTIMES = 16'H20;

always@ (posedge clk, posedge rst)
if(rst)begin
    circnt = 16'H0000;
end else begin
    if((circnt< (16'H8000+CIRTIMES))&veri_en)
        circnt = circnt+16'H0001;
    else
        circnt = circnt;
end

assign veri_valid = (circnt == (16'H8000+CIRTIMES));

//reg [127:0]  shift;
integer j;
always@ (posedge clk, posedge rst)
if(rst)begin
    shift <= 128'H0;
end else begin
    if(circnt[15]&(~veri_valid))begin
        shift = {shift[126:0],shift[127]};
    end
    else if (~circnt[15]) begin
        shift <= 128'HA4CC62E3D638AB6339633ADB7E354633;
    end else begin
        shift <= shift;
    end
end

endmodule
-----------------------------------------------------------------------------------
// test_tb.v
`timescale 1ns / 1ps

module test_tb();

    reg            clk;
    reg            rst;
    reg            veri_en;

    wire      [127:0]  shift;
    wire      [15:0]   circnt;
    wire               veri_valid;

    always #7.3 clk <= ~clk;
    initial begin
        #0    clk <= 0;
        #0    rst <= 1;
        #0    veri_en <= 0;

        #1000 rst <= 0;

        #120  veri_en <= 1;
    end

    test u_test(
                .clk         ( clk  ),
                .rst         ( rst       ),
                .veri_en     ( veri_en     ),

                .circnt      ( circnt      ),
                .shift       ( shift       ),

                .veri_valid  ( veri_valid  )
        );

endmodule
-----------------------------------------------------------------------------------
仿真结果得到的最终shift值不一致。Vivado仿真多进行了一次移位。下图是Vivado仿真的结果,在circnt=0x8000时进行了第一次移位,
Modelsim在在circnt=0x8001时进行第一次移位。就是这个位置不一致导致结果不一致。
这么简单的逻辑仿真软件应该不会出错。不清楚问题出在哪里。 v1.png




发表于 2023-2-5 12:56:25 | 显示全部楼层
好像有一个时序电路里用阻塞赋值了  
shift = {shift[126:0],shift[127]}
 楼主| 发表于 2023-2-5 15:16:27 | 显示全部楼层


硅下亡魂 发表于 2023-2-5 12:56
好像有一个时序电路里用阻塞赋值了  
shift = {shift[126:0],shift[127]}


多谢提醒。shift和上面的circnt都写成阻塞赋值了。改正后测试就正常了。为了查找原因折腾了一晚上。感谢、感谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-5 21:29 , Processed in 0.024431 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表