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.

Read from a text file

Status
Not open for further replies.

bachoo786

Junior Member level 1
Junior Member level 1
Joined
Oct 25, 2012
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,480
Hello there,

I have got this code for reading data from a text file into a RAM. I get this warning "net mem [0][7] does not have a driver." Can anyone please have a look at my code, if I am missing something? Many thanks !!

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;

entity rom is
port (
clk :in std_logic; -- Clock
read_en :in std_logic; -- Read enable
address :in std_logic_vector (7 downto 0); -- Address input
data :eek:ut std_logic_vector (7 downto 0) -- Data output
);
end entity;
architecture behavior of rom is

-- RAM block 8x256
type RAM is array (integer range <>) of std_logic_vector (7 downto 0);
signal mem : RAM (0 to 255);

-- Instructions to read a text file into RAM --
procedure Load_ROM (signal data_word :inout RAM) is
-- Open File in Read Mode
file romfile :text open read_mode is "memory.txt";
variable lbuf :line;
variable i :integer := 0;
variable fdata :std_logic_vector (7 downto 0);
begin
while not endfile(romfile) loop
-- read data from input file
readline(romfile, lbuf);
read(lbuf, fdata);
data_word(i) <= fdata;
i := i+1;
end loop;
end procedure;

begin
process(clk,read_en,mem)

begin

-- Procedural Call --
Load_ROM(mem);

if(clk'event and clk = '1') then
if(read_en='1')then
data <= mem(to_integer(unsigned(address)));
else
data <="ZZZZZZZZ";
end if;
end if;
end process;

end architecture;
 

Yeah, because you're procedure doesn't even load anything into the mem array.
 

On top of ads_ee's post above, you have a process that reloads the RAM on every clk'event, read_en'event and mem'event. You should initialise the RAM from a function called at initialisation time.
 

Tricky,

Code:
begin

-- Procedural Call --
Load_ROM(mem);

I think bachoo was trying to initialize the ram using this procedure like a SW call. I think bachoo thinks in SW terms and VHDL looks like SW so it must be just like C. ;-)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top