123 lines
6.8 KiB
VHDL
123 lines
6.8 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"00000000", -- [0x00400004] nop ; 7: sll $0, $0, 0
|
|
X"3c011000", -- [0x00400008] lui $1, 4096 ; 8: lui $1, 0x1000
|
|
X"20220000", -- [0x0040000c] addi $2, $1, 0 ; 9: addi $2, $1, 0
|
|
X"3c071234", -- [0x00400010] lui $7, 4660 ; 10: lui $7, 0x1234
|
|
X"3c050001", -- [0x00400014] lui $5, 1 ; 11: lui $5, 0x0001
|
|
X"ac270000", -- [0x00400018] sw $7, 0($1) ; 12: sw $7, 0($1)
|
|
X"8c430000", -- [0x0040001c] lw $3, 0($2) ; 13: lw $3, 0($2)
|
|
X"00654020", -- [0x00400020] add $8, $3, $5 ; 14: add $8, $3, $5
|
|
X"00654820", -- [0x00400024] add $9, $3, $5 ; 15: add $9, $3, $5
|
|
X"00655020", -- [0x00400028] add $10, $3, $5 ; 16: add $10, $3, $5
|
|
X"00655820", -- [0x0040002c] add $11, $3, $5 ; 17: add $11, $3, $5
|
|
X"00000000", -- [0x00400030] nop ; 18: sll $0, $0, 0
|
|
X"00000000", -- [0x00400034] nop ; 19: sll $0, $0, 0
|
|
X"08100001", -- [0x00400038] j 0x00400004 [main] ; 20: j main
|
|
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;
|