------------------------------------------------------------------------- -- 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"0042782b", -- [0x00400028] sltu $15, $2, $2 X"0043782b", -- [0x0040002c] sltu $15, $2, $3 X"0044782b", -- [0x00400030] sltu $15, $2, $4 X"0045782b", -- [0x00400034] sltu $15, $2, $5 X"0062782b", -- [0x00400038] sltu $15, $3, $2 X"0063782b", -- [0x0040003c] sltu $15, $3, $3 X"0064782b", -- [0x00400040] sltu $15, $3, $4 X"0065782b", -- [0x00400044] sltu $15, $3, $5 X"0082782b", -- [0x00400048] sltu $15, $4, $2 X"0083782b", -- [0x0040004c] sltu $15, $4, $3 X"0084782b", -- [0x00400050] sltu $15, $4, $4 X"0085782b", -- [0x00400054] sltu $15, $4, $5 X"00a2782b", -- [0x00400058] sltu $15, $5, $2 X"00a3782b", -- [0x0040005c] sltu $15, $5, $3 X"00a4782b", -- [0x00400060] sltu $15, $5, $4 X"00a5782b", -- [0x00400064] sltu $15, $5, $5 X"00000000", -- [0x00400068] nop X"0042782a", -- [0x0040006c] slt $15, $2, $2 X"0043782a", -- [0x00400070] slt $15, $2, $3 X"0044782a", -- [0x00400074] slt $15, $2, $4 X"0045782a", -- [0x00400078] slt $15, $2, $5 X"0062782a", -- [0x0040007c] slt $15, $3, $2 X"0063782a", -- [0x00400080] slt $15, $3, $3 X"0064782a", -- [0x00400084] slt $15, $3, $4 X"0065782a", -- [0x00400088] slt $15, $3, $5 X"0082782a", -- [0x0040008c] slt $15, $4, $2 X"0083782a", -- [0x00400090] slt $15, $4, $3 X"0084782a", -- [0x00400094] slt $15, $4, $4 X"0085782a", -- [0x00400098] slt $15, $4, $5 X"00a2782a", -- [0x0040009c] slt $15, $5, $2 X"00a3782a", -- [0x004000a0] slt $15, $5, $3 X"00a4782a", -- [0x004000a4] slt $15, $5, $4 X"00a5782a", -- [0x004000a8] slt $15, $5, $5 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;