122 lines
6.7 KiB
VHDL
122 lines
6.7 KiB
VHDL
-------------------------------------------------------------------------
|
|
-- Project: JCPU, a portable 8-bit RISC CPU written in VHDL
|
|
-- This file: The ROM file for use in your VHDL design
|
|
--
|
|
-- Copyright (C) 2007 J. Ahrensfeld
|
|
--
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
--
|
|
-- This program is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
--
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
--
|
|
-- For questions and ideas, please contact the author at jens@jayfield.org
|
|
--
|
|
--------------------------------------------------------------------------
|
|
|
|
LIBRARY ieee;
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
USE ieee.numeric_std.ALL;
|
|
|
|
|
|
ENTITY rom IS
|
|
Generic
|
|
(
|
|
addr_width : integer := 2;
|
|
data_width : integer := 32
|
|
);
|
|
Port
|
|
(
|
|
addr : in unsigned(addr_width-1 downto 0);
|
|
dout : out unsigned(data_width-1 downto 0)
|
|
);
|
|
END rom;
|
|
|
|
ARCHITECTURE itest OF rom IS
|
|
|
|
subtype word_t is unsigned(data_width-1 downto 0);
|
|
type word_array_t is array (0 to 2**addr_width-1) of word_t;
|
|
|
|
-- Assembled from itest.jsm
|
|
constant word_array : word_array_t :=
|
|
(
|
|
X"08100001", -- [0x00400000] j 0x00400004 [main] ; 5: j main
|
|
X"3c080000", -- [0x00400004] lui $8, 0 ; 7: lui $8, 0
|
|
X"00000000", -- [0x00400008] nop ; 8: sll $0, $0, 0
|
|
X"0c100009", -- [0x0040000c] jal 0x00400024 [subr1] ; 9: jal subr1
|
|
X"3c010040", -- [0x00400010] lui $1, 64 [subr2] ; 10: la $2, subr2
|
|
X"34220030", -- [0x00400014] ori $2, $1, 48 [subr2]
|
|
X"00407809", -- [0x00400018] jalr $15, $2 ; 11: jalr $15, $2
|
|
X"00000000", -- [0x0040001c] nop ; 12: sll $0, $0, 0
|
|
X"08100002", -- [0x00400020] j 0x00400008 [loop] ; 13: j loop
|
|
X"21080001", -- [0x00400024] addi $8, $8, 1 ; 15: addi $8, 1
|
|
X"00000000", -- [0x00400028] nop ; 16: sll $0, $0, 0
|
|
X"03e00008", -- [0x0040002c] jr $31 ; 17: jr $31
|
|
X"21080010", -- [0x00400030] addi $8, $8, 16 ; 18: addi $8, 16
|
|
X"00000000", -- [0x00400034] nop ; 19: sll $0, $0, 0
|
|
X"01e00008", -- [0x00400038] jr $15 ; 20: jr $15
|
|
X"00000000", -- [0x0040003c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400040] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400044] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400048] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040004c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400050] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400054] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400058] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040005c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400060] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400064] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400068] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040006c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400070] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400074] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400078] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040007c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400080] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400084] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400088] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040008c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400090] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400094] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x00400098] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x0040009c] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000a0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000a4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000a8] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000ac] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000b0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000b4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000b8] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000bc] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000c0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000c4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000c8] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000cc] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000d0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000d4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000d8] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000dc] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000e0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000e4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000e8] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000ec] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000f0] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000f4] nop ; 21: sll $0, $0, 0
|
|
X"00000000", -- [0x004000f8] nop ; 21: sll $0, $0, 0
|
|
X"00000000" -- [0x004000fc] nop ; 21: sll $0, $0, 0
|
|
);
|
|
|
|
begin
|
|
|
|
PROM_READ:
|
|
dout <= word_array(to_integer(addr));
|
|
|
|
end itest;
|