Why is my C code from dpigen not giving different random values when I run it multiple times?
1 次查看(过去 30 天)
显示 更早的评论
I am using Matlab R2019a to generate DPI C functions. I am generating C code from this function:
function stimulus = get_stimulus()
stimulus = rand(1,100);
end
However the C function doesn't behave as I expected. The value stimulus gives an array of 100 random-looking values, but when I run the test calling it multiple times, I get the same array each time.
I see a function named 'b_rand', and somewhere else in the comments I see:
This is a uniform (0,1) pseudorandom number generator
So it looks like this should be truly random, and I should get different outputs each time I run the test.
If it helps, I make calls to the C code like this. This is in a SystemVerilog testbench.
import stimulus_dpi_pkg::*;
chandle stim_objhandle=null;
real stimulus [0:99];
stim_objhandle=DPI_stimulus_initialize(stim_objhandle);
// Call the DPI function to get the simulus
DPI_stimulus(stim_objhandle,stimulus);
// Clean up DPIC function
DPI_stimulus_terminate(stim_objhandle);
Is this the expected behavior? If not, how do I fix it?
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!