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
library work;
use work.lpm_pack.all;
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(31 downto 0);
iout, dout : out std_logic_vector(31 downto 0));
end idram;
architecture RTL of idram is
type RamType is array(0 to 255) of bit_vector(31 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);
read (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)) <= to_bitvector(ini);
end if;
end if;
end process;
dout <= to_stdlogicvector(RAM(conv_integer(dad)));
-- 命令用RAM
iout <= to_stdlogicvector(RAM(conv_integer(iad)));
end RTL;
10001100010000010000000000010100
00000000100001010001100000100010
00000000111010000011000000100100
00000001010010110100100000100101
00000001101011100110000000100000
00000000000000000000000000000001
assembler comment
----------------------------------------------------------------------------
# P435 ラベル付けしたパイプラインでの命令実行状況
000 8C410014 : lw $1,20($2) #
004 00851822 : sub $3,$4,$5 #
008 00E83024 : and $6,$7,$8 #
00C 014B4825 : or $9,$10,$11 #
010 01AE6020 : add $12,$13,$14 #
014 00000001 : .word 1 #
process (clk) begin
if clk'event and clk = '1' then
if wr = '1' then
RAM(conv_integer(dad)) <= to_bitvector(ini);
end if;
dout <= to_stdlogicvector(RAM(conv_integer(dad)));
-- 命令用RAM
iout <= to_stdlogicvector(RAM(conv_integer(iad)));
end if;
end process;
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 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 | - | - | - | - | - | - |