Warp-SE/cpld/FSB.v

64 lines
1.3 KiB
Coq
Raw Normal View History

2021-10-29 10:04:59 +00:00
module FSB(
/* MC68HC000 interface */
input FCLK, input nAS, output reg nDTACK, output nVPA, output nBERR,
/* AS cycle detection */
2023-03-20 04:53:10 +00:00
output BACT, output LBACT,
2021-10-29 10:04:59 +00:00
/* Ready inputs */
2022-09-04 01:32:05 +00:00
input Ready0, input Ready1, input Ready2,
2023-03-20 05:13:11 +00:00
/* BERR input from IOB slave port */
input IOBS_BERR,
2021-10-29 10:04:59 +00:00
/* Interrupt acknowledge select */
input IACS);
/* AS cycle detection */
reg ASrf = 0;
always @(negedge FCLK) begin ASrf <= ~nAS; end
2023-03-20 04:53:10 +00:00
assign BACT = ~nAS || ASrf; // BACT - bus active
/* LBACT - "Long BACT" */
reg [1:0] BACTCnt = 0;
always @(posedge FCLK) begin
if (!BACT) begin
BACTCnt <= 0;
LBACT <= 0;
end else begin
BACTCnt <= BACTCnt+1;
if (BACTCnt==2'b11 && BACT) LBACT <= 1;
end
end
2021-10-29 10:04:59 +00:00
2022-09-04 01:32:05 +00:00
/* Ready generation and bypass */
2021-10-29 10:04:59 +00:00
reg Ready0r, Ready1r, Ready2r;
2022-09-04 01:32:05 +00:00
wire Ready = (Ready0 || Ready0r) &&
(Ready1 || Ready1r) &&
(Ready2 || Ready2r);
2021-10-29 10:04:59 +00:00
always @(posedge FCLK) begin
if (~BACT) begin
Ready0r <= 0;
Ready1r <= 0;
Ready2r <= 0;
end else begin
if (Ready0) Ready0r <= 1;
if (Ready1) Ready1r <= 1;
if (Ready2) Ready2r <= 1;
end
end
2022-09-04 01:32:05 +00:00
/* BERR generation */
2023-03-20 05:13:11 +00:00
assign nBERR = ~(~nAS && IOBS_BERR);
2021-10-29 10:04:59 +00:00
/* DTACK/VPA control */
reg VPA;
assign nVPA = ~(~nAS && VPA);
always @(posedge FCLK) begin
if (~BACT) begin
nDTACK <= 1;
VPA <= 0;
2023-03-20 05:13:11 +00:00
end else if (Ready) begin
2021-10-29 10:04:59 +00:00
nDTACK <= IACS;
VPA <= IACS;
end
end
endmodule