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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 1514|回复: 1

[讨论] verilog use $random, why random seed be force changed?

[复制链接]
发表于 2020-10-3 16:31:56 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 luoyanghero 于 2020-10-3 16:47 编辑

//How use $random with seed?
//This is the verilog standard documentdiscription:
//The seed argument controls the numbers that$random returns so that different seeds generate different random streams. Theseed argument shall be an integral variable. The seed value should be assignedto this variable prior to calling $random.

//I did a test.




  1. `ifndef DLY
  2. `define DLY 1
  3. `endif

  4. module tb_top;
  5. reg             clk_bus;
  6. reg             brst_n;
  7. reg [31:0] frame_cnt;
  8. reg [31:0] cnt;

  9. initial begin
  10.     brst_n = 1'b1;
  11.     #1;
  12.     brst_n = 1'b0;
  13.     #100;
  14.     brst_n = 1'b1;
  15.     #1000000000;
  16.     //$finish;
  17. end

  18. initial begin
  19.     clk_bus = 1'b0;
  20.     forever #5 clk_bus = ~clk_bus;
  21. end

  22. always @ (posedge clk_bus or negedge brst_n) begin
  23.     if (~brst_n)
  24.         cnt[31:0] <= #`DLY 'd0;
  25.     else
  26.         cnt[31:0] <= #`DLY cnt + 1;
  27. end
  28. always @ (posedge clk_bus or negedge brst_n) begin
  29.     if (~brst_n)
  30.         frame_cnt[31:0] <= #`DLY 32'd0;
  31.     else if (cnt==1000)
  32.         frame_cnt[31:0] <= #`DLY frame_cnt + 1;
  33. end

  34. integer end_dly;
  35. initial begin
  36.     end_dly = 1;
  37.     while (1) begin
  38.         @(posedge clk_bus);
  39.         if (cnt==1001) begin
  40.             #`DLY end_dly = $random(frame_cnt[7:0]);//luoy why random seed(frame_cnt[7:0]) be force changed?
  41.         end
  42.     end
  43. end

  44. initial begin
  45.         //wait ((in_data_drv.frm_cnt == 1) && (in_data_drv.mb_y_cnt == 90));
  46.         $fsdbDumpfile("tb_top.fsdb");
  47.         $fsdbDumpvars(tb_top, 0);
  48. end
  49. endmodule



复制代码

1.png

//frame_cnt be force changed from 32'h1 to 32'hce.

 楼主| 发表于 2020-10-5 10:05:37 来自手机 | 显示全部楼层
有人遇到过吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

×

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

GMT+8, 2024-5-1 06:53 , Processed in 0.020468 second(s), 7 queries , Gzip On, Redis On.

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