I'm trying to create a simple cache to use in simulation with my processor design.
I want to populate the cache with instructions that are stored in a file, .bin or .txt.
The file has no more than 1023 lines, and each line has the following format:
Adr is the address of the instruction, and the instruction is the instruction code, and [tab] is a tab (space between addr and instruction).
Here's the problem:
Addr is written as a hex value, has 32 bits, and instruction is written as a binary value and also has 32 bits. So one line looks like, for example, this
My idea was to create an array of std logic vectors and each line was one std logic vector where elem(63 downto 32) would be the address and elem (31 downto 0) would be the instruction code.
How do I read each line and at the same time convert hex value into binary, ignore tab, read the instruction and store everything into one std logic vector?
Thanks in advance for your help.
Would something like this work:
while not endfile(load_file) loop readline(load_file, rdline); hread(rdline, address); read(rdline, data); memory(index) := data; index := index + 1; end loop;
My question is: does hread move the cursor when reading the line? Also, how would I go about skipping the tab character?