Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Read from a Text File, urgent help needed.

Status
Not open for further replies.
A

andonie12

Guest
Hello There,

In the current attached vhdl code: I am reading a text file "sim2.dat" which content is one column.

00000
00001
00010
00011

The question is how to read a text file "sim2.dat" which content is consists of two column instead of one column.

we data
00 00000
01 00001
10 00010
11 00011

I need the vhdl code for that if you know it. I included the complete design on how to read on column.
 

hello, you can use UltraEdit to select the expected column.
 

You can use bit_vector instead of string. Just invoke read for a line as many times as your data go.

If your data looks like
we data
00 0000
...

Then you add the following signal declaration in read_file.vhd

signal we : std_logic_vector( 1 downto 0);

And change the receive_data process with the following

==============================
receive_data: process

variable l: line;
--variable s: string(y'range);
variable swe: bit_vector(1 downto 0);
variable s: bit_vector(y'range);

begin

eog <= '0';

-- wait for reset to complete
wait until rst = '1';
wait until rst = '0';


while not endfile(stimulus) loop

-- read digital data from input file
readline(stimulus, l);
read(l, swe);
read(l, s);
--y <= to_std_logic_vector(s);
we <= to_stdlogicvector(swe);
y <= to_stdlogicvector(s);

wait until clk = '1';

end loop;

print("i@read_file: reached end of " & stim_file);
eog <= '1';

wait;

end process receive_data;
==================================
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top