在 VHDL 中获取 Unix 时间或纪元

发布于 2025-01-16 11:36:22 字数 97 浏览 0 评论 0原文

为了在我的测试平台中引入一些随机性,我想使用以当前 Unix 时间或纪元为种子的伪随机数。 VHDL 中有一个(不可综合的 ofc)函数吗?我需要它在 VHDL 2008 中工作。

To introduce some randomness in my testbench I would like to use pseudo-random numbers seeded with the current Unix time or epoch. Is there a (non-synthesizable ofc) function in VHDL for that? I need it to work in VHDL 2008.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱格式化 2025-01-23 11:36:22

为什么不在用于运行模拟的同一命令行上简单地传递通用参数值? bash 示例:

entity foo is
  generic(seed: natural := 0);
end entity foo;

architecture bar of foo is
begin
  assert false report natural'image(seed);
end architecture bar;
$ ghdl -a --std=08 foo.vhd
$ ghdl -r --std=08 foo
foo.vhd:7:3:@0ms:(assertion error): 0
$ ghdl -r --std=08 foo -gseed=$(date +%s)
foo.vhd:7:3:@0ms:(assertion error): 1648027085

Why not simply passing a generic parameter value on the same command line you use to run the simulation? Example with bash:

entity foo is
  generic(seed: natural := 0);
end entity foo;

architecture bar of foo is
begin
  assert false report natural'image(seed);
end architecture bar;
$ ghdl -a --std=08 foo.vhd
$ ghdl -r --std=08 foo
foo.vhd:7:3:@0ms:(assertion error): 0
$ ghdl -r --std=08 foo -gseed=$(date +%s)
foo.vhd:7:3:@0ms:(assertion error): 1648027085
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文