2021-10-29 10:04:59 +00:00
|
|
|
module IOBM(
|
|
|
|
/* PDS interface */
|
2023-03-26 08:33:59 +00:00
|
|
|
input C16M, input C8M, input E,
|
2024-10-03 15:48:59 +00:00
|
|
|
output reg nAS, output reg RnW, output reg nLDS, output reg nUDS, output reg nVMA,
|
2023-03-25 07:49:44 +00:00
|
|
|
input nDTACK, input nVPA, input nBERR, input nRES,
|
2021-10-29 10:04:59 +00:00
|
|
|
/* PDS address and data latch control */
|
2023-03-20 04:53:10 +00:00
|
|
|
input AoutOE, output nDoutOE, output reg ALE0, output reg nDinLE,
|
2021-10-29 10:04:59 +00:00
|
|
|
/* IO bus slave port interface */
|
2024-10-03 15:48:59 +00:00
|
|
|
input IOREQ, input IORW, input IOLDS, input IOUDS,
|
2024-10-07 05:37:58 +00:00
|
|
|
output reg IOACT, output IODONE);
|
2021-10-29 10:04:59 +00:00
|
|
|
|
2023-04-07 03:11:11 +00:00
|
|
|
/* C8M clock registration */
|
|
|
|
reg C8Mr; always @(posedge C16M) C8Mr <= C8M;
|
|
|
|
|
|
|
|
/* I/O request input synchronization */
|
2024-10-03 15:48:59 +00:00
|
|
|
reg IOREQr; always @(posedge C16M) IOREQr <= IOREQ;
|
2023-04-07 03:11:11 +00:00
|
|
|
|
2023-04-07 04:41:16 +00:00
|
|
|
/* VPA synchronization */
|
|
|
|
reg VPAr; always @(negedge C8M) VPAr <= !nVPA;
|
2023-04-01 08:46:47 +00:00
|
|
|
|
2023-03-26 08:33:59 +00:00
|
|
|
/* E clock synchronization */
|
2023-04-07 04:41:16 +00:00
|
|
|
reg Er; always @(negedge C8M) begin Er <= E; end
|
2023-03-26 08:33:59 +00:00
|
|
|
|
2021-10-29 10:04:59 +00:00
|
|
|
/* E clock state */
|
2023-04-07 04:41:16 +00:00
|
|
|
reg [3:0] ES;
|
|
|
|
always @(negedge C8M) begin
|
|
|
|
if (!E && Er) ES <= 1;
|
|
|
|
else if (ES==0 || ES==9) ES <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
else ES <= ES+1;
|
|
|
|
end
|
|
|
|
|
|
|
|
/* ETACK and VMA generation */
|
2023-04-07 04:41:16 +00:00
|
|
|
wire ETACK = (ES==8) && !nVMA;
|
2024-10-07 10:09:02 +00:00
|
|
|
always @(negedge C8M) begin
|
|
|
|
if ((ES==3) && IOACT && VPAr) nVMA <= 0;
|
2024-10-07 05:35:42 +00:00
|
|
|
else if (ES==0) nVMA <= 1;
|
2023-04-07 04:41:16 +00:00
|
|
|
end
|
|
|
|
|
2021-10-29 10:04:59 +00:00
|
|
|
/* I/O bus state */
|
|
|
|
reg [2:0] IOS = 0;
|
2023-04-07 03:11:11 +00:00
|
|
|
reg IOS0;
|
2024-10-07 10:09:25 +00:00
|
|
|
|
2024-10-08 11:20:01 +00:00
|
|
|
/* IODONE DTACK/"ETACK"/BERR/reset synchronization */
|
2024-10-07 05:37:58 +00:00
|
|
|
reg IODONEr;
|
2024-10-07 10:09:25 +00:00
|
|
|
always @(posedge C16M) begin
|
|
|
|
if ((IOS==3 || IOS==5) && !C8Mr) begin
|
|
|
|
IODONEr <= !nDTACK || ETACK || !nBERR || !nRES;
|
|
|
|
end else if (IOS==0) IODONEr <= 0;
|
2024-10-07 05:37:58 +00:00
|
|
|
end
|
|
|
|
|
2024-10-08 11:20:01 +00:00
|
|
|
/* IODONE output */
|
2024-10-07 10:09:25 +00:00
|
|
|
assign IODONE = IODONEr;
|
2024-10-07 05:37:58 +00:00
|
|
|
|
2024-10-07 05:35:42 +00:00
|
|
|
/* I/O bus control */
|
2024-10-03 15:48:59 +00:00
|
|
|
always @(posedge C16M) case (IOS[2:0])
|
|
|
|
3'h0: begin
|
2023-04-07 03:11:11 +00:00
|
|
|
if (IOREQr && !C8Mr && AoutOE) begin // "IOS1"
|
|
|
|
IOS <= 2;
|
|
|
|
IOS0 <= 0;
|
|
|
|
end else begin // "regular" IOS0
|
|
|
|
IOS <= 0;
|
|
|
|
IOS0 <= 1;
|
|
|
|
end
|
2024-10-03 15:48:59 +00:00
|
|
|
IOACT <= IOREQr;
|
|
|
|
ALE0 <= IOREQr;
|
|
|
|
end 3'h2: begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 3;
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
IOACT <= 1;
|
|
|
|
ALE0 <= 1;
|
2024-10-03 15:48:59 +00:00
|
|
|
end 3'h3: begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 4;
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
IOACT <= 1;
|
|
|
|
ALE0 <= 1;
|
2024-10-03 15:48:59 +00:00
|
|
|
end 3'h4: begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 5;
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 0;
|
|
|
|
IOACT <= 1;
|
2021-10-29 10:04:59 +00:00
|
|
|
ALE0 <= 1;
|
2024-10-03 15:48:59 +00:00
|
|
|
end 3'h5: begin
|
2024-10-07 05:37:58 +00:00
|
|
|
if (!C8Mr && IODONEr) begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 6;
|
|
|
|
IOACT <= 0;
|
|
|
|
end else begin
|
|
|
|
IOS <= 5;
|
|
|
|
IOACT <= 1;
|
|
|
|
end
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
ALE0 <= 1;
|
2024-10-03 15:48:59 +00:00
|
|
|
end 3'h6: begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 7;
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
IOACT <= 0;
|
|
|
|
ALE0 <= 0;
|
2024-10-03 15:48:59 +00:00
|
|
|
end 3'h7: begin
|
2021-10-29 10:04:59 +00:00
|
|
|
IOS <= 0;
|
2023-04-07 03:11:11 +00:00
|
|
|
IOS0 <= 1;
|
2021-10-29 10:04:59 +00:00
|
|
|
IOACT <= 0;
|
|
|
|
ALE0 <= 0;
|
|
|
|
end
|
2024-10-03 15:48:59 +00:00
|
|
|
endcase
|
2021-10-29 10:04:59 +00:00
|
|
|
|
|
|
|
/* PDS address and data latch control */
|
2023-03-20 05:13:11 +00:00
|
|
|
always @(negedge C16M) begin nDinLE = IOS==4 || IOS==5; end
|
2023-04-07 03:11:11 +00:00
|
|
|
reg DoutOE = 0;
|
2021-10-29 10:04:59 +00:00
|
|
|
always @(posedge C16M) begin
|
2024-10-08 11:20:23 +00:00
|
|
|
DoutOE <= ((IOS==0 && IOREQr && !IORW && !C8Mr) ||
|
|
|
|
(DoutOE && (IOS==2 || IOS==3 || IOS==4 || IOS==5)));
|
2021-10-29 10:04:59 +00:00
|
|
|
end
|
2024-10-08 11:21:01 +00:00
|
|
|
//assign nDoutOE = !(AoutOE && (DoutOE || (IOS0 && !IOREQr)));
|
|
|
|
assign nDoutOE = !(AoutOE && DoutOE);
|
2021-10-29 10:04:59 +00:00
|
|
|
|
2024-10-03 15:48:59 +00:00
|
|
|
/* AS, DS, RW control */
|
2021-10-29 10:04:59 +00:00
|
|
|
always @(negedge C16M) begin
|
2024-10-03 15:48:59 +00:00
|
|
|
nAS <= !(
|
|
|
|
(IOS==0 && IOREQr && !C8Mr) ||
|
|
|
|
(IOS==2) ||
|
|
|
|
(IOS==3) ||
|
|
|
|
(IOS==4) ||
|
|
|
|
(IOS==5));
|
|
|
|
RnW <= !(
|
|
|
|
(IOS==0 && IOREQr && !IORW && !C8Mr) ||
|
|
|
|
(!IORW && IOS==2) ||
|
|
|
|
(!IORW && IOS==3) ||
|
|
|
|
(!IORW && IOS==4) ||
|
|
|
|
(!IORW && IOS==5) ||
|
|
|
|
(!IORW && IOS==6));
|
|
|
|
nLDS <= !(
|
|
|
|
(IOS==0 && IOREQr && IORW && IOLDS && !C8Mr) ||
|
|
|
|
(IOS==2 && IOLDS) ||
|
|
|
|
(IOS==3 && IOLDS) ||
|
|
|
|
(IOS==4 && IOLDS) ||
|
|
|
|
(IOS==5 && IOLDS));
|
|
|
|
nUDS <= !(
|
|
|
|
(IOS==0 && IOREQr && IORW && IOUDS && !C8Mr) ||
|
|
|
|
(IOS==2 && IOUDS) ||
|
|
|
|
(IOS==3 && IOUDS) ||
|
|
|
|
(IOS==4 && IOUDS) ||
|
|
|
|
(IOS==5 && IOUDS));
|
2021-10-29 10:04:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|