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.

how to descripe a rom with std.textio in vhdl?

Status
Not open for further replies.

honeyleabe

Newbie level 5
Joined
Jul 28, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
deutschland
Activity points
1,332
vhdl textio

the code is below.when i simulation,read file fail.why?

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 rom is
Port ( read : in STD_LOGIC;
adr : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0)
);
end rom;

architecture Behav of rom is
subtype word is std_logic_vector(15 downto 0);
type memory is array(0 to 65535) of word;
signal adr_in:integer range 0 to 65535;
FILE romin :text is in "rom16.in";
begin
process(read,adr)
variable rom:memory;
variable startup:BOOLEAN:=TRUE;
variable lin:line;
variable j:integer;
variable output : STD_LOGIC_VECTOR (15 downto 0);
begin
if startup then
for j in rom'range loop
readline(romin,lin);
hread(lin,rom(j));
end loop;
startup:=false;
end if;

adr_in<=conv_integer(adr);
if (read ='1') then
output:=rom(adr_in);
else
output:=output;
end if;
dout<=output;
end process;
end Behav;

thanks for your attention
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top