Reputation: 21
I would like to load a few data from .txt file into the testbench as input in order to run the simulation, but the data I wish to load in are real numbers.
For example:
0.00537667139546100
0.0182905843325460
-0.0218392122072903
0.00794853052089004
I found that $readmemh
, or $readmemb
are meant for hex or binary. Is there any method that can help me to load the data without convert it to binary or hex before loading it to the testbench?
Upvotes: 0
Views: 1858
Reputation: 5751
$readmemh
and $readmemb
are meant to load data into memory. As you mentioned, these functions requires hex or binary data. If you simply want to use some data read from file, you can use $fscanf
function with %f
format set, i.e.:
$fscanf(file,"%f ",real_num);
Upvotes: 2