summaryrefslogtreecommitdiff
path: root/python/openvino/demo/ip/intel_ai_ip/verilog/dla_platform_reset.sv
blob: 1f9e9eff2fb91c5ad3843478e80aaf71cd18b369 (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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright 2020-2020 Intel Corporation.
//
// This software and the related documents are Intel copyrighted materials,
// and your use of them is governed by the express license under which they
// were provided to you ("License"). Unless the License provides otherwise,
// you may not use, modify, copy, publish, distribute, disclose or transmit
// this software or the related documents without Intel's prior written
// permission.
//
// This software and the related documents are provided as is, with no express
// or implied warranties, other than those that are expressly stated in the
// License.



// This is top level reset module that is responsible for ensuring reset is held for a long time
// on each clock domain. All resets from each clock domain (which typically come from PLL locked,
// DDR calibrated, or an external pin) are combined asynchronously. The idea is that if any reset
// is asserted, everything goes into reset. After including all reset sources, for each clock domain
// this all-inclusive reset is synchronized to that clock domain and then pulse extended (to ensure
// reset is held for a long time). Finally, all the pulse extended resets are combined asynchronously.
// This commonize reset is distributed to all modules within the DLA IP, each module is responsible
// for synchronizing the reset before consumption.

`resetall
`undefineall
`default_nettype none

module dla_platform_reset #(
    parameter int RESET_HOLD_CLOCK_CYCLES,  //how many clock cycles to extend how long reset is held for
    parameter int MAX_DLA_INSTANCES,        //maximum number of DLA instances defined by the number of CSR and DDR interfaces provided by the BSP
    parameter int ENABLE_DDR=1,             //whether the DDR resets passed to this instance are valid, resets are ignored when disabled
    parameter int ENABLE_AXI=0              //Whether the AXI resets passed to this instance are valid, resets are ignored when disabled
) (
    //clocks
    input wire     clk_dla,
    input wire     clk_ddr       [MAX_DLA_INSTANCES],  //one ddr clock for each ddr bank
    input wire     clk_pcie,
    input wire     clk_axis      [MAX_DLA_INSTANCES],

    //resets from each clock domain, if you don't have a resetn signal then tie that inport port to 1'b1
    input wire     i_resetn_dla,
    input wire     i_resetn_ddr  [MAX_DLA_INSTANCES],  //one ddr reset for each ddr bank
    input wire     i_resetn_pcie,
    input wire     i_resetn_axis [MAX_DLA_INSTANCES],

    //after combining the resets from all clock domains, this output reset has been held for at RESET_HOLD_CLOCK_CYCLES on each clock domain
    //this reset is NOT synchronized to any clock, it is meant for distribution to the DLA IP
    //unfortunately inside a PR region one has no access to a global clock line, which would be ideal for distribution
    output logic    o_resetn_async
);

    //convert unpacked to packed
    logic [MAX_DLA_INSTANCES-1:0] resetn_ddr_reindex;
    logic [MAX_DLA_INSTANCES-1:0] resetn_axis_reindex;
    always_comb begin
        for (int i=0; i<MAX_DLA_INSTANCES; i++) begin
            resetn_ddr_reindex[i] = i_resetn_ddr[i];
            resetn_axis_reindex[i] = i_resetn_axis[i];
        end
    end

    logic resetn_ddr_combined, resetn_axi_combined, resetn_inputs_combined;
    logic resetn_pulse_extended_dla, resetn_pulse_extended_pcie;
    logic [MAX_DLA_INSTANCES-1:0] resetn_pulse_extended_ddr;
    logic [MAX_DLA_INSTANCES-1:0] resetn_pulse_extended_axis;

    assign resetn_inputs_combined = i_resetn_dla & i_resetn_pcie & resetn_ddr_combined & resetn_axi_combined;

    dla_platform_reset_internal #(
        .RESET_HOLD_CLOCK_CYCLES    (RESET_HOLD_CLOCK_CYCLES)
    )
    dla_resetn_inst
    (
        .clk                        (clk_dla),
        .i_resetn_combined          (resetn_inputs_combined),
        .o_resetn_pulse_extended    (resetn_pulse_extended_dla)
    );

    if (ENABLE_DDR) begin
        assign resetn_ddr_combined = &resetn_ddr_reindex;

        for (genvar g = 0; g < MAX_DLA_INSTANCES; g++) begin : GEN_DDR_RESET
            dla_platform_reset_internal #(
                .RESET_HOLD_CLOCK_CYCLES    (RESET_HOLD_CLOCK_CYCLES)
            )
            ddr_resetn_inst
            (
                .clk                        (clk_ddr[g]),
                .i_resetn_combined          (resetn_inputs_combined),
                .o_resetn_pulse_extended    (resetn_pulse_extended_ddr[g])
            );
        end
    end else begin
        assign resetn_ddr_combined = 1'b1;
        assign resetn_pulse_extended_ddr = '{default: 1'b1};
    end

    dla_platform_reset_internal #(
        .RESET_HOLD_CLOCK_CYCLES    (RESET_HOLD_CLOCK_CYCLES)
    )
    pcie_resetn_inst
    (
        .clk                        (clk_pcie),
        .i_resetn_combined          (resetn_inputs_combined),
        .o_resetn_pulse_extended    (resetn_pulse_extended_pcie)
    );

    if (ENABLE_AXI) begin
        assign resetn_axi_combined = &resetn_axis_reindex;

        for (genvar g = 0; g < MAX_DLA_INSTANCES; g++) begin: GEN_AXI_RESET
            dla_platform_reset_internal #(
                .RESET_HOLD_CLOCK_CYCLES    (RESET_HOLD_CLOCK_CYCLES)
            )
            axis_resetn_inst
            (
                .clk                        (clk_axis[g]),
                .i_resetn_combined          (resetn_inputs_combined),
                .o_resetn_pulse_extended    (resetn_pulse_extended_axis[g])
            );
        end
    end else begin
        assign resetn_axi_combined = 1'b1;
        assign resetn_pulse_extended_axis = '{default: 1'b1};
    end

    dla_cdc_reset_async recombine_resets
    (
      .clk            (clk_pcie),
      .i_async_resetn (
        resetn_pulse_extended_dla &
        (&resetn_pulse_extended_ddr) &
        resetn_pulse_extended_pcie &
        (&resetn_pulse_extended_axis)
      ),

      .o_async_resetn (o_resetn_async)
    );

endmodule