hp-saturn/attic/hp48_00_bus.v

149 lines
2.6 KiB
Coq
Raw Normal View History

2019-02-09 09:32:29 +01:00
`define MMIO
`define SYSRAM
`include "bus_commands.v"
2019-02-09 09:32:29 +01:00
`ifdef MMIO
2019-02-09 00:02:09 +01:00
`include "hp48_01_io_ram.v"
2019-02-09 09:32:29 +01:00
`endif
`ifdef SYSRAM
2019-02-09 00:02:09 +01:00
`include "hp48_02_sys_ram.v"
2019-02-09 09:32:29 +01:00
`endif
2019-02-09 00:02:09 +01:00
`include "hp48_06_rom.v"
2019-02-09 09:32:29 +01:00
`ifndef _HP48_BUS
`define _HP48_BUS
/**************************************************************************************************
*
* Bus manager
*
*
*
*/
module hp48_bus (
2019-02-07 22:54:06 +01:00
input strobe,
input reset,
input [19:0] address,
input [3:0] command,
input [3:0] nibble_in,
2019-02-09 09:32:29 +01:00
output [3:0] nibble_out,
output bus_error
);
2019-02-09 00:02:09 +01:00
// mmio
2019-02-08 21:11:47 +01:00
wire [3:0] mmio_nibble_in;
wire [3:0] mmio_nibble_out;
wire mmio_active;
wire mmio_daisy_in;
wire mmio_daisy_out;
wire mmio_error;
2019-02-09 00:02:09 +01:00
// sysram
wire [3:0] sysram_nibble_in;
wire [3:0] sysram_nibble_out;
wire sysram_active;
wire sysram_daisy_in;
wire sysram_daisy_out;
wire sysram_error;
// rom
wire [3:0] rom_nibble_out;
2019-02-09 09:32:29 +01:00
`ifdef MMIO
//
// listed in order of priority
//
hp48_io_ram dev_io_ram (
2019-02-08 21:11:47 +01:00
.strobe (strobe),
.reset (reset),
.address (address),
.command (command),
2019-02-08 21:11:47 +01:00
.nibble_in (mmio_nibble_in),
.nibble_out (mmio_nibble_out),
.active (mmio_active),
.daisy_in (mmio_daisy_in),
.daisy_out (mmio_daisy_out),
.error (mmio_error)
);
2019-02-08 21:11:47 +01:00
assign mmio_nibble_in = nibble_in;
2019-02-09 00:02:09 +01:00
assign mmio_daisy_in = 1;
2019-02-09 09:32:29 +01:00
`else
assign mmio_error = 0;
assign mmio_active = 0;
assign mmio_nibble_out = 0;
assign mmio_error = 0;
`endif
`ifdef SYSRAM
2019-02-09 00:02:09 +01:00
hp48_sys_ram dev_sys_ram (
.strobe (strobe),
.reset (reset),
.address (address),
.command (command),
.nibble_in (sysram_nibble_in),
.nibble_out (sysram_nibble_out),
.active (sysram_active),
.daisy_in (sysram_daisy_in),
.daisy_out (sysram_daisy_out),
.error (sysram_error)
);
assign sysram_nibble_in = nibble_in;
assign sysram_daisy_in = mmio_daisy_out;
2019-02-09 09:32:29 +01:00
`else
assign sysram_active = 0;
assign sysram_nibble_out = 0;
assign sysram_error = 0;
`endif
2019-02-08 21:11:47 +01:00
hp48_rom dev_rom (
2019-02-08 21:11:47 +01:00
.strobe (strobe),
.address (address),
.command (command),
.nibble_out (rom_nibble_out)
);
2019-02-09 09:32:29 +01:00
assign bus_error = mmio_error | sysram_error;
wire show_mmio;
wire show_sysram;
wire show_rom;
assign show_mmio = mmio_active;
assign show_sysram = !mmio_active & sysram_active;
assign show_rom = !mmio_active & !sysram_active;
assign nibble_out = {4 {strobe}} & (
({4 {show_mmio}} & mmio_nibble_out) |
({4 {show_sysram}} & sysram_nibble_out) |
({4 {show_rom}} & rom_nibble_out));
// initial begin
// $monitor("BUS > STRB %b | MMIO %b %h | SYSRAM %b %h | ROM %b %h | IN %h | OUT %h",
// strobe,
// show_mmio, mmio_nibble_out,
// show_sysram, sysram_nibble_out,
// show_rom, rom_nibble_out,
// nibble_in, nibble_out);
// end
endmodule
`endif