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.

Test Bench reading from an extern File on VHDL

Status
Not open for further replies.

oscarodrigo

Newbie level 3
Joined
Mar 31, 2009
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
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:


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
);

lectura:process

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 :D:D
 

testbench read from txt

i think u have missed the "readline" function before read function...

Check the below link
**broken link removed**
 

test bench reading from file

mmm it doen't work if i put a readline before the read function :(
 

vhdl file read std_logic_vector

Hi,

lectura:process
variable rdline : line;
variable a_tmp, b_tmp, c_tmp : std_logic_vector(1 downto 0);

file vector_file : text open read_mode is "suma.txt";

begin

while not endfile(vector_file) loop
readline(vector_file, rdline);
read(rdline, a_tmp);
read(rdline, b_tmp);
a <= a_tmp;
b <= b_tmp;
wait for 1 ns;
end loop;
wait;
end process;

I do not know why you declare a "type text is file ...". It is not necessary.

If you do not put a wait statement in the loop, the entire file is read at time 0 ns and you will only see the latest line at signal a and b.

Devas
 
writing std_logic_vectors to a text file

Oh! now it's working!!

Thanks you so much!
 

how to do reading process if the text in form of a matrix?????
 

i did that but that shows me error for declaring arrays ??? can u give some example plz ??
 

Why not post the problems. We are not telepathic.
 

Thnx
sir,actually i have an image processing project in which i have to implement 2d convolution filtering. I tried to develop the code for convolution and then check the output by entering the arbitrary input vectors.but i do not how how to do it actually for an 2d image. I also tried to use textio about which i do not hv much knowlege .since i have less time for completion i want to read the data from text file in my test bench .Is it possible to read text file which is in matrix form in the tesh bench so that my input data is read from this file ?? Plz guide me
 

You can read any text into a testbench, you can deconstruct the file however you want, and read it into pretty much any type. Only you can do it though, because only you know the formatting.

If you are short of time, then I think you are probably stuck. Better get reading those VHDL tutorials asap.
 

The format in which your file stores the matrix. That formatting.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top