Warp-SE/cpld/IOBM.v

109 lines
2.7 KiB
Coq
Raw Normal View History

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,
2022-09-04 01:32:05 +00:00
output reg nASout, 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 */
2023-04-01 08:46:47 +00:00
output reg IOACT,
2022-09-11 21:15:53 +00:00
input IOREQ, input IOLDS, input IOUDS, input IOWE);
2021-10-29 10:04:59 +00:00
/* I/O bus slave port input synchronization */
reg IOREQr = 0;
always @(negedge C16M) begin IOREQr <= IOREQ; end
/* DTACK, BERR, RESET synchronization */
2023-04-01 08:46:47 +00:00
reg DTACKrf, BERRrf, RESrf;
always @(negedge C8M) begin
2023-04-01 08:46:47 +00:00
DTACKrf <= !nDTACK;
BERRrf <= !nBERR;
RESrf <= !nRES;
2021-10-29 10:04:59 +00:00
end
2023-04-01 08:46:47 +00:00
/* VPA synchronization */
reg VPAr;
always @(negedge C16M) VPAr <= !nVPA;
2023-03-26 08:33:59 +00:00
/* E clock synchronization */
reg Er; always @(negedge C8M) begin Er <= E; end
reg Er2; always @(posedge C16M) begin Er2 <= Er; end
2021-10-29 10:04:59 +00:00
/* E clock state */
reg [4:0] ES;
always @(posedge C16M) begin
if (Er2 && ~Er) ES <= 1;
else if (ES==0 || ES==19) ES <= 0;
else ES <= ES+1;
end
/* ETACK and VMA generation */
reg ETACK = 0;
always @(posedge C16M) begin ETACK <= ES==16 && ~nVMA; end
always @(posedge C16M) begin
2023-04-01 08:46:47 +00:00
if (ES==7 && IOACT && VPAr) nVMA <= 0;
2021-10-29 10:04:59 +00:00
else if (ES==0) nVMA <= 1;
end
/* I/O bus state */
reg [2:0] IOS = 0;
always @(posedge C16M) begin
if (IOS==0) begin
2023-03-25 07:49:44 +00:00
if (~C8M && IOREQr && AoutOE) IOS <= 1;
2022-09-04 01:32:05 +00:00
else IOS <= 0;
IOACT <= IOREQr;
ALE0 <= IOREQr;
2021-10-29 10:04:59 +00:00
end else if (IOS==1) begin
IOS <= 2;
IOACT <= 1;
ALE0 <= 1;
end else if (IOS==2) begin
IOS <= 3;
IOACT <= 1;
ALE0 <= 1;
end else if (IOS==3) begin
IOS <= 4;
IOACT <= 1;
ALE0 <= 1;
end else if (IOS==4) begin
IOS <= 5;
ALE0 <= 1;
2023-04-01 08:46:47 +00:00
if (DTACKrf) IOACT <= 0;
else IOACT <= 1;
2021-10-29 10:04:59 +00:00
end else if (IOS==5) begin
2023-04-01 08:46:47 +00:00
if (C8M && (DTACKrf || ETACK || BERRrf || RESrf)) begin
2021-10-29 10:04:59 +00:00
IOS <= 6;
IOACT <= 0;
end else begin
IOS <= 5;
IOACT <= 1;
end
ALE0 <= 1;
end else if (IOS==6) begin
IOS <= 7;
IOACT <= 0;
ALE0 <= 0;
end else if (IOS==7) begin
IOS <= 0;
IOACT <= 0;
ALE0 <= 0;
end
end
/* PDS address and data latch control */
2023-03-20 05:13:11 +00:00
always @(negedge C16M) begin nDinLE = IOS==4 || IOS==5; end
reg DoutOE = 0; assign nDoutOE = !(AoutOE && DoutOE);
2021-10-29 10:04:59 +00:00
always @(posedge C16M) begin
2023-03-26 08:33:59 +00:00
DoutOE <= ( IOWE && (IOS==1 || IOS==2 || IOS==3 || IOS==4 || IOS==5 || IOS==6)) ||
(!IOREQr && IOS==0 && AoutOE);
2021-10-29 10:04:59 +00:00
end
/* AS, DS control */
always @(negedge C16M) begin
2022-03-28 03:45:53 +00:00
nASout <= ~(IOS==1 || IOS==2 || IOS==3 || IOS==4 || IOS==5);
2021-10-29 10:04:59 +00:00
nLDS <= ~(IOLDS && (((IOS==1 || IOS==2) && ~IOWE) || IOS==3 || IOS==4 || IOS==5));
nUDS <= ~(IOUDS && (((IOS==1 || IOS==2) && ~IOWE) || IOS==3 || IOS==4 || IOS==5));
end
endmodule