Author Topic: How to read a txt file into VHDL ROM?  (Read 2227 times)

0 Members and 1 Guest are viewing this topic.

Offline matrixofdynamism

  • Contributor
  • Posts: 47
How to read a txt file into VHDL ROM?
« on: June 26, 2015, 02:13:29 am »
I am designing a processor which shall store instructions in a ROM (as expected).

For purpose of simulation I want to parse a text file and load the contents of the result into a huge std_logic_vector into the ROM. The actual file shall store instructions in an assembly like format, they shall have to parsed and translated into binary words for std_logic_vector.

How do I do this? This should happen as soon as the simulation starts.
 

Offline Bassman59

  • Frequent Contributor
  • **
  • Posts: 974
  • Country: us
  • Yes, I do this for a living
Re: How to read a txt file into VHDL ROM?
« Reply #1 on: June 26, 2015, 03:54:01 am »
I am designing a processor which shall store instructions in a ROM (as expected).

For purpose of simulation I want to parse a text file and load the contents of the result into a huge std_logic_vector into the ROM. The actual file shall store instructions in an assembly like format, they shall have to parsed and translated into binary words for std_logic_vector.

How do I do this? This should happen as soon as the simulation starts.

Look into the VHDL textio library; it's a standard thing.
 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: nz
Re: How to read a txt file into VHDL ROM?
« Reply #2 on: June 26, 2015, 10:48:33 am »
See page 241of http://www.xilinx.com/support/documentation/sw_manuals/xilinx13_3/xst_v6s6.pdf

Quote
Specifying RAM Initial Contents in an External Data File
• Use the file read function in the HDL source code to load the RAM initial contents
from an external data file.
– The external data file is an ASCII text file with any name.
– Each line in the external data file describes the initial content at an address
position in the RAM.
– There must be as many lines in the external data file as there are rows in the
RAM array. An insufficient number of lines is flagged.
– The addressable position related to a given line is defined by the direction of
the primary range of the signal modeling the RAM.
– You can represent RAM content in either binary or hexadecimal. You cannot
mix both.
– The external data file cannot contain any other content, such as comments.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf