D
daniel.larkin@gmail.com
Guest
All,
Within my verilog testbench I'd like to generate a signal which gives
the error between an arithmetic function using real numbers and an
approximation to the arithmetic function using a fixed point
representation resulting from the actual rtl.
i.e.
error = result_of_function_with_real_numbers_in_tb -
fixed_point_rtl_function_approximation;
My problem is that the arithmetic function uses e^x and I'm not aware
of a straightforward way of implementing this in the testbench using
Verilog/SystemVerilog. Consequently I considered generating the actual
real value offline using a C program and writing the result to a file
and then reading in this value into the tb. However it appears Verilog
(95 & 2001?) can only read hexadecimal or binary from a file (please
correct me if I'm wrong?). So it would seem to be necessary to write
the real value to file in its IEEE double/floating point binary format,
and afterwards do a fair bit of conversion before I could get it back
into a verilog real type.
The other option as I see it is to generate the error value completely
in software, and use shifted integers to capture the effects of the
precision loss due to the reduced wordlength of the fixed point
representation.
Whilst both options are achieveable, they seem overkill for what is
probably not an uncommon task.
Any suggestions or thoughts on the best approach would be most welcome
Regards
Daniel
Within my verilog testbench I'd like to generate a signal which gives
the error between an arithmetic function using real numbers and an
approximation to the arithmetic function using a fixed point
representation resulting from the actual rtl.
i.e.
error = result_of_function_with_real_numbers_in_tb -
fixed_point_rtl_function_approximation;
My problem is that the arithmetic function uses e^x and I'm not aware
of a straightforward way of implementing this in the testbench using
Verilog/SystemVerilog. Consequently I considered generating the actual
real value offline using a C program and writing the result to a file
and then reading in this value into the tb. However it appears Verilog
(95 & 2001?) can only read hexadecimal or binary from a file (please
correct me if I'm wrong?). So it would seem to be necessary to write
the real value to file in its IEEE double/floating point binary format,
and afterwards do a fair bit of conversion before I could get it back
into a verilog real type.
The other option as I see it is to generate the error value completely
in software, and use shifted integers to capture the effects of the
precision loss due to the reduced wordlength of the fixed point
representation.
Whilst both options are achieveable, they seem overkill for what is
probably not an uncommon task.
Any suggestions or thoughts on the best approach would be most welcome
Regards
Daniel