MATLAB Answers

Why is my C code from dpigen not giving different random values when I run it multiple times?

1 view (last 30 days)
John Smith
John Smith on 25 Mar 2020
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);
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];
// Call the DPI function to get the simulus
// Clean up DPIC function
Is this the expected behavior? If not, how do I fix it?


Sign in to comment.

Answers (0)