mirror of
https://github.com/garrettsworkshop/Warp-SE.git
synced 2025-01-08 17:29:52 +00:00
PDS bridge refactor
This commit is contained in:
parent
d557f9e502
commit
8767a92544
66
cpld/IOBM.v
66
cpld/IOBM.v
@ -1,21 +1,19 @@
|
||||
module IOBM(
|
||||
/* PDS interface */
|
||||
input C16M, input C8M, input E,
|
||||
output reg nASout, output reg nLDS, output reg nUDS, output reg nVMA,
|
||||
output reg nAS, output reg RnW, output reg nLDS, output reg nUDS, output reg nVMA,
|
||||
input nDTACK, input nVPA, input nBERR, input nRES,
|
||||
/* PDS address and data latch control */
|
||||
input AoutOE, output nDoutOE, output reg ALE0, output reg nDinLE,
|
||||
/* IO bus slave port interface */
|
||||
input IORDREQ, input IOWRREQ, input IOLDS, input IOUDS,
|
||||
input IOREQ, input IORW, input IOLDS, input IOUDS,
|
||||
output reg IOACT, output reg IODONE, output reg IOBERR);
|
||||
|
||||
/* C8M clock registration */
|
||||
reg C8Mr; always @(posedge C16M) C8Mr <= C8M;
|
||||
|
||||
/* I/O request input synchronization */
|
||||
reg IORDREQr; always @(posedge C16M) IORDREQr <= IORDREQ;
|
||||
reg IOWRREQr; always @(posedge C16M) IOWRREQr <= IOWRREQ;
|
||||
wire IOREQr = IORDREQr || IOWRREQr;
|
||||
reg IOREQr; always @(posedge C16M) IOREQr <= IOREQ;
|
||||
|
||||
/* VPA synchronization */
|
||||
reg VPAr; always @(negedge C8M) VPAr <= !nVPA;
|
||||
@ -39,8 +37,8 @@ module IOBM(
|
||||
end
|
||||
|
||||
/* DTACK and BERR synchronization */
|
||||
always @(negedge C8M, posedge nASout) begin
|
||||
if (nASout) begin
|
||||
always @(negedge C8M, posedge nAS) begin
|
||||
if (nAS) begin
|
||||
IODONE <= 0;
|
||||
IOBERR <= 0;
|
||||
end else begin
|
||||
@ -52,8 +50,8 @@ module IOBM(
|
||||
/* I/O bus state */
|
||||
reg [2:0] IOS = 0;
|
||||
reg IOS0;
|
||||
always @(posedge C16M) begin
|
||||
if (IOS==0) begin
|
||||
always @(posedge C16M) case (IOS[2:0])
|
||||
3'h0: begin
|
||||
if (IOREQr && !C8Mr && AoutOE) begin // "IOS1"
|
||||
IOS <= 2;
|
||||
IOS0 <= 0;
|
||||
@ -61,24 +59,24 @@ module IOBM(
|
||||
IOS <= 0;
|
||||
IOS0 <= 1;
|
||||
end
|
||||
IOACT <= IOREQr && AoutOE;
|
||||
ALE0 <= IOREQr && AoutOE;
|
||||
end else if (IOS==2) begin
|
||||
IOACT <= IOREQr;
|
||||
ALE0 <= IOREQr;
|
||||
end 3'h2: begin
|
||||
IOS <= 3;
|
||||
IOS0 <= 0;
|
||||
IOACT <= 1;
|
||||
ALE0 <= 1;
|
||||
end else if (IOS==3) begin
|
||||
end 3'h3: begin
|
||||
IOS <= 4;
|
||||
IOS0 <= 0;
|
||||
IOACT <= 1;
|
||||
ALE0 <= 1;
|
||||
end else if (IOS==4) begin
|
||||
end 3'h4: begin
|
||||
IOS <= 5;
|
||||
IOS0 <= 0;
|
||||
IOACT <= 1;
|
||||
ALE0 <= 1;
|
||||
end else if (IOS==5) begin
|
||||
end 3'h5: begin
|
||||
if (!C8Mr && (IODONE || IOBERR)) begin
|
||||
IOS <= 6;
|
||||
IOACT <= 0;
|
||||
@ -88,33 +86,55 @@ module IOBM(
|
||||
end
|
||||
IOS0 <= 0;
|
||||
ALE0 <= 1;
|
||||
end else if (IOS==6) begin
|
||||
end 3'h6: begin
|
||||
IOS <= 7;
|
||||
IOS0 <= 0;
|
||||
IOACT <= 0;
|
||||
ALE0 <= 0;
|
||||
end else if (IOS==7) begin
|
||||
end 3'h7: begin
|
||||
IOS <= 0;
|
||||
IOS0 <= 1;
|
||||
IOACT <= 0;
|
||||
ALE0 <= 0;
|
||||
end
|
||||
end
|
||||
endcase
|
||||
|
||||
/* PDS address and data latch control */
|
||||
always @(negedge C16M) begin nDinLE = IOS==4 || IOS==5; end
|
||||
reg DoutOE = 0;
|
||||
always @(posedge C16M) begin
|
||||
DoutOE <= (IOS==0 && IOWRREQr && !C8Mr) ||
|
||||
DoutOE <= (IOS==0 && IOREQr && !IORW && !C8Mr) ||
|
||||
(DoutOE && (IOS==2 || IOS==3 || IOS==4 || IOS==5));
|
||||
end
|
||||
assign nDoutOE = !(AoutOE && (DoutOE || (IOS0 && !IOREQr)));
|
||||
|
||||
/* AS, DS control */
|
||||
/* AS, DS, RW control */
|
||||
always @(negedge C16M) begin
|
||||
nASout <= !((IOS==0 && IOREQr && !C8Mr) || IOS==2 || IOS==3 || IOS==4 || IOS==5);
|
||||
nLDS <= !(IOLDS && ((IOS==0 && IORDREQr && !C8Mr) || (IOS==2 && !nLDS) || IOS==3 || IOS==4 || IOS==5));
|
||||
nUDS <= !(IOUDS && ((IOS==0 && IORDREQr && !C8Mr) || (IOS==2 && !nUDS) || IOS==3 || IOS==4 || IOS==5));
|
||||
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));
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
49
cpld/IOBS.v
49
cpld/IOBS.v
@ -10,7 +10,7 @@ module IOBS(
|
||||
/* Read data OE control */
|
||||
output nDinOE,
|
||||
/* IOB master controller interface */
|
||||
output reg IORDREQ, output reg IOWRREQ,
|
||||
output reg IOREQ, output reg IORW,
|
||||
input IOACT, input IODONEin, input IOBERR,
|
||||
/* FIFO primary level control */
|
||||
output reg ALE0, output reg IOL0, output reg IOU0,
|
||||
@ -70,30 +70,32 @@ module IOBS(
|
||||
/* FIFO primary level control */
|
||||
always @(posedge CLK) begin
|
||||
if (TS==0) begin
|
||||
if (ALE1) begin // If FIFO secondary level occupied
|
||||
// Request transfer from IOBM and latch R/W from FIFO
|
||||
// Start IOREQ if FIFO secondary level occupied or FSB request
|
||||
if (ALE1 || (BACT && IOCS && !ALE1 && !Sent)) begin
|
||||
// Request transfer from IOBM
|
||||
TS <= 3;
|
||||
IORDREQ <= IORW1;
|
||||
IOWRREQ <= !IORW1;
|
||||
IOL0 <= IOL1;
|
||||
IOU0 <= IOU1;
|
||||
end else if (BACT && IOCS && !ALE1 && !Sent) begin // FSB request
|
||||
// Request transfer from IOBM and latch R/W from FSB
|
||||
TS <= 3;
|
||||
IORDREQ <= nWE;
|
||||
IOWRREQ <= !nWE;
|
||||
IOL0 <= !nLDS;
|
||||
IOU0 <= !nUDS;
|
||||
IOREQ <= 1;
|
||||
end else begin // Otherwise stay in idle
|
||||
TS <= 0;
|
||||
IORDREQ <= 0;
|
||||
IOWRREQ <= 0;
|
||||
IOREQ <= 0;
|
||||
end
|
||||
// Latch R/W and data strobes from FIFO secondary or FSB
|
||||
if (ALE1) begin // If FIFO secondary level occupied
|
||||
IORW <= IORW1;
|
||||
IOL0 <= IOL1;
|
||||
IOU0 <= IOU1;
|
||||
end else begin // FSB request
|
||||
IORW <= nWE;
|
||||
IOL0 <= !nLDS;
|
||||
IOU0 <= !nUDS;
|
||||
end
|
||||
|
||||
ALE0 <= 0;
|
||||
end else if (TS==3) begin
|
||||
TS <= 2; // Always go to TS2. Keep IORDREQ/IOWRREQ active
|
||||
TS <= 2; // Always go to TS2
|
||||
IOREQ <= 1; // Keep IOREQ active
|
||||
ALE0 <= 1; // Latch address (and data)
|
||||
// Latch data strobes from FIFO or FSB as appropriate
|
||||
// Latch data strobes again from FIFO or FSB as appropriate
|
||||
if (ALE1) begin
|
||||
IOL0 <= IOL1;
|
||||
IOU0 <= IOU1;
|
||||
@ -105,16 +107,17 @@ module IOBS(
|
||||
// Wait for IOACT then withdraw IOREQ and enter TS1
|
||||
if (IOACTr) begin
|
||||
TS <= 1;
|
||||
IORDREQ <= 0;
|
||||
IOWRREQ <= 0;
|
||||
end else TS <= 2;
|
||||
IOREQ <= 0;
|
||||
end else begin
|
||||
TS <= 2;
|
||||
IOREQ <= 1;
|
||||
end
|
||||
ALE0 <= 1; // Keep address latched
|
||||
end else if (TS==1) begin
|
||||
// Wait for IOACT low (transfer over) before going back to idle
|
||||
if (!IOACTr) TS <= 0;
|
||||
else TS <= 1;
|
||||
IORDREQ <= 0;
|
||||
IOWRREQ <= 0;
|
||||
IOREQ <= 0;
|
||||
ALE0 <= 0; // Release addr latch since it's controlled by IOBM now
|
||||
end
|
||||
end
|
||||
|
@ -126,7 +126,7 @@ module WarpSE(
|
||||
.nROMWE(nROMWE));
|
||||
|
||||
wire IONPReady, IOPWReady;
|
||||
wire IORDREQ, IOWRREQ;
|
||||
wire IOREQ, IORW;
|
||||
wire IOL0, IOU0;
|
||||
wire ALE0S, ALE0M, ALE1;
|
||||
assign nADoutLE0 = ~(ALE0S || ALE0M);
|
||||
@ -152,8 +152,8 @@ module WarpSE(
|
||||
/* Read data OE control */
|
||||
.nDinOE(nDinOE),
|
||||
/* IOB Master Controller Interface */
|
||||
.IORDREQ(IORDREQ),
|
||||
.IOWRREQ(IOWRREQ),
|
||||
.IOREQ(IOREQ),
|
||||
.IORW(IORW),
|
||||
.IOACT(IOACT),
|
||||
.IODONEin(IODONE),
|
||||
.IOBERR(IOBERR),
|
||||
@ -166,8 +166,9 @@ module WarpSE(
|
||||
|
||||
wire AoutOE;
|
||||
assign nAoutOE = !AoutOE;
|
||||
wire nAS_IOBout, nLDS_IOBout, nUDS_IOBout, nVMA_IOBout;
|
||||
wire nAS_IOBout, RnW_IOBout, nLDS_IOBout, nUDS_IOBout, nVMA_IOBout;
|
||||
assign nAS_IOB = AoutOE ? nAS_IOBout : 1'bZ;
|
||||
assign RnW_IOB = AoutOE ? RnW_IOBout : 1'bZ;
|
||||
assign nLDS_IOB = AoutOE ? nLDS_IOBout : 1'bZ;
|
||||
assign nUDS_IOB = AoutOE ? nUDS_IOBout : 1'bZ;
|
||||
assign nVMA_IOB = AoutOE ? nVMA_IOBout : 1'bZ;
|
||||
@ -176,7 +177,8 @@ module WarpSE(
|
||||
.C16M(C16M),
|
||||
.C8M(C8M),
|
||||
.E(E),
|
||||
.nASout(nAS_IOBout),
|
||||
.nAS(nAS_IOBout),
|
||||
.RnW(RnW_IOBout),
|
||||
.nLDS(nLDS_IOBout),
|
||||
.nUDS(nUDS_IOBout),
|
||||
.nVMA(nVMA_IOBout),
|
||||
@ -190,8 +192,8 @@ module WarpSE(
|
||||
.ALE0(ALE0M),
|
||||
.nDinLE(nDinLE),
|
||||
/* IO bus slave port interface */
|
||||
.IORDREQ(IORDREQ),
|
||||
.IOWRREQ(IOWRREQ),
|
||||
.IOREQ(IOREQ),
|
||||
.IORW(IORW),
|
||||
.IOLDS(IOL0),
|
||||
.IOUDS(IOU0),
|
||||
.IOACT(IOACT),
|
||||
|
Loading…
Reference in New Issue
Block a user