mirror of
https://github.com/garrettsworkshop/Warp-SE.git
synced 2024-06-12 17:34:08 +00:00
Compare commits
2 Commits
d4e0008854
...
443a159063
Author | SHA1 | Date | |
---|---|---|---|
|
443a159063 | ||
|
22c3dd55ac |
117
cpld/RAM.v
117
cpld/RAM.v
|
@ -1,6 +1,7 @@
|
||||||
module RAM(
|
module RAM(
|
||||||
/* MC68HC000 interface */
|
/* MC68HC000 interface */
|
||||||
input CLK, input [21:1] A, input nWE, input nAS, input nLDS, input nUDS,
|
input CLK, input [21:1] A, input nWE,
|
||||||
|
input nAS, input nLDS, input nUDS, input nDTACK,
|
||||||
/* AS cycle detection */
|
/* AS cycle detection */
|
||||||
input BACT,
|
input BACT,
|
||||||
/* Select and ready signals */
|
/* Select and ready signals */
|
||||||
|
@ -9,13 +10,16 @@ module RAM(
|
||||||
input RefReqIn, input RefUrgIn,
|
input RefReqIn, input RefUrgIn,
|
||||||
/* DRAM and NOR flash interface */
|
/* DRAM and NOR flash interface */
|
||||||
output [11:0] RA, output nRAS, output reg nCAS,
|
output [11:0] RA, output nRAS, output reg nCAS,
|
||||||
output nLWE, output nUWE, output nOE, output nROMCS, output nROMWE);
|
output nLWE, output nUWE, output reg nOE, output nROMCS, output nROMWE);
|
||||||
|
|
||||||
|
/* BACT and /DTACK registration */
|
||||||
|
reg BACTr; always @(posedge CLK) BACTr <= BACT;
|
||||||
|
reg DTACKr; always @(posedge CLK) DTACKr <= !nDTACK;
|
||||||
|
|
||||||
/* RAM control state */
|
/* RAM control state */
|
||||||
reg [3:0] RS = 0;
|
reg [2:0] RS = 0;
|
||||||
reg RASEN = 0;
|
reg RASEN = 0;
|
||||||
reg RASEL = 0;
|
reg RASEL = 0;
|
||||||
reg CAS = 0;
|
|
||||||
reg RASrr = 0;
|
reg RASrr = 0;
|
||||||
reg RASrf = 0;
|
reg RASrf = 0;
|
||||||
|
|
||||||
|
@ -23,20 +27,22 @@ module RAM(
|
||||||
reg RefDone; // Refresh done "remember"
|
reg RefDone; // Refresh done "remember"
|
||||||
always @(posedge CLK) begin
|
always @(posedge CLK) begin
|
||||||
if (!RefReqIn && !RefUrgIn) RefDone <= 0;
|
if (!RefReqIn && !RefUrgIn) RefDone <= 0;
|
||||||
else if (RS[3]) RefDone <= 1;
|
else if (RS[2]) RefDone <= 1;
|
||||||
end
|
end
|
||||||
wire RefReq = RefReqIn && !RefDone;
|
wire RefReq = RefReqIn && !RefDone;
|
||||||
wire RefUrg = RefUrgIn && !RefDone;
|
wire RefUrg = RefUrgIn && !RefDone;
|
||||||
|
|
||||||
/* RAM control signals */
|
/* RAM control signals */
|
||||||
assign nRAS = !((!nAS && RAMCS && RASEN) || RASrr || RASrf);
|
assign nRAS = !((!nAS && RAMCS && RASEN) || RASrr || RASrf);
|
||||||
assign nOE = !(!nAS && nWE); // Shared with ROM
|
|
||||||
assign nLWE = !(!nLDS && !nWE && RASEL);
|
assign nLWE = !(!nLDS && !nWE && RASEL);
|
||||||
assign nUWE = !(!nUDS && !nWE && RASEL);
|
assign nUWE = !(!nUDS && !nWE && RASEL);
|
||||||
|
|
||||||
/* ROM control signals */
|
/* ROM control signals */
|
||||||
assign nROMCS = !ROMCS;
|
assign nROMCS = !ROMCS;
|
||||||
assign nROMWE = !((!nAS && !nWE));
|
assign nROMWE = !(!nAS && !nWE);
|
||||||
|
|
||||||
|
/* Shared ROM and RAM /OE control */
|
||||||
|
always @(posedge CLK) nOE <= !(BACT && !nWE && !(BACTr && DTACKr));
|
||||||
|
|
||||||
/* RAM address mux (and ROM address on RA8) */
|
/* RAM address mux (and ROM address on RA8) */
|
||||||
// RA11 doesn't do anything so both should be identical.
|
// RA11 doesn't do anything so both should be identical.
|
||||||
|
@ -55,119 +61,114 @@ module RAM(
|
||||||
assign RA[01] = !RASEL ? A[10] : A[02];
|
assign RA[01] = !RASEL ? A[10] : A[02];
|
||||||
assign RA[00] = !RASEL ? A[09] : A[01];
|
assign RA[00] = !RASEL ? A[09] : A[01];
|
||||||
|
|
||||||
reg BACTr; always @(posedge CLK) BACTr <= BACT;
|
wire RS0toRef = (RefReq && BACT && !BACTr && !RAMCS0X) ||
|
||||||
|
(RefUrg && !RASEN) ||
|
||||||
|
(RefUrg && BACT && !RAMCS0X) ||
|
||||||
|
(RefUrg && !BACT);
|
||||||
|
|
||||||
always @(posedge CLK) begin
|
always @(posedge CLK) begin
|
||||||
case (RS[3:0])
|
case (RS[2:0])
|
||||||
0: begin
|
0: begin // Idle/ready
|
||||||
if (( BACT && !BACTr && !RAMCS0X && RefReq) ||
|
if (RS0toRef) begin // Go to refresh
|
||||||
(!BACT && RefUrg) ||
|
RS <= 4;
|
||||||
( BACT && RefUrg && !RAMCS0X) ||
|
|
||||||
(!RASEN)) begin
|
|
||||||
RS <= 8;
|
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 1;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end else if (BACT && RAMCS && RASEN) begin
|
end else if (BACT && RAMCS && RASEN) begin // Access RAM
|
||||||
RS <= 1;
|
RS <= 1;
|
||||||
RASEL <= 1;
|
RASEL <= 1;
|
||||||
CAS <= 1;
|
|
||||||
RASrr <= 1;
|
RASrr <= 1;
|
||||||
RASEN <= 1;
|
RASEN <= 1;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end else begin
|
end else begin // Stay in idle/ready
|
||||||
RS <= 0;
|
RS <= 0;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 1;
|
RASEN <= 1;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end
|
end
|
||||||
end 1: begin
|
end 1: begin // RAM access
|
||||||
RS <= 2;
|
RS <= 2;
|
||||||
RASEL <= 1;
|
RASEL <= 1;
|
||||||
CAS <= 1;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end 2: begin
|
end 2: begin // finish RAM access
|
||||||
|
if (DTACKr) begin // Cycle ending
|
||||||
RS <= 3;
|
RS <= 3;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end 3: begin
|
end else begin
|
||||||
if (BACT) begin
|
RS <= 2;
|
||||||
RS <= 3;
|
RASEL <= 1;
|
||||||
RASEL <= 0;
|
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end else if (RefUrg) begin
|
end
|
||||||
RS <= 8;
|
end 3: begin //AS cycle complete
|
||||||
|
if (RefUrg) begin // Refresh RAS
|
||||||
|
RS <= 4;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 1;
|
RASrr <= 1;
|
||||||
RASrr <= 0;
|
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end else begin
|
end else begin // Cycle ended so go abck to idle/ready
|
||||||
RS <= 0;
|
RS <= 0;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 1;
|
RASEN <= 1;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end
|
end
|
||||||
end 8: begin
|
end 4: begin // Refresh RAS I
|
||||||
RS <= 9;
|
RS <= 5;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 1;
|
|
||||||
RASrr <= 1;
|
RASrr <= 1;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end 9: begin
|
end 5: begin // Refresh RAS II
|
||||||
RS <= 10;
|
RS <= 6;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 1;
|
RASrr <= 1;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end 10: begin
|
end 6: begin // Refresh precharge I / II
|
||||||
RS <= 11;
|
if (RASrr) begin
|
||||||
|
RS <= 6;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end 11: begin
|
end else begin
|
||||||
RS <= 15;
|
RS <= 7;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 0;
|
RASEN <= 0;
|
||||||
RAMReady <= 0;
|
RAMReady <= 0;
|
||||||
end 15: begin
|
end
|
||||||
|
end 7: begin // Reenable RAM and go to idle/ready
|
||||||
RS <= 0;
|
RS <= 0;
|
||||||
RASEL <= 0;
|
RASEL <= 0;
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
|
||||||
RASEN <= 1;
|
|
||||||
RAMReady <= 1;
|
|
||||||
end default: begin
|
|
||||||
RS <= 0;
|
|
||||||
RASEL <= 0;
|
|
||||||
CAS <= 0;
|
|
||||||
RASrr <= 0;
|
RASrr <= 0;
|
||||||
RASEN <= 1;
|
RASEN <= 1;
|
||||||
RAMReady <= 1;
|
RAMReady <= 1;
|
||||||
end
|
end
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
always @(negedge CLK) RASrf <= RS==1;
|
always @(negedge CLK) begin
|
||||||
always @(negedge CLK) nCAS <= !CAS;
|
RASrf <= RS==1;
|
||||||
|
case (RS[2:0])
|
||||||
|
0: nCAS <= !RS0toRef;
|
||||||
|
1: nCAS <= 0;
|
||||||
|
2: nCAS <= DTACKr;
|
||||||
|
3: nCAS <= !RefUrg;
|
||||||
|
4: nCAS <= !RefUrg;
|
||||||
|
5: nCAS <= 1;
|
||||||
|
6: nCAS <= 1;
|
||||||
|
7: nCAS <= 1;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
@ -71,7 +71,8 @@ module WarpSE(
|
||||||
wire RAMReady;
|
wire RAMReady;
|
||||||
RAM ram(
|
RAM ram(
|
||||||
/* MC68HC000 interface */
|
/* MC68HC000 interface */
|
||||||
FCLK, A_FSB[21:1], nWE_FSB, nAS_FSB, nLDS_FSB, nUDS_FSB,
|
FCLK, A_FSB[21:1], nWE_FSB,
|
||||||
|
nAS_FSB, nLDS_FSB, nUDS_FSB, nDTACK_FSB,
|
||||||
/* AS cycle detection */
|
/* AS cycle detection */
|
||||||
BACT,
|
BACT,
|
||||||
/* Select and ready signals */
|
/* Select and ready signals */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user