hp-saturn/hp48_rom.v

67 lines
1 KiB
Coq
Raw Normal View History

`include "bus_commands.v"
`ifndef _HP48_ROM
`define _HP48_ROM
/**************************************************************************************************
*
* Rom module
* accesses the calculators firmware
*
*
*/
module hp48_rom (
2019-02-07 22:54:06 +01:00
input strobe,
input [19:0] address,
input [3:0] command,
output reg [3:0] nibble_out
);
localparam ROM_FILENAME = "rom-gx-r.hex";
//
// This is only for debug, the rom should be stored elsewhere
//
`ifdef SIM
reg [3:0] rom [0:(2**20)-1];
`else
reg[3:0] rom [0:(2**16)-1];
`endif
2019-02-07 22:54:06 +01:00
reg [3:0] i_cmd;
reg [19:0] pc_ptr;
reg [19:0] data_ptr;
initial
begin
$readmemh( ROM_FILENAME, rom);
end
/**************************************
*
*
*
*/
2019-02-07 22:54:06 +01:00
always @(posedge strobe) begin
2019-02-07 08:55:41 +01:00
case (command)
2019-02-07 22:54:06 +01:00
`BUSCMD_LOAD_PC: begin
// $display("ROM - LOAD_PC %5h", address);
2019-02-07 22:54:06 +01:00
pc_ptr <= address;
i_cmd <= `BUSCMD_PC_READ;
end
`BUSCMD_PC_READ: begin
// $display("ROM PC_READ %5h -> %h", pc_ptr, rom[pc_ptr]);
2019-02-07 22:54:06 +01:00
nibble_out <= rom[pc_ptr];
pc_ptr <= pc_ptr + 1;
i_cmd <= command;
end
2019-02-07 08:55:41 +01:00
endcase
2019-02-07 22:54:06 +01:00
end
endmodule
`endif