How to instantiate another vhd file inside testbench, where the testbench is used for opening files

OP #7575376

I am trying to learn how to read from file in VHDL, the vhdl_code.vhd implements a low pass moving average filter, I already have a separate vhdl code Read_File.vhd that reads the data, now I have to read the column data from the file data2fpga.dat, and perform the low-pass operations in vhdl_code.vhd. My question is, should the Read_file.vhd should run as testbench or, how exactly i can perform this, i.e. how can I invoke the vhdl_code.vhd into Read_file.vhd? Any guidance will be highly appreciated. Thanks.

Attached files:
Moderator (Company: Titel)

Zahid wrote:

should the Read_file.vhd should run as testbench

A testbench does not have any ports in its entity, because it is the uppermost level of the design. So it looks like the ReadFile may be a component of your testbench. And the testbench manages the interconnets between the ReadFile and lab111 components.

OP

@Von Lothar, I never coded a testbench which has a component that happens to be a testbench itself, this is the first time I am seeing it, the problem is the clk signal, both entity lab111 and ReadFile have clk ports, you are right, testbench should NOT have any ports, but I tried to perform the operations nevertheless, & I got the error "Declaration with designator "clk" already exists in this region." If it is not much to ask, I could not find any tutorials that have similar problems, can you guide me to any literature or learning videos so that I can learn & solve this problem?

Thanks a lot for replying to the previous message.

Zahid.

Moderator (Company: Titel)

In the testbench you define ak clock signal and in the very same test bench you connect that clock signal to all components needing that clock signal.

Look how iI do it there with some components (its German, but Google translator will do it):

Top level is the testbench which generates a clock signal. In the test bench the clock ist connected to the SinusPWM. And in the SinusPWM there are two components which also get that clock signal routed through.

So all in VHDL designs there only are entities which act as components in other entities.

OP

Ok, thank you Mr. Lothar, your comment "So it looks like the ReadFile may be a component of your testbench." solved my issue. You are right, testbenches should not have entities, i created a new testbench, instantiated both the ReadFile and Lab111 as components, make the necessary port and generic maps & was finally able to load the data into the testbench. Thanks again. Best of Regards, Zahid.

Reply

A question of your own? This thread is over 2 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.