Warp-SE/cpld/CNT.v

35 lines
801 B
Coq
Raw Normal View History

2021-10-29 10:04:59 +00:00
module CNT(
/* FSB clock and AS detection */
input FCLK, input CACT,
/* Refresh request */
output RefReq, output RefUrgent, input RefAck,
/* Timeout signals */
output reg TimeoutA, output reg TimeoutB);
/* Refresh counter */
reg [7:0] RefCnt = 0;
reg RefDone = 0;
assign RefReq = ~RefDone;
assign RefUrgent = RefCnt[7] && RefCnt[6] && RefCnt[5] && ~RefDone;
always @(posedge FCLK) begin
RefCnt <= RefCnt+1;
if (RefCnt==0) RefDone <= 0;
else if (RefAck) RefDone <= 1;
end
/* Timeout signals */
2022-01-16 15:56:37 +00:00
reg TimeoutBPre;
2021-10-29 10:04:59 +00:00
always @(posedge FCLK) begin
if (~CACT) begin
TimeoutA <= 0;
2022-01-16 15:56:37 +00:00
TimeoutBPre <= 0;
2021-10-29 10:04:59 +00:00
TimeoutB <= 0;
end else begin
2022-01-16 15:56:37 +00:00
if (RefCnt[6:0]==0) TimeoutA <= 1;
if (RefCnt==0) TimeoutBPre <= 1;
if (RefCnt==0 && TimeoutBPre) TimeoutB <= 1;
2021-10-29 10:04:59 +00:00
end
end
endmodule