2021-10-29 10:04:59 +00:00
|
|
|
module CS(
|
|
|
|
/* MC68HC000 interface */
|
|
|
|
input [23:08] A, input CLK, input nRES, input nWE,
|
|
|
|
/* AS cycle detection */
|
|
|
|
input BACT,
|
2024-09-22 12:13:18 +00:00
|
|
|
/* QoS enable input */
|
2024-10-03 09:51:10 +00:00
|
|
|
input QoSEN,
|
2021-10-29 10:04:59 +00:00
|
|
|
/* Device select outputs */
|
2024-10-03 09:51:10 +00:00
|
|
|
output IOCS, output IORealCS, output IOPWCS, output IACS,
|
2023-07-16 06:25:27 +00:00
|
|
|
output ROMCS, output ROMCS4X,
|
2024-10-03 09:51:10 +00:00
|
|
|
output RAMCS, output RAMCS0X, output QoSCS);
|
2021-10-29 10:04:59 +00:00
|
|
|
|
|
|
|
/* Overlay control */
|
2024-09-22 12:13:18 +00:00
|
|
|
reg Overlay;
|
2023-03-31 10:14:47 +00:00
|
|
|
always @(posedge CLK) begin
|
2024-09-22 12:13:18 +00:00
|
|
|
if (!BACT && !nRES) Overlay <= 1;
|
|
|
|
else if (BACT && ROMCS4X) Overlay <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
end
|
|
|
|
|
2024-09-22 12:13:18 +00:00
|
|
|
/* I/O select signals */
|
2024-10-03 09:51:10 +00:00
|
|
|
wire IACKCS = A[23:20]==4'hF;
|
2024-09-22 12:13:18 +00:00
|
|
|
wire VIACS = A[23:20]==4'hE;
|
|
|
|
wire IWMCS = A[23:20]==4'hD;
|
|
|
|
wire SCCCS = A[23:20]==4'hB || A[23:20]==4'h9;
|
|
|
|
wire SCSICS = A[23:20]==4'h5;
|
|
|
|
|
2023-04-07 03:11:11 +00:00
|
|
|
/* ROM select signals */
|
|
|
|
assign ROMCS4X = A[23:20]==4'h4;
|
2023-07-16 06:25:27 +00:00
|
|
|
assign ROMCS = Overlay || ROMCS4X;
|
2023-04-07 03:11:11 +00:00
|
|
|
|
|
|
|
/* RAM select signals */
|
|
|
|
assign RAMCS0X = A[23:22]==2'b00;
|
2023-04-07 06:33:04 +00:00
|
|
|
assign RAMCS = RAMCS0X && !Overlay;
|
2023-07-16 06:25:27 +00:00
|
|
|
wire VidRAMCSWR64k = A[23:16]==8'h3F && !nWE; // 3F0000-3FFFFF
|
2024-09-22 12:13:18 +00:00
|
|
|
wire VidRAMCSWR = VidRAMCSWR64k; //&& (
|
|
|
|
//A[15:12]==4'h2 || // 1792 bytes RAM, 2304 bytes video
|
|
|
|
//A[15:12]==4'h3 || // 4096 bytes video
|
|
|
|
//A[15:12]==4'h4 || // 4096 bytes video
|
|
|
|
//A[15:12]==4'h5 || // 4096 bytes video
|
|
|
|
//A[15:12]==4'h6 || // 4096 bytes video
|
|
|
|
//A[15:12]==4'h7 || // 3200 bytes video, 896 bytes RAM
|
|
|
|
//A[15:12]==4'hA || // 256 bytes RAM, 768 bytes sound, 768 bytes RAM, 2304 bytes video
|
|
|
|
//A[15:12]==4'hB || // 4096 bytes video
|
|
|
|
//A[15:12]==4'hC || // 4096 bytes video
|
|
|
|
//A[15:12]==4'hD || // 4096 bytes video
|
2024-09-24 05:11:57 +00:00
|
|
|
//A[15:12]==4'hE || // 4096 bytes video
|
2024-09-22 12:13:18 +00:00
|
|
|
//A[15:12]==4'hF); // 3200 bytes video, 128 bytes RAM (system error space), 768 bytes sound
|
2024-10-03 09:51:10 +00:00
|
|
|
wire SndRAMCSWR = VidRAMCSWR64k && (
|
2023-04-10 02:50:24 +00:00
|
|
|
((A[15:12]==4'hF) && (A[11:8]==4'hD || A[11:8]==4'hE || A[11:8]==4'hF)) ||
|
|
|
|
((A[15:12]==4'hA) && (A[11:8]==4'h1 || A[11:8]==4'h2 || A[11:8]==4'h3)));
|
2024-10-03 09:51:10 +00:00
|
|
|
assign QoSCS = IACKCS || VIACS || IWMCS || SCCCS || SCSICS || SndRAMCSWR;
|
2021-10-29 10:04:59 +00:00
|
|
|
|
|
|
|
/* Select signals - IOB domain */
|
2024-10-03 09:51:10 +00:00
|
|
|
assign IACS = A[23:20]==4'hF; // IACK
|
2024-09-22 12:13:18 +00:00
|
|
|
assign IORealCS =
|
|
|
|
A[23:20]==4'hF || // IACK
|
|
|
|
A[23:20]==4'hE || // VIA
|
|
|
|
A[23:20]==4'hD || // IWM
|
|
|
|
A[23:20]==4'hC || // empty / fast ROM
|
|
|
|
A[23:20]==4'hB || // SCC write
|
|
|
|
A[23:20]==4'hA || // empty
|
|
|
|
A[23:20]==4'h9 || // SCC read/reset
|
|
|
|
A[23:20]==4'h8 || // empty (expansion RAM)
|
|
|
|
A[23:20]==4'h7 || // empty (expansion RAM)
|
|
|
|
A[23:20]==4'h6 || // empty (expansion RAM)
|
|
|
|
A[23:20]==4'h5; // SCSI
|
2024-10-03 09:51:10 +00:00
|
|
|
assign IOCS = IORealCS || VidRAMCSWR || QoSEN;
|
|
|
|
assign IOPWCS = VidRAMCSWR64k && !QoSEN; // Posted write to video RAM only when QoS disabled
|
2021-10-29 10:04:59 +00:00
|
|
|
endmodule
|