OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

[/] [spacewiresystemc/] [trunk/] [altera_work/] [spw_fifo_ulight/] [ulight_fifo/] [synthesis/] [submodules/] [altera_reset_controller.v] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 redbear
// (C) 2001-2017 Intel Corporation. All rights reserved.
2
// Your use of Intel Corporation's design tools, logic functions and other 
3
// software and tools, and its AMPP partner logic functions, and any output 
4 40 redbear
// files from any of the foregoing (including device programming or simulation 
5 32 redbear
// files), and any associated documentation or information are expressly subject 
6
// to the terms and conditions of the Intel Program License Subscription 
7 40 redbear
// Agreement, Intel FPGA IP License Agreement, or other applicable 
8 32 redbear
// license agreement, including, without limitation, that your use is for the 
9
// sole purpose of programming logic devices manufactured by Intel and sold by 
10
// Intel or its authorized distributors.  Please refer to the applicable 
11
// agreement for further details.
12
 
13
 
14
// (C) 2001-2013 Altera Corporation. All rights reserved.
15
// Your use of Altera Corporation's design tools, logic functions and other 
16
// software and tools, and its AMPP partner logic functions, and any output 
17
// files any of the foregoing (including device programming or simulation 
18
// files), and any associated documentation or information are expressly subject 
19
// to the terms and conditions of the Altera Program License Subscription 
20
// Agreement, Altera MegaCore Function License Agreement, or other applicable 
21
// license agreement, including, without limitation, that your use is for the 
22
// sole purpose of programming logic devices manufactured by Altera and sold by 
23
// Altera or its authorized distributors.  Please refer to the applicable 
24
// agreement for further details.
25
 
26
 
27 40 redbear
// $Id: //acds/rel/17.1std/ip/merlin/altera_reset_controller/altera_reset_controller.v#1 $
28 32 redbear
// $Revision: #1 $
29 40 redbear
// $Date: 2017/07/30 $
30 32 redbear
// $Author: swbranch $
31
 
32
// --------------------------------------
33
// Reset controller
34
//
35
// Combines all the input resets and synchronizes
36
// the result to the clk.
37
// ACDS13.1 - Added reset request as part of reset sequencing
38
// --------------------------------------
39
 
