blob: 5220bce846a6251cc0b1f69426db7fd8a264a471 [file] [log] [blame]
agorararmard6c766a82020-12-10 18:13:12 +02001// SPDX-FileCopyrightText: 2020 Efabless Corporation
agorararmarde5780bf2020-12-09 21:27:56 +00002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
agorararmardafa96ea2020-12-09 23:37:31 +020014// SPDX-License-Identifier: Apache-2.0
agorararmarde5780bf2020-12-09 21:27:56 +000015
Matt Venn08cd6eb2020-11-16 12:01:14 +010016`default_nettype none
Tim Edwards53d92182020-10-11 21:47:40 -040017/*----------------------------------------------------------------------*/
18/* Buffers protecting the management region from the user region. */
19/* This mainly consists of tristate buffers that are enabled by a */
20/* "logic 1" output connected to the user's VCCD domain. This ensures */
21/* that the buffer is disabled and the output high-impedence when the */
22/* user 1.8V supply is absent. */
23/*----------------------------------------------------------------------*/
24/* Because there is no tristate buffer with a non-inverted enable, a */
25/* tristate inverter with non-inverted enable is used in series with */
26/* another (normal) inverter. */
27/*----------------------------------------------------------------------*/
28/* For the sake of placement/routing, one conb (logic 1) cell is used */
29/* for every buffer. */
30/*----------------------------------------------------------------------*/
31
32module mgmt_protect (
Ahmed Ghazyfe9c3bb2020-11-26 15:29:48 +020033`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -040034 inout vccd,
35 inout vssd,
36 inout vccd1,
37 inout vssd1,
Tim Edwards32d05422020-10-19 19:43:52 -040038 inout vccd2,
39 inout vssd2,
Tim Edwards05ad4fc2020-10-19 22:12:33 -040040 inout vdda1,
41 inout vssa1,
42 inout vdda2,
43 inout vssa2,
Ahmed Ghazyfe9c3bb2020-11-26 15:29:48 +020044`endif
Tim Edwards53d92182020-10-11 21:47:40 -040045
46 input caravel_clk,
Tim Edwards7a8cbb12020-10-12 11:32:11 -040047 input caravel_clk2,
Tim Edwards53d92182020-10-11 21:47:40 -040048 input caravel_rstn,
49 input mprj_cyc_o_core,
50 input mprj_stb_o_core,
51 input mprj_we_o_core,
52 input [3:0] mprj_sel_o_core,
53 input [31:0] mprj_adr_o_core,
54 input [31:0] mprj_dat_o_core,
Tim Edwards43e5c602020-11-19 15:59:50 -050055
56 // All signal in/out directions are the reverse of the signal
57 // names at the buffer intrface.
58
59 output [127:0] la_data_in_mprj,
60 input [127:0] la_data_out_mprj,
61 input [127:0] la_oen_mprj,
62
63 input [127:0] la_data_out_core,
64 output [127:0] la_data_in_core,
65 output [127:0] la_oen_core,
Tim Edwards53d92182020-10-11 21:47:40 -040066
67 output user_clock,
Tim Edwards7a8cbb12020-10-12 11:32:11 -040068 output user_clock2,
Tim Edwards53d92182020-10-11 21:47:40 -040069 output user_resetn,
Ahmed Ghazy69663c72020-11-18 20:15:53 +020070 output user_reset,
Tim Edwards53d92182020-10-11 21:47:40 -040071 output mprj_cyc_o_user,
72 output mprj_stb_o_user,
73 output mprj_we_o_user,
74 output [3:0] mprj_sel_o_user,
75 output [31:0] mprj_adr_o_user,
76 output [31:0] mprj_dat_o_user,
Tim Edwards05ad4fc2020-10-19 22:12:33 -040077 output user1_vcc_powergood,
78 output user2_vcc_powergood,
79 output user1_vdd_powergood,
80 output user2_vdd_powergood
Tim Edwards53d92182020-10-11 21:47:40 -040081);
82
Tim Edwards43e5c602020-11-19 15:59:50 -050083 wire [458:0] mprj_logic1;
84 wire mprj2_logic1;
Tim Edwards05ad4fc2020-10-19 22:12:33 -040085
86 wire mprj_vdd_logic1_h;
87 wire mprj2_vdd_logic1_h;
88 wire mprj_vdd_logic1;
89 wire mprj2_vdd_logic1;
90
91 wire user1_vcc_powergood;
92 wire user2_vcc_powergood;
93 wire user1_vdd_powergood;
94 wire user2_vdd_powergood;
Tim Edwards53d92182020-10-11 21:47:40 -040095
Tim Edwards4518c622020-11-19 17:44:25 -050096 wire [127:0] la_data_in_mprj_bar;
97
Ahmed Ghazy442825e2020-12-14 19:12:34 +020098 mprj_logic_high mprj_logic_high_inst (
Ahmed Ghazy69663c72020-11-18 20:15:53 +020099`ifdef USE_POWER_PINS
Ahmed Ghazy442825e2020-12-14 19:12:34 +0200100 .vccd1(vccd1),
101 .vssd1(vssd1),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200102`endif
Ahmed Ghazy442825e2020-12-14 19:12:34 +0200103 .HI(mprj_logic1)
Tim Edwards53d92182020-10-11 21:47:40 -0400104 );
105
Ahmed Ghazy442825e2020-12-14 19:12:34 +0200106 mprj2_logic_high mprj2_logic_high_inst (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200107`ifdef USE_POWER_PINS
Ahmed Ghazy442825e2020-12-14 19:12:34 +0200108 .vccd2(vccd2),
109 .vssd2(vssd2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200110`endif
Ahmed Ghazy442825e2020-12-14 19:12:34 +0200111 .HI(mprj2_logic1)
Tim Edwards32d05422020-10-19 19:43:52 -0400112 );
113
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400114 // Logic high in the VDDA (3.3V) domains
115
Tim Edwardsbc035512020-11-23 11:16:08 -0500116 mgmt_protect_hv powergood_check (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200117`ifdef USE_POWER_PINS
Tim Edwardsbc035512020-11-23 11:16:08 -0500118 .vccd(vccd),
119 .vssd(vssd),
120 .vdda1(vdda1),
121 .vssa1(vssa1),
122 .vdda2(vdda2),
123 .vssa2(vssa2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200124`endif
Tim Edwardsbc035512020-11-23 11:16:08 -0500125 .mprj_vdd_logic1(mprj_vdd_logic1),
126 .mprj2_vdd_logic1(mprj2_vdd_logic1)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400127 );
128
Tim Edwards32d05422020-10-19 19:43:52 -0400129
Tim Edwards43e5c602020-11-19 15:59:50 -0500130 // Buffering from the user side to the management side.
131 // NOTE: This is intended to be better protected, by a full
132 // chain of an lv-to-hv buffer followed by an hv-to-lv buffer.
133 // This serves as a placeholder until that configuration is
134 // checked and characterized. The function below forces the
135 // data input to the management core to be a solid logic 0 when
136 // the user project is powered down.
137
Tim Edwards4518c622020-11-19 17:44:25 -0500138 sky130_fd_sc_hd__nand2_4 user_to_mprj_in_gates [127:0] (
139`ifdef USE_POWER_PINS
140 .VPWR(vccd),
141 .VGND(vssd),
142 .VPB(vccd),
143 .VNB(vssd),
144`endif
145 .Y(la_data_in_mprj_bar),
146 .A(la_data_out_core),
147 .B(mprj_logic1[457:330])
148 );
149
150 sky130_fd_sc_hd__inv_8 user_to_mprj_in_buffers [127:0] (
Tim Edwards43e5c602020-11-19 15:59:50 -0500151`ifdef USE_POWER_PINS
152 .VPWR(vccd),
153 .VGND(vssd),
154 .VPB(vccd),
155 .VNB(vssd),
156`endif
157 .Y(la_data_in_mprj),
Tim Edwards4518c622020-11-19 17:44:25 -0500158 .A(la_data_in_mprj_bar)
Tim Edwards43e5c602020-11-19 15:59:50 -0500159 );
160
161 // The remaining circuitry guards against the management
162 // SoC dumping current into the user project area when
163 // the user project area is powered down.
164
Tim Edwards53d92182020-10-11 21:47:40 -0400165 sky130_fd_sc_hd__einvp_8 mprj_rstn_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200166`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400167 .VPWR(vccd),
168 .VGND(vssd),
169 .VPB(vccd),
170 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200171`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400172 .Z(user_resetn),
173 .A(~caravel_rstn),
174 .TE(mprj_logic1[0])
175 );
176
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200177 assign user_reset = ~user_resetn;
178
Tim Edwards53d92182020-10-11 21:47:40 -0400179 sky130_fd_sc_hd__einvp_8 mprj_clk_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200180`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400181 .VPWR(vccd),
182 .VGND(vssd),
183 .VPB(vccd),
184 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200185`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400186 .Z(user_clock),
187 .A(~caravel_clk),
188 .TE(mprj_logic1[1])
189 );
190
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400191 sky130_fd_sc_hd__einvp_8 mprj_clk2_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200192`ifdef USE_POWER_PINS
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400193 .VPWR(vccd),
194 .VGND(vssd),
195 .VPB(vccd),
196 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200197`endif
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400198 .Z(user_clock2),
199 .A(~caravel_clk2),
200 .TE(mprj_logic1[2])
201 );
202
Tim Edwards53d92182020-10-11 21:47:40 -0400203 sky130_fd_sc_hd__einvp_8 mprj_cyc_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200204`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400205 .VPWR(vccd),
206 .VGND(vssd),
207 .VPB(vccd),
208 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200209`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400210 .Z(mprj_cyc_o_user),
211 .A(~mprj_cyc_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400212 .TE(mprj_logic1[3])
Tim Edwards53d92182020-10-11 21:47:40 -0400213 );
214
215 sky130_fd_sc_hd__einvp_8 mprj_stb_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200216`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400217 .VPWR(vccd),
218 .VGND(vssd),
219 .VPB(vccd),
220 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200221`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400222 .Z(mprj_stb_o_user),
223 .A(~mprj_stb_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400224 .TE(mprj_logic1[4])
Tim Edwards53d92182020-10-11 21:47:40 -0400225 );
226
227 sky130_fd_sc_hd__einvp_8 mprj_we_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200228`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400229 .VPWR(vccd),
230 .VGND(vssd),
231 .VPB(vccd),
232 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200233`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400234 .Z(mprj_we_o_user),
235 .A(~mprj_we_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400236 .TE(mprj_logic1[5])
Tim Edwards53d92182020-10-11 21:47:40 -0400237 );
238
239 sky130_fd_sc_hd__einvp_8 mprj_sel_buf [3:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200240`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400241 .VPWR(vccd),
242 .VGND(vssd),
243 .VPB(vccd),
244 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200245`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400246 .Z(mprj_sel_o_user),
247 .A(~mprj_sel_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400248 .TE(mprj_logic1[9:6])
Tim Edwards53d92182020-10-11 21:47:40 -0400249 );
250
251 sky130_fd_sc_hd__einvp_8 mprj_adr_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200252`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400253 .VPWR(vccd),
254 .VGND(vssd),
255 .VPB(vccd),
256 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200257`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400258 .Z(mprj_adr_o_user),
259 .A(~mprj_adr_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400260 .TE(mprj_logic1[41:10])
Tim Edwards53d92182020-10-11 21:47:40 -0400261 );
262
263 sky130_fd_sc_hd__einvp_8 mprj_dat_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200264`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400265 .VPWR(vccd),
266 .VGND(vssd),
267 .VPB(vccd),
268 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200269`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400270 .Z(mprj_dat_o_user),
271 .A(~mprj_dat_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400272 .TE(mprj_logic1[73:42])
Tim Edwards53d92182020-10-11 21:47:40 -0400273 );
274
Tim Edwards43e5c602020-11-19 15:59:50 -0500275 /* Project data out from the managment side to the user project */
276 /* area when the user project is powered down. */
Tim Edwards53d92182020-10-11 21:47:40 -0400277
278 sky130_fd_sc_hd__einvp_8 la_buf [127:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200279`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400280 .VPWR(vccd),
281 .VGND(vssd),
282 .VPB(vccd),
283 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200284`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500285 .Z(la_data_in_core),
286 .A(~la_data_out_mprj),
287 .TE(mprj_logic1[201:74])
Tim Edwards53d92182020-10-11 21:47:40 -0400288 );
289
Tim Edwards43e5c602020-11-19 15:59:50 -0500290 /* Project data out enable (bar) from the managment side to the */
291 /* user project area when the user project is powered down. */
292
293 sky130_fd_sc_hd__einvp_8 user_to_mprj_oen_buffers [127:0] (
294`ifdef USE_POWER_PINS
295 .VPWR(vccd),
296 .VGND(vssd),
297 .VPB(vccd),
298 .VNB(vssd),
299`endif
300 .Z(la_oen_core),
301 .A(~la_oen_mprj),
302 .TE(mprj_logic1[329:202])
303 );
304
Tim Edwards32d05422020-10-19 19:43:52 -0400305 /* The conb cell output is a resistive connection directly to */
306 /* the power supply, so when returning the user1_powergood */
307 /* signal, make sure that it is buffered properly. */
308
309 sky130_fd_sc_hd__buf_8 mprj_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200310`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400311 .VPWR(vccd),
312 .VGND(vssd),
313 .VPB(vccd),
314 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200315`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500316 .A(mprj_logic1[458]),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400317 .X(user1_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400318 );
319
320 sky130_fd_sc_hd__buf_8 mprj2_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200321`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400322 .VPWR(vccd),
323 .VGND(vssd),
324 .VPB(vccd),
325 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200326`endif
Ahmed Ghazy94dabb82020-12-14 19:02:22 +0200327 .A(mprj2_logic1),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400328 .X(user2_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400329 );
330
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400331 sky130_fd_sc_hd__buf_8 mprj_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200332`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400333 .VPWR(vccd),
334 .VGND(vssd),
335 .VPB(vccd),
336 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200337`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400338 .A(mprj_vdd_logic1),
Tim Edwards581068f2020-11-19 12:45:25 -0500339 .X(user1_vdd_powergood)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400340 );
341
342 sky130_fd_sc_hd__buf_8 mprj2_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200343`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400344 .VPWR(vccd),
345 .VGND(vssd),
346 .VPB(vccd),
347 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200348`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400349 .A(mprj2_vdd_logic1),
350 .X(user2_vdd_powergood)
351 );
Tim Edwards53d92182020-10-11 21:47:40 -0400352endmodule
Tim Edwards581068f2020-11-19 12:45:25 -0500353`default_nettype wire