mjuneja
Advanced Member level 4
- Joined
- Aug 28, 2016
- Messages
- 105
- Helped
- 12
- Reputation
- 24
- Reaction score
- 10
- Trophy points
- 18
- Location
- Bangalore, India
- Activity points
- 674
Code:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE std.textio.ALL;
USE ieee.numeric_std.ALL;
ENTITY Trial_test IS
END Trial_test;
ARCHITECTURE behavior OF Trial_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Trial
PORT(
clk : IN std_logic;
c : IN std_logic_vector(15 downto 0);
d : OUT std_logic_vector(15 downto 0)
);
END COMPONENT;
--Inputs
signal c : std_logic_vector(15 downto 0) := (others => '0');
signal clk : std_logic;
--Outputs
signal d : std_logic_vector(15 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
shared variable Data_in : integer;
shared variable inline : line;
signal linenumber : integer;
file img : text
open read_mode is "D:\New folder_lin\img.txt";
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Trial PORT MAP (
c => c,
clk => clk,
d => d
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
stim_proc: process(clk)
begin
if(not endfile(img)) then
if(rising_edge(clk)) then
readline(img,inline);
read(inline,Data_in);
c <= STD_LOGIC_VECTOR(to_unsigned(Data_in,16));
end if;
end if;
end process;
END;
In the above written VHDL code for a testbench using std_textio,
while reading the img.txt file in the stim_proc, elements of files are read line by line in a sequential order.
My question is can I read the img.txt file in a random order that is instead of going line by line, certain lines can be jumped and we can directly read data 4 lines or 5 lines apart.
Please clarify..