40
`timescale 1 ns / 1 ns
41
 
42
module altera_reset_controller
43
#(
44
    parameter NUM_RESET_INPUTS              = 6,
45
    parameter USE_RESET_REQUEST_IN0 = 0,
46
    parameter USE_RESET_REQUEST_IN1 = 0,
47
    parameter USE_RESET_REQUEST_IN2 = 0,
48
    parameter USE_RESET_REQUEST_IN3 = 0,
49
    parameter USE_RESET_REQUEST_IN4 = 0,
50
    parameter USE_RESET_REQUEST_IN5 = 0,
51
    parameter USE_RESET_REQUEST_IN6 = 0,
52
    parameter USE_RESET_REQUEST_IN7 = 0,
53
    parameter USE_RESET_REQUEST_IN8 = 0,
54
    parameter USE_RESET_REQUEST_IN9 = 0,
55
    parameter USE_RESET_REQUEST_IN10 = 0,
56
    parameter USE_RESET_REQUEST_IN11 = 0,
57
    parameter USE_RESET_REQUEST_IN12 = 0,
58
    parameter USE_RESET_REQUEST_IN13 = 0,
59
    parameter USE_RESET_REQUEST_IN14 = 0,
60
    parameter USE_RESET_REQUEST_IN15 = 0,
61
    parameter OUTPUT_RESET_SYNC_EDGES       = "deassert",
62
    parameter SYNC_DEPTH                    = 2,
63
    parameter RESET_REQUEST_PRESENT         = 0,
64
    parameter RESET_REQ_WAIT_TIME           = 3,
65
    parameter MIN_RST_ASSERTION_TIME        = 11,
66
    parameter RESET_REQ_EARLY_DSRT_TIME     = 4,
67
    parameter ADAPT_RESET_REQUEST          = 0
68
)
69
(
70
    // --------------------------------------
71
    // We support up to 16 reset inputs, for now
72
    // --------------------------------------
73
    input reset_in0,
74
    input reset_in1,
75
    input reset_in2,
76
    input reset_in3,
77
    input reset_in4,
78
    input reset_in5,
79
    input reset_in6,
80
    input reset_in7,
81
    input reset_in8,
82
    input reset_in9,
83
    input reset_in10,
84
    input reset_in11,
85
    input reset_in12,
86
    input reset_in13,
87
    input reset_in14,
88
    input reset_in15,
89
    input reset_req_in0,
90
    input reset_req_in1,
91
    input reset_req_in2,
92
    input reset_req_in3,
93
    input reset_req_in4,
94
    input reset_req_in5,
95
    input reset_req_in6,
96
    input reset_req_in7,
97
    input reset_req_in8,
98
    input reset_req_in9,
99
    input reset_req_in10,
100
    input reset_req_in11,
101
    input reset_req_in12,
102
    input reset_req_in13,
103
    input reset_req_in14,
104
    input reset_req_in15,
105
 
106
 
107
    input  clk,
108
    output reg reset_out,
109
    output reg reset_req
110
);
111
 
112
   // Always use async reset synchronizer if reset_req is used
113
   localparam ASYNC_RESET = (OUTPUT_RESET_SYNC_EDGES == "deassert");
114
 
115
   // --------------------------------------
116
   // Local parameter to control the reset_req and reset_out timing when RESET_REQUEST_PRESENT==1
117
   // --------------------------------------
118
   localparam MIN_METASTABLE = 3;
119
   localparam RSTREQ_ASRT_SYNC_TAP = MIN_METASTABLE + RESET_REQ_WAIT_TIME;
120
 
121
   localparam LARGER = RESET_REQ_WAIT_TIME > RESET_REQ_EARLY_DSRT_TIME ? RESET_REQ_WAIT_TIME : RESET_REQ_EARLY_DSRT_TIME;
122
 
123
   localparam ASSERTION_CHAIN_LENGTH =  (MIN_METASTABLE > LARGER) ?
124
                                            MIN_RST_ASSERTION_TIME + 1 :
125
                                        (
126
                                        (MIN_RST_ASSERTION_TIME > LARGER)?
127
                                            MIN_RST_ASSERTION_TIME + (LARGER - MIN_METASTABLE + 1) + 1 :
128
                                            MIN_RST_ASSERTION_TIME + RESET_REQ_EARLY_DSRT_TIME + RESET_REQ_WAIT_TIME - MIN_METASTABLE + 2
129
                                        );
130
 
131
   localparam RESET_REQ_DRST_TAP = RESET_REQ_EARLY_DSRT_TIME + 1;
132
   // --------------------------------------
133
 
134
   wire merged_reset;
135
   wire merged_reset_req_in;
136
   wire reset_out_pre;
137
   wire reset_req_pre;
138
 
139
   // Registers and Interconnect
140
   (*preserve*) reg  [RSTREQ_ASRT_SYNC_TAP: 0]  altera_reset_synchronizer_int_chain;
141
   reg [ASSERTION_CHAIN_LENGTH-1: 0]            r_sync_rst_chain;
142
   reg                                          r_sync_rst;
143
   reg                                          r_early_rst;
144
 
145
    // --------------------------------------
146
    // "Or" all the input resets together
147
    // --------------------------------------
148
    assign merged_reset = (
149
                              reset_in0 |
150
                              reset_in1 |
151
                              reset_in2 |
152
                              reset_in3 |
153
                              reset_in4 |
154
                              reset_in5 |
155
                              reset_in6 |
156
                              reset_in7 |
157
                              reset_in8 |
158
                              reset_in9 |
159
                              reset_in10 |
160
                              reset_in11 |
161
                              reset_in12 |
162
                              reset_in13 |
163
                              reset_in14 |
164
                              reset_in15
165
                          );
166
 
167
    assign merged_reset_req_in = (
168
                              ( (USE_RESET_REQUEST_IN0 == 1) ? reset_req_in0 : 1'b0)  |
169
                              ( (USE_RESET_REQUEST_IN1 == 1) ? reset_req_in1 : 1'b0)  |
170
                              ( (USE_RESET_REQUEST_IN2 == 1) ? reset_req_in2 : 1'b0)  |
171
                              ( (USE_RESET_REQUEST_IN3 == 1) ? reset_req_in3 : 1'b0)  |
172
                              ( (USE_RESET_REQUEST_IN4 == 1) ? reset_req_in4 : 1'b0)  |
173
                              ( (USE_RESET_REQUEST_IN5 == 1) ? reset_req_in5 : 1'b0)  |
174
                              ( (USE_RESET_REQUEST_IN6 == 1) ? reset_req_in6 : 1'b0)  |
175
                              ( (USE_RESET_REQUEST_IN7 == 1) ? reset_req_in7 : 1'b0)  |
176
                              ( (USE_RESET_REQUEST_IN8 == 1) ? reset_req_in8 : 1'b0)  |
177
                              ( (USE_RESET_REQUEST_IN9 == 1) ? reset_req_in9 : 1'b0)  |
178
                              ( (USE_RESET_REQUEST_IN10 == 1) ? reset_req_in10 : 1'b0)  |
179
                              ( (USE_RESET_REQUEST_IN11 == 1) ? reset_req_in11 : 1'b0)  |
180
                              ( (USE_RESET_REQUEST_IN12 == 1) ? reset_req_in12 : 1'b0)  |
181
                              ( (USE_RESET_REQUEST_IN13 == 1) ? reset_req_in13 : 1'b0)  |
182
                              ( (USE_RESET_REQUEST_IN14 == 1) ? reset_req_in14 : 1'b0)  |
183
                              ( (USE_RESET_REQUEST_IN15 == 1) ? reset_req_in15 : 1'b0)
184
                            );
185
 
186
 
187
    // --------------------------------------
188
    // And if required, synchronize it to the required clock domain,
189
    // with the correct synchronization type
190
    // --------------------------------------
191
    generate if (OUTPUT_RESET_SYNC_EDGES == "none" && (RESET_REQUEST_PRESENT==0)) begin
192
 
193
        assign reset_out_pre = merged_reset;
194
        assign reset_req_pre = merged_reset_req_in;
195
 
196
    end else begin
197
 
198
        altera_reset_synchronizer
199
        #(
200
            .DEPTH      (SYNC_DEPTH),
201
            .ASYNC_RESET(RESET_REQUEST_PRESENT? 1'b1 : ASYNC_RESET)
202
        )
203
        alt_rst_sync_uq1
204
        (
205
            .clk        (clk),
206
            .reset_in   (merged_reset),
207
            .reset_out  (reset_out_pre)
208
        );
209
 
210
        altera_reset_synchronizer
211
        #(
212
            .DEPTH      (SYNC_DEPTH),
213
            .ASYNC_RESET(0)
214
        )
215
        alt_rst_req_sync_uq1
216
        (
217
            .clk        (clk),
218
            .reset_in   (merged_reset_req_in),
219
            .reset_out  (reset_req_pre)
220
        );
221
 
222
    end
223
    endgenerate
224
 
225
    generate if ( ( (RESET_REQUEST_PRESENT == 0) && (ADAPT_RESET_REQUEST==0) )|
226
                  ( (ADAPT_RESET_REQUEST == 1) && (OUTPUT_RESET_SYNC_EDGES != "deassert") ) ) begin
227
        always @* begin
228
            reset_out = reset_out_pre;
229
            reset_req = reset_req_pre;
230
        end
231
    end else if ( (RESET_REQUEST_PRESENT == 0) && (ADAPT_RESET_REQUEST==1) ) begin
232
 
233
        wire reset_out_pre2;
234
 
235
        altera_reset_synchronizer
236
        #(
237
            .DEPTH      (SYNC_DEPTH+1),
238
            .ASYNC_RESET(0)
239
        )
240
        alt_rst_sync_uq2
241
        (
242
            .clk        (clk),
243
            .reset_in   (reset_out_pre),
244
            .reset_out  (reset_out_pre2)
245
        );
246
 
247
        always @* begin
248
            reset_out = reset_out_pre2;
249
            reset_req = reset_req_pre;
250
        end
251
 
252
    end
253
    else begin
254
 
255
    // 3-FF Metastability Synchronizer
256
    initial
257
    begin
258
        altera_reset_synchronizer_int_chain <= {RSTREQ_ASRT_SYNC_TAP{1'b1}};
259
    end
260
 
261
    always @(posedge clk)
262
    begin
263
        altera_reset_synchronizer_int_chain[RSTREQ_ASRT_SYNC_TAP:0] <=
264
            {altera_reset_synchronizer_int_chain[RSTREQ_ASRT_SYNC_TAP-1:0], reset_out_pre};
265
    end
266
 
267
    // Synchronous reset pipe
268
    initial
269
    begin
270
        r_sync_rst_chain <= {ASSERTION_CHAIN_LENGTH{1'b1}};
271
    end
272
 
273
    always @(posedge clk)
274
    begin
275
        if (altera_reset_synchronizer_int_chain[MIN_METASTABLE-1] == 1'b1)
276
        begin
277
            r_sync_rst_chain <= {ASSERTION_CHAIN_LENGTH{1'b1}};
278
    end
279
    else
280
    begin
281
        r_sync_rst_chain <= {1'b0, r_sync_rst_chain[ASSERTION_CHAIN_LENGTH-1:1]};
282
    end
283
    end
284
 
285
    // Standard synchronous reset output.  From 0-1, the transition lags the early output.  For 1->0, the transition
286
    // matches the early input.
287
 
288
    always @(posedge clk)
289
    begin
290
        case ({altera_reset_synchronizer_int_chain[RSTREQ_ASRT_SYNC_TAP], r_sync_rst_chain[1], r_sync_rst})
291
            3'b000:   r_sync_rst <= 1'b0; // Not reset
292
            3'b001:   r_sync_rst <= 1'b0;
293
            3'b010:   r_sync_rst <= 1'b0;
294
            3'b011:   r_sync_rst <= 1'b1;
295
            3'b100:   r_sync_rst <= 1'b1;
296
            3'b101:   r_sync_rst <= 1'b1;
297
            3'b110:   r_sync_rst <= 1'b1;
298
            3'b111:   r_sync_rst <= 1'b1; // In Reset
299
            default:  r_sync_rst <= 1'b1;
300
        endcase
301
 
302
        case ({r_sync_rst_chain[1], r_sync_rst_chain[RESET_REQ_DRST_TAP] | reset_req_pre})
303
            2'b00:   r_early_rst <= 1'b0; // Not reset
304
            2'b01:   r_early_rst <= 1'b1; // Coming out of reset
305
            2'b10:   r_early_rst <= 1'b0; // Spurious reset - should not be possible via synchronous design.
306
            2'b11:   r_early_rst <= 1'b1; // Held in reset
307
            default: r_early_rst <= 1'b1;
308
        endcase
309
    end
310
 
311
    always @* begin
312
        reset_out = r_sync_rst;
313
        reset_req = r_early_rst;
314
    end
315
 
316
    end
317
    endgenerate
318
 
319
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.