90 lines
2.6 KiB
VHDL
90 lines
2.6 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;
|
|
|
|
library work;
|
|
use work.cpu_pkg.all;
|
|
|
|
-- JASM_ROM_INSERT_HERE
|
|
ENTITY irom IS
|
|
Port (
|
|
clk : in STD_LOGIC;
|
|
ce : in STD_LOGIC;
|
|
addr : in inst_addr_t;
|
|
dout : out inst_t
|
|
);
|
|
END irom;
|
|
|
|
ARCHITECTURE reti_issue OF irom IS
|
|
|
|
type imem_rom_t is array (0 to 27) of inst_t;
|
|
|
|
-- Assembled from reti_issue.jsm
|
|
constant imem_rom : imem_rom_t :=
|
|
(
|
|
"110000" & X"002", -- 0x000: JMP 0x002
|
|
"111111" & X"000", -- 0x001: RETI
|
|
"000011" & X"050", -- 0x002: MOV R00, 0x05
|
|
"100110" & X"030", -- 0x003: COUT (0x03), R00
|
|
"000011" & X"000", -- 0x004: MOV R00, 0x00
|
|
"000000" & X"000", -- 0x005: NOP
|
|
"010001" & X"010", -- 0x006: INC R00
|
|
"000000" & X"000", -- 0x007: NOP
|
|
"111011" & X"01B", -- 0x008: CALL 0x01B
|
|
"000000" & X"000", -- 0x009: NOP
|
|
"111100" & X"003", -- 0x00A: PUSH R03
|
|
"000000" & X"000", -- 0x00B: NOP
|
|
"111100" & X"002", -- 0x00C: PUSH R02
|
|
"000000" & X"000", -- 0x00D: NOP
|
|
"111100" & X"001", -- 0x00E: PUSH R01
|
|
"000000" & X"000", -- 0x00F: NOP
|
|
"111100" & X"000", -- 0x010: PUSH R00
|
|
"000000" & X"000", -- 0x011: NOP
|
|
"111101" & X"000", -- 0x012: POP R00
|
|
"000000" & X"000", -- 0x013: NOP
|
|
"111101" & X"001", -- 0x014: POP R01
|
|
"000000" & X"000", -- 0x015: NOP
|
|
"111101" & X"002", -- 0x016: POP R02
|
|
"000000" & X"000", -- 0x017: NOP
|
|
"111101" & X"003", -- 0x018: POP R03
|
|
"000000" & X"000", -- 0x019: NOP
|
|
"110000" & X"005", -- 0x01A: JMP 0x005
|
|
"111110" & X"000" -- 0x01B: RET
|
|
);
|
|
|
|
begin
|
|
|
|
PROM_READ:
|
|
process(clk, ce)
|
|
begin
|
|
if rising_edge(clk) and ce = '1' then
|
|
dout <= imem_rom(to_integer(addr));
|
|
end if;
|
|
end process;
|
|
|
|
end reti_issue;
|
|
|