Dear Members,
I need help with simulating a filter I have designed using the FDA tool
of Matlab.
I need to read data (hexadecimal format, 10 bit each) from a text file
and write the filter output to another file. I am not able to modify the
original testbench (generated by FDA tool in Matlab) to implement this.
It would much relief for me if anyone could help me on this.
The filter .fda file, HDL module and test bench generated by Matlab are
uploaded on the google drive link.
Thanks in advance.
May you please be more specific in "I am not able to modify the original
testbench"?
Does it mean
- the file is write protected?
- you are not aware of text editors?
- you don't know the procedure to read in a file in
verilog/systemverilog? ($fopen, $fscanf)
- this file-read procedure fails at any point?
- you already copied the data from this file into
filter_in_data_log_force and filter_out_expected, but it doesn't work as
intented, as the result is X instead of Y?
- there is a problem in including the datafile into matlab?
How can we help, if we don't know, at which point you struggle? Please
provide us more information.
Thanks EIKo for such an elaborate reply. Actually, I am new to Verilog
and I don't know how to use the $fread, $fwrite commands to write a test
bench. After much efforts, I have made one (filter_tb2.v). Can you just
review it to tell if I have done it correctly?
Currently, I am testing it with the attached HEX file (P28hex200.txt)
Basically thats the way to go. The code you provided had some issues.
After removing them, it is reading the content of the file, doing
something, and writing it to an output file.
You find the reworked version attached to the post.
The testbench was prooven in modelsim alter 15. The tcl-commands are
included in the testbench.
You have to check, whether the procedure and timing of applying the data
and reading it from the filter is done right. Also you have to proove
the filter output.
[...]
initial begin
// open files, read input Memory
$readmemh("P28hex200.txt", IN_MEM);
filter_output_file = $fopen("Filter_Output.txt", "w");
// Initialize Inputs
[...]
// Wait 100 ns for global reset to finish#100// release reset
[...]
// apply data to the filter and read resultfor (i = 0; i < 199; i=i+1) begin
#1
filter_in = IN_MEM[i];
#8
$fwrite(filter_output_file, "%h\n" , filter_out);
#1
$display(" in %u - out %u", filter_in, filter_out);
end
// close file
$fclose(filter_output_file);
// stop simulation#1 $finish;
[...]
Hey, EIKo thanks so much for such an elaborate answer. Your solution
worked out. I have verified the output using matlab as well. So, that's
a sigh of relief. I thought it was important to thank you.
Moreover, I would like to upload the files that I have used for everyone
else.