hp-saturn/attic/hp48_06_rom.v

68 lines
1.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
2019-02-10 12:04:53 +01:00
//reg[3:0] rom [0:(2**16)-1];
reg[3:0] rom [0:(2**12)-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
pc_ptr <= address;
i_cmd <= `BUSCMD_PC_READ;
2019-02-09 00:02:09 +01:00
// $display("ROM - LOAD_PC %5h", address);
2019-02-07 22:54:06 +01:00
end
`BUSCMD_PC_READ: begin
nibble_out <= rom[pc_ptr];
pc_ptr <= pc_ptr + 1;
i_cmd <= command;
2019-02-09 00:02:09 +01:00
// $display("ROM PC_READ %5h -> %h", pc_ptr, rom[pc_ptr]);
2019-02-07 22:54:06 +01:00
end
2019-02-07 08:55:41 +01:00
endcase
2019-02-07 22:54:06 +01:00
end
endmodule
`endif