wtr
Full Member level 5
Hello all,
I can read in a file using vhdl, and I can compartmentalise it based on space ' ' delimiter, however I want to be able to split the read line based on a different delimiter...primarily '|'.
The code below will read the text file quoted below. However I want to be able to read the second quoted text file.
Doing so will give errors about | not being and int or std_logic or whatever.
I can read in a file using vhdl, and I can compartmentalise it based on space ' ' delimiter, however I want to be able to split the read line based on a different delimiter...primarily '|'.
The code below will read the text file quoted below. However I want to be able to read the second quoted text file.
Doing so will give errors about | not being and int or std_logic or whatever.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 read_ip : process file file_in : text; variable file_line : line; constant path : string := "C:/Sandbox/REDACTED_Code/bench/SPI_S_IF_TB/"; constant file_name : string := "rx_data_frame_1.txt"; constant file_pwd : string := path & file_name; variable scs : integer; variable delimiter : string(1 to 3); -- : character; variable data_in : byte; variable byte_index: integer; begin file_open(file_in, file_pwd, READ_MODE); wait until RISING_EDGE(CLK); -- read the header readline(file_in, file_line); while not endfile(file_in) loop DATA_RX_RE <= '0'; wait until RISING_EDGE(SCLK); readline(file_in, file_line); read(file_line, scs); -- int read, int if statement if scs = 1 then -- read(file_line, delimiter); hread(file_line, data_in); -- read(file_line, delimiter); read(file_line, byte_index); DATA_RX_RE <= '1'; SCS_RST <= '0'; else SCS_RST <= '1'; end if; DATA_RX_IN <= DATA_IN; wait until falling_edge(clk); wait until rising_edge(clk); end loop; file_close(file_in); report "finished" severity FAILURE; wait; end process;
SCS |Data_in | BYTE_index | Description
0 xx x XXX-START
0 xx x XXX-START
1 7E 1 START
1 11 2 SEQ_NO*
1 01 3 CTRL
1 01 4 PAYLOAD
1 00 5 PAYLOAD
1 00 6 PAYLOAD
1 00 7 PAYLOAD
1 00 8 PAYLOAD
1 AA 9 CRC32
1 F9 10 CRC32
1 B2 11 CRC32
1 11 12 CRC32
1 81 13 STOP
0 xx x XXX-STOP
0 xx x XXX-STOP
SCS |Data_in | BYTE_index | Description
0 | xx | x | XXX-START
0 | xx | x | XXX-START
1 | 7E | 1 | START
1 | 11 | 2 | SEQ_NO*
1 | 01 | 3 | CTRL
1 | 01 | 4 | PAYLOAD
1 | 00 | 5 | PAYLOAD
1 | 00 | 6 | PAYLOAD
1 | 00 | 7 | PAYLOAD
1 | 00 | 8 | PAYLOAD
1 | AA | 9 | CRC32
1 | F9 | 10 | CRC32
1 | B2 | 11 | CRC32
1 | 11 | 12 | CRC32
1 | 81 | 13 | STOP
0 | xx | x | XXX-STOP
0 | xx | x | XXX-STOP