-
Notifications
You must be signed in to change notification settings - Fork 3
/
BUFG_GT.v
109 lines (86 loc) · 2.24 KB
/
BUFG_GT.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
`ifdef verilator3
`else
`timescale 1 ps / 1 ps
`endif
//
// BUFG_GT primitive for Xilinx FPGAs
// Compatible with Verilator tool (www.veripool.org)
// Copyright (c) 2019-2022 Frédéric REQUIN
// License : BSD
//
/* verilator coverage_off */
module BUFG_GT
(
input I,
input [2:0] DIV,
input CE,
input CEMASK,
input CLR,
input CLRMASK,
output O /* verilator clocker */
);
reg [1:0] r_CE_cdc;
wire w_CE_msk;
reg r_CE_msk;
reg [1:0] r_CLR_cdc;
wire w_CLR_msk;
reg [2:0] r_clk_div;
/* verilator lint_off MULTIDRIVEN */
reg r_O;
/* verilator lint_on MULTIDRIVEN */
initial begin
r_CE_cdc = 2'b00;
r_CE_msk = 1'b0;
r_CLR_cdc = 2'b00;
r_clk_div = 3'd0;
end
always @(posedge I) begin
r_CE_cdc <= { r_CE_cdc[0], CE };
end
assign w_CE_msk = r_CE_cdc[1] | CEMASK;
always @(negedge I) begin
if (w_CLR_msk) begin
r_CE_msk <= 1'b0;
end
else begin
r_CE_msk <= w_CE_msk;
end
end
always @(posedge CLR or posedge I) begin
if (CLR) begin
r_CLR_cdc <= 2'b11;
end
else begin
r_CLR_cdc <= { r_CLR_cdc[0], 1'b0 };
end
end
assign w_CLR_msk = r_CLR_cdc[1] & ~CLRMASK;
always @(posedge I) begin
if (w_CLR_msk) begin
r_clk_div <= (DIV[2:1] == 2'b10) ? 3'd1 : 3'd0;
end
else if (r_CE_msk | O) begin
if (DIV[2:1] == 2'b10) begin
r_clk_div <= (r_clk_div == (DIV + 3'd1)) ? 3'd1 : r_clk_div + 3'd1;
end
else begin
r_clk_div <= (r_clk_div == DIV) ? 3'd0 : r_clk_div + 3'd1;
end
end
end
always @(posedge I) begin
casez (DIV)
3'b000 : r_O <= r_CE_msk;
3'b001 : r_O <= r_clk_div[0];
3'b01? : r_O <= r_clk_div[1];
3'b1?? : r_O <= r_clk_div[2];
endcase
end
always @(negedge I) begin
if (DIV == 3'b000) begin
r_O <= 1'b0;
end
end
assign O = r_O;
endmodule
/* verilator coverage_on */