library IEEE, STD;
use IEEE.std_logic_1164.all;
use STD.textio.all;
use IEEE.std_logic_textio.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
-- pragma translate_off
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
-- pragma translate_on
entity idram is
port(
clk, reset : in std_logic;
wr : in std_logic;
iad, dad : in std_logic_vector(7 downto 0);
ini : in std_logic_vector(15 downto 0);
iout, dout : out std_logic_vector(15 downto 0));
end idram;
architecture RTL of idram is
type RamType is array(0 to 255) of std_logic_vector(15 downto 0);
impure function InitRamFromFile (RamFileName : in string) return RamType is
FILE RamFile : text is in RamFileName;
variable RamFileLine : line;
variable RAM : RamType;
begin
for I in RamType'range loop
readline (RamFile, RamFileLine);
hread (RamFileLine, RAM(I));
end loop;
return RAM;
end function;
signal RAM : RamType := InitRamFromFile("idram.data");
begin
-- データ用RAM
process (clk) begin
if clk'event and clk = '1' then
if wr = '1' then
RAM(conv_integer(dad)) <= ini;
end if;
dout <= RAM(conv_integer(dad));
end if;
end process;
end RTL;
0101
1234
3456
FF00
0000
0000
0000
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | - | - | - | - |