------------------------------------------------------------------------- -- 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"3c081000", -- [0x00400020] lui $8, 4096 X"00000000", -- [0x00400024] nop X"2c4f1234", -- [0x00400028] sltiu $15, $2, 4660 X"2c4f2345", -- [0x0040002c] sltiu $15, $2, 9029 X"2c4fedcc", -- [0x00400030] sltiu $15, $2, -4660 X"2c4fdcbb", -- [0x00400034] sltiu $15, $2, -9029 X"2c6f1234", -- [0x00400038] sltiu $15, $3, 4660 X"2c6f2345", -- [0x0040003c] sltiu $15, $3, 9029 X"2c6fedcc", -- [0x00400040] sltiu $15, $3, -4660 X"2c6fdcbb", -- [0x00400044] sltiu $15, $3, -9029 X"2c8f1234", -- [0x00400048] sltiu $15, $4, 4660 X"2c8f2345", -- [0x0040004c] sltiu $15, $4, 9029 X"2c8fedcc", -- [0x00400050] sltiu $15, $4, -4660 X"2c8fdcbb", -- [0x00400054] sltiu $15, $4, -9029 X"2caf1234", -- [0x00400058] sltiu $15, $5, 4660 X"2caf2345", -- [0x0040005c] sltiu $15, $5, 9029 X"2cafedcc", -- [0x00400060] sltiu $15, $5, -4660 X"2cafdcbb", -- [0x00400064] sltiu $15, $5, -9029 X"00000000", -- [0x00400068] nop X"284f1234", -- [0x0040006c] slti $15, $2, 4660 X"284f2345", -- [0x00400070] slti $15, $2, 9029 X"284fedcc", -- [0x00400074] slti $15, $2, -4660 X"284fdcbb", -- [0x00400078] slti $15, $2, -9029 X"286f1234", -- [0x0040007c] slti $15, $3, 4660 X"286f2345", -- [0x00400080] slti $15, $3, 9029 X"286fedcc", -- [0x00400084] slti $15, $3, -4660 X"286fdcbb", -- [0x00400088] slti $15, $3, -9029 X"288f1234", -- [0x0040008c] slti $15, $4, 4660 X"288f2345", -- [0x00400090] slti $15, $4, 9029 X"288fedcc", -- [0x00400094] slti $15, $4, -4660 X"288fdcbb", -- [0x00400098] slti $15, $4, -9029 X"28af1234", -- [0x0040009c] slti $15, $5, 4660 X"28af2345", -- [0x004000a0] slti $15, $5, 9029 X"28afedcc", -- [0x004000a4] slti $15, $5, -4660 X"28afdcbb", -- [0x004000a8] slti $15, $5, -9029 X"00000000", -- [0x004000ac] nop X"08104000", -- [0x004000b0] j 0x00410000 [main] X"00000000", -- [0x004000b4] nop 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;