1
我正在尝试为模拟纸牌游戏的VHDL项目实现测试台。vhdl testbench的纸牌游戏?
我需要计算游戏中获胜的几率,在按下按钮时从持续计数的计数器中抽取卡。
为了引入随机性,我需要以随机时间间隔向卡片绘制模块发送一个脉冲。我只是想知道如何实现它。
我不知道如何实现一个,所以我试了这个。
tb: process
VARIABLE seed1, seed2: positive;
VARIABLE rand: real;
VARIABLE int_rand: integer;
variable time_var1, time_var2: time ;
begin
uniform(seed1, seed2,rand);
int_rand := INTEGER(trunc(rand*4096.0));
int_rand := to_integer((to_unsigned(int_rand, 14)));
time_var2 := (10 ms + (int_rand*1 us));
end process;
然后,我发送邮件使用
key1 <= '1';
wait for time_var2;
key1 <= '0';
wait for 2ns;
and repeat...
我使用的ModelSim启动脉冲。