------------------------------------------------------------------------- -- 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 . -- -- 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"3c011234", -- [0x00400000] lui $1, 4660 X"34225678", -- [0x00400004] ori $2, $1, 22136 X"3c012345", -- [0x00400008] lui $1, 9029 X"34236789", -- [0x0040000c] ori $3, $1, 26505 X"3c018765", -- [0x00400010] lui $1, -30875 X"34244321", -- [0x00400014] ori $4, $1, 17185 X"3c019876", -- [0x00400018] lui $1, -26506 X"34255432", -- [0x0040001c] ori $5, $1, 21554 X"00000000", -- [0x00400020] nop X"00427823", -- [0x00400024] subu $15, $2, $2 X"00437823", -- [0x00400028] subu $15, $2, $3 X"00447823", -- [0x0040002c] subu $15, $2, $4 X"00457823", -- [0x00400030] subu $15, $2, $5 X"00627823", -- [0x00400034] subu $15, $3, $2 X"00637823", -- [0x00400038] subu $15, $3, $3 X"00647823", -- [0x0040003c] subu $15, $3, $4 X"00657823", -- [0x00400040] subu $15, $3, $5 X"00827823", -- [0x00400044] subu $15, $4, $2 X"00837823", -- [0x00400048] subu $15, $4, $3 X"00847823", -- [0x0040004c] subu $15, $4, $4 X"00857823", -- [0x00400050] subu $15, $4, $5 X"00a27823", -- [0x00400054] subu $15, $5, $2 X"00a37823", -- [0x00400058] subu $15, $5, $3 X"00a47823", -- [0x0040005c] subu $15, $5, $4 X"00a57823", -- [0x00400060] subu $15, $5, $5 X"00000000", -- [0x00400064] nop X"00427822", -- [0x00400068] sub $15, $2, $2 X"00437822", -- [0x0040006c] sub $15, $2, $3 X"00447822", -- [0x00400070] sub $15, $2, $4 X"00457822", -- [0x00400074] sub $15, $2, $5 X"00627822", -- [0x00400078] sub $15, $3, $2 X"00637822", -- [0x0040007c] sub $15, $3, $3 X"00647822", -- [0x00400080] sub $15, $3, $4 X"00657822", -- [0x00400084] sub $15, $3, $5 X"00827822", -- [0x00400088] sub $15, $4, $2 X"00837822", -- [0x0040008c] sub $15, $4, $3 X"00847822", -- [0x00400090] sub $15, $4, $4 X"00857822", -- [0x00400094] sub $15, $4, $5 X"00a27822", -- [0x00400098] sub $15, $5, $2 X"00a37822", -- [0x0040009c] sub $15, $5, $3 X"00a47822", -- [0x004000a0] sub $15, $5, $4 X"00a57822", -- [0x004000a4] sub $15, $5, $5 X"00000000", -- [0x004000a8] nop X"08104000", -- [0x004000ac] j 0x00410000 [main] X"00000000", -- [0x004000b0] nop X"00000000", -- [0x004000b4] X"00000000", -- [0x004000b8] X"00000000", -- [0x004000bc] X"00000000", -- [0x004000c0] X"00000000", -- [0x004000c4] X"00000000", -- [0x004000c8] X"00000000", -- [0x004000cc] X"00000000", -- [0x004000d0] X"00000000", -- [0x004000d4] X"00000000", -- [0x004000d8] X"00000000", -- [0x004000dc] X"00000000", -- [0x004000e0] X"00000000", -- [0x004000e4] X"00000000", -- [0x004000e8] X"00000000", -- [0x004000ec] X"00000000", -- [0x004000f0] X"00000000", -- [0x004000f4] X"00000000", -- [0x004000f8] X"00000000" -- [0x004000fc] ); begin PROM_READ: dout <= word_array(to_integer(addr)); end itest;