oscarodrigo
Newbie level 3
read a file test bench std_logic_vector
Hello to everyone
I need to do a test bench by hand, it's necesary read from an external file that contains all the information, when I do that with modelsim, this show to me some values, but none of these values are in the external file (things like ?(32) ?(49) appears)
The test bench that I simulate is this:
And the text file contains values in this order
01 01
01 11
10 01
Suma_2 file only sum two different numbers, I only want to know how a test bench works reading from an external file for apply this to a biggest file
Thanks to all for any advice and sorry for my english
Hello to everyone
I need to do a test bench by hand, it's necesary read from an external file that contains all the information, when I do that with modelsim, this show to me some values, but none of these values are in the external file (things like ?(32) ?(49) appears)
The test bench that I simulate is this:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.std_logic_textio.all;
library STD;
use STD.textio.all;
entity tb_suma_2 is
end tb_suma_2;
architecture test_bench of tb_suma_2 is
component suma_2
port(
a,b : in std_logic_vector(1 downto 0);
c : out std_logic_vector(1 downto 0)
);
end component;
signal a, b, c : std_logic_vector(1 downto 0);
begin
cut:suma_2
port map(
a => a,
b => b,
c => c
);
lecturarocess
variable read_len : natural;
variable a_tmp, b_tmp, c_tmp : std_logic_vector(1 downto 0);
type text is file of std_logic_vector;
file vector_file : text open read_mode is "suma.txt";
begin
while not endfile(vector_file) loop
read(vector_file, a_tmp, read_len);
a <= a_tmp;
read(vector_file, b_tmp, read_len);
b <= b_tmp;
end loop;
wait;
end process;
end test_bench;
And the text file contains values in this order
01 01
01 11
10 01
Suma_2 file only sum two different numbers, I only want to know how a test bench works reading from an external file for apply this to a biggest file
Thanks to all for any advice and sorry for my english