------------------------------------------------------------------------- -- 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"08100001", -- [0x00400000] j 0x00400004 [main] X"3c011234", -- [0x00400004] lui $1, 4660 X"34215678", -- [0x00400008] ori $1, $1, 22136 X"3021f00f", -- [0x0040000c] andi $1, $1, -4081 X"2021affc", -- [0x00400010] addi $1, $1, -20484 X"2021ffff", -- [0x00400014] addi $1, $1, -1 X"1c20fffe", -- [0x00400018] bgtz $1 -8 [loop-0x00400018] X"3c020000", -- [0x0040001c] lui $2, 0 X"34420001", -- [0x00400020] ori $2, $2, 1 X"3c010000", -- [0x00400024] lui $1, 0 X"34210004", -- [0x00400028] ori $1, $1, 4 X"00220822", -- [0x0040002c] sub $1, $1, $2 X"1c20fffe", -- [0x00400030] bgtz $1 -8 [loop2-0x00400030] X"3c1f0040", -- [0x00400034] lui $31, 64 X"03e00008", -- [0x00400038] jr $31 X"00000000", -- [0x0040003c] nop X"00000000", -- [0x00400040] nop X"00000000", -- [0x00400044] nop X"00000000", -- [0x00400048] nop X"00000000", -- [0x0040004c] nop X"00000000", -- [0x00400050] nop X"00000000", -- [0x00400054] nop X"00000000", -- [0x00400058] nop X"00000000", -- [0x0040005c] nop X"00000000", -- [0x00400060] nop X"00000000", -- [0x00400064] nop X"00000000", -- [0x00400068] nop X"00000000", -- [0x0040006c] nop X"00000000", -- [0x00400070] nop X"00000000", -- [0x00400074] nop X"00000000", -- [0x00400078] nop X"00000000", -- [0x0040007c] nop X"00000000", -- [0x00400080] nop X"00000000", -- [0x00400084] nop X"00000000", -- [0x00400088] nop X"00000000", -- [0x0040008c] nop X"00000000", -- [0x00400090] nop X"00000000", -- [0x00400094] nop X"00000000", -- [0x00400098] nop X"00000000", -- [0x0040009c] nop X"00000000", -- [0x004000a0] nop X"00000000", -- [0x004000a4] nop X"00000000", -- [0x004000a8] nop X"00000000", -- [0x004000ac] nop X"00000000", -- [0x004000b0] nop X"00000000", -- [0x004000b4] nop X"00000000", -- [0x004000b8] nop X"00000000", -- [0x004000bc] nop X"00000000", -- [0x004000c0] nop X"00000000", -- [0x004000c4] nop X"00000000", -- [0x004000c8] nop X"00000000", -- [0x004000cc] nop X"00000000", -- [0x004000d0] nop X"00000000", -- [0x004000d4] nop X"00000000", -- [0x004000d8] nop X"00000000", -- [0x004000dc] nop X"00000000", -- [0x004000e0] nop X"00000000", -- [0x004000e4] nop X"00000000", -- [0x004000e8] nop X"00000000", -- [0x004000ec] nop X"00000000", -- [0x004000f0] nop X"00000000", -- [0x004000f4] nop X"00000000", -- [0x004000f8] nop X"00000000" -- [0x004000fc] nop ); begin PROM_READ: dout <= word_array(to_integer(addr)); end itest;