|
| 1 | +// *!*************************************************************************** |
| 2 | +// *! Copyright 2019 International Business Machines |
| 3 | +// *! |
| 4 | +// *! Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// *! you may not use this file except in compliance with the License. |
| 6 | +// *! You may obtain a copy of the License at |
| 7 | +// *! http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// *! |
| 9 | +// *! The patent license granted to you in Section 3 of the License, as applied |
| 10 | +// *! to the "Work," hereby includes implementations of the Work in physical form. |
| 11 | +// *! |
| 12 | +// *! Unless required by applicable law or agreed to in writing, the reference design |
| 13 | +// *! distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// *! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// *! See the License for the specific language governing permissions and |
| 16 | +// *! limitations under the License. |
| 17 | +// *! |
| 18 | +// *! The background Specification upon which this is based is managed by and available from |
| 19 | +// *! the OpenCAPI Consortium. More information can be found at https://opencapi.org. |
| 20 | +// *!*************************************************************************** |
| 21 | +// Module designer: Dimitris Syrivelis |
| 22 | +// Backup: Christian Pinto, Michele Gazzetti |
| 23 | + |
| 24 | +`timescale 1ns / 10ps |
| 25 | + |
| 26 | +// ============================================================================================================================== |
| 27 | +// @@@ Module Declaration |
| 28 | +// ============================================================================================================================== |
| 29 | +module aurora_power_on_reset ( |
| 30 | + input clock // Clock - needs to be the aurora init_clk and needs to be stable. |
| 31 | + , input reset_n // needs to be active high early reset (ocde - would be fine) |
| 32 | + , input sys_out_aurora_r // Let's you know when to deassert rb |
| 33 | + , output pma_init // locally registered to meet timing. |
| 34 | + , output rpb // |
| 35 | + , output rout_n |
| 36 | +) ; |
| 37 | + |
| 38 | +reg pos_pma_init_q; |
| 39 | +reg pos_reset_pb_q; |
| 40 | +reg pos_reset_logic_n_q; |
| 41 | + |
| 42 | +reg pow_pma_init_q; |
| 43 | +reg pow_reset_pb_q; |
| 44 | +reg pow_reset_logic_n_q; |
| 45 | + |
| 46 | +reg ce_pma_init_q; |
| 47 | +reg ce_reset_pb_q; |
| 48 | +reg ce_reset_logic_n_q; |
| 49 | + |
| 50 | +reg dsor_pma_init_q; |
| 51 | +reg dsor_reset_pb_q; |
| 52 | +reg dsor_reset_logic_n_q; |
| 53 | + |
| 54 | +reg oor_pma_init_q; |
| 55 | +reg oor_reset_pb_q; |
| 56 | +reg oor_reset_logic_n_q; |
| 57 | + |
| 58 | + |
| 59 | +reg[7:0] cycle_counter_poweron; |
| 60 | +reg[7:0] cycle_counter_poweron2; |
| 61 | +//These regs should go to the core |
| 62 | +assign pma_init = pos_pma_init_q | pow_pma_init_q | ce_pma_init_q | dsor_pma_init_q | oor_pma_init_q; |
| 63 | +assign rpb = pos_reset_pb_q | pow_reset_pb_q | ce_reset_pb_q | dsor_reset_pb_q | oor_reset_pb_q; |
| 64 | +assign rout_n = pos_reset_logic_n_q | pow_reset_logic_n_q | ce_reset_logic_n_q | dsor_reset_logic_n_q | oor_reset_logic_n_q; |
| 65 | + |
| 66 | +reg [2:0] SM; |
| 67 | +parameter POWER_ON_SEQ = 3'b000; |
| 68 | +parameter POWER_ON_WAIT = 3'b001; |
| 69 | +parameter COUNTER_EXPIRED = 3'b010; |
| 70 | +parameter DETECT_SYS_OUT_RESET_HIGH = 3'b011; |
| 71 | +parameter OUT_OF_RESET = 3'b100; |
| 72 | + |
| 73 | +always @(posedge(clock)) |
| 74 | + if (SM == POWER_ON_SEQ) |
| 75 | + begin |
| 76 | + pos_reset_logic_n_q <= 1'b0;//Activate reset |
| 77 | + pos_pma_init_q <= 1'b1; //assert active low pma_init_q for power_on |
| 78 | + pos_reset_pb_q <= 1'b1; //assert pma_init_q for |
| 79 | + cycle_counter_poweron <= 8'h20; |
| 80 | + end |
| 81 | + else |
| 82 | + begin |
| 83 | + cycle_counter_poweron <= cycle_counter_poweron - 8'h01; |
| 84 | + pos_reset_logic_n_q <= 1'b0;//invalidate for or gate |
| 85 | + pos_pma_init_q <= 1'b0; //invalidate for or gate |
| 86 | + pos_reset_pb_q <= 1'b0; //invalidatae for or gate |
| 87 | + end |
| 88 | + |
| 89 | + |
| 90 | +always @(posedge(clock)) |
| 91 | + if (SM == POWER_ON_WAIT) |
| 92 | + begin |
| 93 | + pow_reset_logic_n_q <= 1'b0;//maintain reset |
| 94 | + pow_pma_init_q <= 1'b1; //maintain assert pma_init_q for power_on |
| 95 | + pow_reset_pb_q <= 1'b1; //maintain assert pma_init_q for |
| 96 | + end |
| 97 | + else |
| 98 | + begin |
| 99 | + pow_reset_logic_n_q <= 1'b0; |
| 100 | + pow_pma_init_q <= 1'b0; |
| 101 | + pow_reset_pb_q <= 1'b0; |
| 102 | + end |
| 103 | + |
| 104 | +always @(posedge(clock)) |
| 105 | + if (SM == COUNTER_EXPIRED) |
| 106 | + begin |
| 107 | + ce_reset_logic_n_q <= 1'b0;//maintain reset |
| 108 | + ce_pma_init_q <= 1'b0; //deassert pma_init_q for power_on |
| 109 | + ce_reset_pb_q <= 1'b1; //maintain assert pma_init_q for |
| 110 | + cycle_counter_poweron2 <= 8'h20; |
| 111 | + end |
| 112 | + else |
| 113 | + begin |
| 114 | + cycle_counter_poweron2 <= cycle_counter_poweron2 - 8'h01; |
| 115 | + ce_reset_logic_n_q <= 1'b0; |
| 116 | + ce_pma_init_q <= 1'b0; |
| 117 | + ce_reset_pb_q <= 1'b0; |
| 118 | + end |
| 119 | + |
| 120 | +always @(posedge(clock)) |
| 121 | + if (SM == DETECT_SYS_OUT_RESET_HIGH) |
| 122 | + begin |
| 123 | + dsor_reset_logic_n_q <= 1'b0;//maintain reset |
| 124 | + dsor_pma_init_q <= 1'b0; //maintain deassert pma_init_q for power_on |
| 125 | + dsor_reset_pb_q <= 1'b1; //maintain assert |
| 126 | + end |
| 127 | + else |
| 128 | + begin |
| 129 | + dsor_reset_logic_n_q <= 1'b0; |
| 130 | + dsor_pma_init_q <= 1'b0; |
| 131 | + dsor_reset_pb_q <= 1'b0; |
| 132 | + end |
| 133 | + |
| 134 | +always @(posedge(clock)) |
| 135 | + if(SM == OUT_OF_RESET) |
| 136 | + begin |
| 137 | + oor_reset_logic_n_q <= 1'b1;//deassert reset (active low) |
| 138 | + oor_pma_init_q <= 1'b0; //maintain deassert pma_init_q for power_on |
| 139 | + oor_reset_pb_q <= 1'b0; //deassert rb |
| 140 | + end |
| 141 | + else |
| 142 | + begin |
| 143 | + oor_reset_logic_n_q <= 1'b0; |
| 144 | + oor_pma_init_q <= 1'b0; |
| 145 | + oor_reset_pb_q <= 1'b0; |
| 146 | + end |
| 147 | + |
| 148 | +//State machine handling |
| 149 | +always @(posedge(clock)) |
| 150 | + if (reset_n == 1'b0) |
| 151 | + begin |
| 152 | + SM <= POWER_ON_SEQ; |
| 153 | + end |
| 154 | + else |
| 155 | + begin |
| 156 | + case (SM) |
| 157 | + POWER_ON_SEQ: |
| 158 | + SM <= POWER_ON_WAIT; |
| 159 | + POWER_ON_WAIT: |
| 160 | + if (cycle_counter_poweron == 8'h0) |
| 161 | + SM <= COUNTER_EXPIRED; |
| 162 | + else SM <= POWER_ON_WAIT; |
| 163 | + COUNTER_EXPIRED: |
| 164 | + SM <= DETECT_SYS_OUT_RESET_HIGH; |
| 165 | + DETECT_SYS_OUT_RESET_HIGH: |
| 166 | + if (cycle_counter_poweron2 == 8'h0) |
| 167 | + SM <= OUT_OF_RESET; |
| 168 | + else SM <= DETECT_SYS_OUT_RESET_HIGH; |
| 169 | + OUT_OF_RESET: |
| 170 | + SM <= OUT_OF_RESET; //lock in this state permanently. |
| 171 | + endcase |
| 172 | + end |
| 173 | +endmodule |
0 commit comments