EmbDev.net

Forum: FPGA, VHDL & Verilog Implement FIR filter in verilog using FDA tool


von Usman A. (Company: LUMS) (usmanashraf678)


Attached files:

Rate this post
useful
not useful
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.

von ElKo (Guest)


Rate this post
useful
not useful
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.

von Usman A. (Company: LUMS) (usmanashraf678)


Attached files:

Rate this post
useful
not useful
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)

von ElKo (Guest)


Attached files:

Rate this post
useful
not useful
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.
1
[...]
2
initial begin
3
    // open files, read input Memory
4
        $readmemh("P28hex200.txt", IN_MEM);
5
        filter_output_file = $fopen("Filter_Output.txt", "w");
6
        
7
    // Initialize Inputs
8
        [...]
9
        
10
    // Wait 100 ns for global reset to finish
11
        #100
12
    
13
    // release reset
14
        [...]
15
    
16
    // apply data to the filter and read result
17
        for (i = 0; i < 199; i=i+1) begin
18
            #1 
19
            filter_in = IN_MEM[i];
20
            #8
21
            $fwrite(filter_output_file, "%h\n" , filter_out);
22
            #1
23
            $display("          in %u - out %u", filter_in, filter_out);
24
        end
25
26
    // close file
27
        $fclose(filter_output_file);
28
    
29
    // stop simulation
30
        #1 $finish;
31
[...]

von Usman A. (Company: LUMS) (usmanashraf678)


Attached files:

Rate this post
useful
not useful
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.

von ElKo (Guest)


Rate this post
useful
not useful
Glad to hear, that it helped you. Thanks for the feedback!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.