summaryrefslogtreecommitdiff
path: root/rtl/uncore/clkgen.sv
blob: 9390e5365f693333e526e4429ec05a6bc88353a7 (plain)
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
//
// Copyright (c) 2026, Apollo Telephone Laboratories.
// Provided under the BSD-3 clause.
//

//
// Uncore clock generator
//
// @refclk_i:       Reference clock input from on-board VCO
// @reset_ni:       Active-low reset input
// @clk_en_i:       Active-high clock enable input
// @dclk_o:         Derieved clock output
// @gclk_o:         Gated global clock output
// @pll_locked_o:   PLL locked indicator output
//
module clkgen (
    input wire refclk_i,
    input wire reset_ni,
    input wire clk_en_i,

    output logic dclk_o,
    output logic gclk_o,
    output logic pll_locked_o
);
    logic clk_en;
    logic dclk;

    // TODO: Handle real silicon
`ifdef _SIM
    assign dclk = refclk_i;
    assign pll_locked_o = 1;
`else
    gpll pll (
        .reset(~reset_ni),
        .clk_in1(refclk_i),
        .clk_out1(dclk),
        .locked(pll_locked_o)
    );
`endif

    // ICG cell
    always_latch begin
        if (!dclk) begin
            clk_en = clk_en_i;
        end
    end

    assign gclk_o = dclk & clk_en;
    assign dclk_o = dclk;
endmodule