How to initialize the memory in testbench when simulate a processor ?

OP (Company: NUDT) #2229613
Rate this post
• ▲ useful
▼ not useful
Hi, everyone!

In my project, I use a procedure "file sim_vector  in stimulation.txt" 
in the textio lib to read the stimulation file into "sim_vector", and 
then I read the file line by line. In each line , I read the stimulating 
data one by one, and put them one by one into the right port of the 
memory(ram).

I think it too slow to input the program and data into the ram, and a 
little bit complicated.


What I need is a procedure or method in VHDL, just like 
"readmemb<memory, stimu.txt, @address>" in verilog, to inital my ram . 
So could u help me?
Guest #2229801
Rate this post
• ▲ useful
▼ not useful
you can use your function to write direct to the memory

type array(1024 downto 0) of std_logic_vector(31 downto 0);
signal memory : myarray := init_function("filename");

you only need to write a inif_function, which returns an array with the 
memory content
OP (Company: NUDT) #2263430
Rate this post
• ▲ useful
▼ not useful
hi!
you mean that I should design the init_function(stimulation.txt) in my 
sram.vhd?
I wanna use: [file stimulation_file : text is in  "stimulation.txt"] , 
when I design the function, then read the stimulation_file line by line, 
and put the value into each unit of my sram, so am I right?

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.