Warp-SE/cpld/FSB.v

55 lines
1.2 KiB
Coq
Raw Permalink Normal View History

2021-10-29 10:04:59 +00:00
module FSB(
2022-04-05 22:00:27 +00:00
input CLK, input [1:0] SS,
2021-10-29 10:04:59 +00:00
/* MC68HC000 interface */
input FCLK, input nAS, output reg nDTACK, output nVPA, output nBERR,
/* AS cycle detection */
2022-04-05 22:00:27 +00:00
output reg BACT,
2021-10-29 10:04:59 +00:00
/* Ready inputs */
2022-04-05 22:00:27 +00:00
input Ready0, input Ready1, input Disable,
2021-10-29 10:04:59 +00:00
/* BERR inputs */
input BERR0, input BERR1,
/* Interrupt acknowledge select */
input IACS);
/* AS cycle detection */
2022-04-05 22:00:27 +00:00
always @(posedge FCLK) begin
if (SS[1:0]==2'h1 && ~nAS) BACT <= 1;
else if (SS[1:0]==2'h3 && nAS) BACT <= 0;
end
2021-10-29 10:04:59 +00:00
/* Ready and BERR "remember" */
2022-04-05 22:00:27 +00:00
reg Ready0r, Ready1r;
2021-10-29 10:04:59 +00:00
reg BERR0r, BERR1r;
2022-03-28 03:45:53 +00:00
wire Ready = ~Disable && (Ready0 || Ready0r) &&
2022-04-05 22:00:27 +00:00
(Ready1 || Ready1r);
2021-10-29 10:04:59 +00:00
wire BERR = (BERR0 || BERR0r || BERR1 || BERR1r);
assign nBERR = ~(~nAS && BERR);
always @(posedge FCLK) begin
if (~BACT) begin
Ready0r <= 0;
Ready1r <= 0;
BERR0r <= 0;
BERR1r <= 0;
end else begin
if (Ready0) Ready0r <= 1;
if (Ready1) Ready1r <= 1;
if (BERR0) BERR0r <= 1;
if (BERR1) BERR1r <= 1;
end
end
/* DTACK/VPA control */
reg VPA;
assign nVPA = ~(~nAS && VPA);
always @(posedge FCLK) begin
if (~BACT) begin
nDTACK <= 1;
VPA <= 0;
end else if (Ready && ~BERR) begin
nDTACK <= IACS;
VPA <= IACS;
end
end
endmodule