blob: 306de341995f8dc338a601d506019225dade7cc6 [file] [log] [blame]
agorararmarde5780bf2020-12-09 21:27:56 +00001// Copyright 2020 Efabless Corporation
2//
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
Tim Edwards43e5c602020-11-19 15:59:50 -050098 sky130_fd_sc_hd__conb_1 mprj_logic_high [458:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +020099`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400100 .VPWR(vccd1),
101 .VGND(vssd1),
102 .VPB(vccd1),
103 .VNB(vssd1),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200104`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400105 .HI(mprj_logic1),
106 .LO()
107 );
108
Tim Edwards32d05422020-10-19 19:43:52 -0400109 sky130_fd_sc_hd__conb_1 mprj2_logic_high (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200110`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400111 .VPWR(vccd2),
112 .VGND(vssd2),
113 .VPB(vccd2),
114 .VNB(vssd2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200115`endif
Tim Edwards32d05422020-10-19 19:43:52 -0400116 .HI(mprj2_logic1),
117 .LO()
118 );
119
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400120 // Logic high in the VDDA (3.3V) domains
121
Tim Edwardsbc035512020-11-23 11:16:08 -0500122 mgmt_protect_hv powergood_check (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200123`ifdef USE_POWER_PINS
Tim Edwardsbc035512020-11-23 11:16:08 -0500124 .vccd(vccd),
125 .vssd(vssd),
126 .vdda1(vdda1),
127 .vssa1(vssa1),
128 .vdda2(vdda2),
129 .vssa2(vssa2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200130`endif
Tim Edwardsbc035512020-11-23 11:16:08 -0500131 .mprj_vdd_logic1(mprj_vdd_logic1),
132 .mprj2_vdd_logic1(mprj2_vdd_logic1)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400133 );
134
Tim Edwards32d05422020-10-19 19:43:52 -0400135
Tim Edwards43e5c602020-11-19 15:59:50 -0500136 // Buffering from the user side to the management side.
137 // NOTE: This is intended to be better protected, by a full
138 // chain of an lv-to-hv buffer followed by an hv-to-lv buffer.
139 // This serves as a placeholder until that configuration is
140 // checked and characterized. The function below forces the
141 // data input to the management core to be a solid logic 0 when
142 // the user project is powered down.
143
Tim Edwards4518c622020-11-19 17:44:25 -0500144 sky130_fd_sc_hd__nand2_4 user_to_mprj_in_gates [127:0] (
145`ifdef USE_POWER_PINS
146 .VPWR(vccd),
147 .VGND(vssd),
148 .VPB(vccd),
149 .VNB(vssd),
150`endif
151 .Y(la_data_in_mprj_bar),
152 .A(la_data_out_core),
153 .B(mprj_logic1[457:330])
154 );
155
156 sky130_fd_sc_hd__inv_8 user_to_mprj_in_buffers [127:0] (
Tim Edwards43e5c602020-11-19 15:59:50 -0500157`ifdef USE_POWER_PINS
158 .VPWR(vccd),
159 .VGND(vssd),
160 .VPB(vccd),
161 .VNB(vssd),
162`endif
163 .Y(la_data_in_mprj),
Tim Edwards4518c622020-11-19 17:44:25 -0500164 .A(la_data_in_mprj_bar)
Tim Edwards43e5c602020-11-19 15:59:50 -0500165 );
166
167 // The remaining circuitry guards against the management
168 // SoC dumping current into the user project area when
169 // the user project area is powered down.
170
Tim Edwards53d92182020-10-11 21:47:40 -0400171 sky130_fd_sc_hd__einvp_8 mprj_rstn_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200172`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400173 .VPWR(vccd),
174 .VGND(vssd),
175 .VPB(vccd),
176 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200177`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400178 .Z(user_resetn),
179 .A(~caravel_rstn),
180 .TE(mprj_logic1[0])
181 );
182
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200183 assign user_reset = ~user_resetn;
184
Tim Edwards53d92182020-10-11 21:47:40 -0400185 sky130_fd_sc_hd__einvp_8 mprj_clk_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200186`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400187 .VPWR(vccd),
188 .VGND(vssd),
189 .VPB(vccd),
190 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200191`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400192 .Z(user_clock),
193 .A(~caravel_clk),
194 .TE(mprj_logic1[1])
195 );
196
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400197 sky130_fd_sc_hd__einvp_8 mprj_clk2_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200198`ifdef USE_POWER_PINS
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400199 .VPWR(vccd),
200 .VGND(vssd),
201 .VPB(vccd),
202 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200203`endif
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400204 .Z(user_clock2),
205 .A(~caravel_clk2),
206 .TE(mprj_logic1[2])
207 );
208
Tim Edwards53d92182020-10-11 21:47:40 -0400209 sky130_fd_sc_hd__einvp_8 mprj_cyc_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200210`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400211 .VPWR(vccd),
212 .VGND(vssd),
213 .VPB(vccd),
214 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200215`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400216 .Z(mprj_cyc_o_user),
217 .A(~mprj_cyc_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400218 .TE(mprj_logic1[3])
Tim Edwards53d92182020-10-11 21:47:40 -0400219 );
220
221 sky130_fd_sc_hd__einvp_8 mprj_stb_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200222`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400223 .VPWR(vccd),
224 .VGND(vssd),
225 .VPB(vccd),
226 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200227`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400228 .Z(mprj_stb_o_user),
229 .A(~mprj_stb_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400230 .TE(mprj_logic1[4])
Tim Edwards53d92182020-10-11 21:47:40 -0400231 );
232
233 sky130_fd_sc_hd__einvp_8 mprj_we_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200234`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400235 .VPWR(vccd),
236 .VGND(vssd),
237 .VPB(vccd),
238 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200239`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400240 .Z(mprj_we_o_user),
241 .A(~mprj_we_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400242 .TE(mprj_logic1[5])
Tim Edwards53d92182020-10-11 21:47:40 -0400243 );
244
245 sky130_fd_sc_hd__einvp_8 mprj_sel_buf [3:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200246`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400247 .VPWR(vccd),
248 .VGND(vssd),
249 .VPB(vccd),
250 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200251`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400252 .Z(mprj_sel_o_user),
253 .A(~mprj_sel_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400254 .TE(mprj_logic1[9:6])
Tim Edwards53d92182020-10-11 21:47:40 -0400255 );
256
257 sky130_fd_sc_hd__einvp_8 mprj_adr_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200258`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400259 .VPWR(vccd),
260 .VGND(vssd),
261 .VPB(vccd),
262 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200263`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400264 .Z(mprj_adr_o_user),
265 .A(~mprj_adr_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400266 .TE(mprj_logic1[41:10])
Tim Edwards53d92182020-10-11 21:47:40 -0400267 );
268
269 sky130_fd_sc_hd__einvp_8 mprj_dat_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200270`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400271 .VPWR(vccd),
272 .VGND(vssd),
273 .VPB(vccd),
274 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200275`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400276 .Z(mprj_dat_o_user),
277 .A(~mprj_dat_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400278 .TE(mprj_logic1[73:42])
Tim Edwards53d92182020-10-11 21:47:40 -0400279 );
280
Tim Edwards43e5c602020-11-19 15:59:50 -0500281 /* Project data out from the managment side to the user project */
282 /* area when the user project is powered down. */
Tim Edwards53d92182020-10-11 21:47:40 -0400283
284 sky130_fd_sc_hd__einvp_8 la_buf [127:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200285`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400286 .VPWR(vccd),
287 .VGND(vssd),
288 .VPB(vccd),
289 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200290`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500291 .Z(la_data_in_core),
292 .A(~la_data_out_mprj),
293 .TE(mprj_logic1[201:74])
Tim Edwards53d92182020-10-11 21:47:40 -0400294 );
295
Tim Edwards43e5c602020-11-19 15:59:50 -0500296 /* Project data out enable (bar) from the managment side to the */
297 /* user project area when the user project is powered down. */
298
299 sky130_fd_sc_hd__einvp_8 user_to_mprj_oen_buffers [127:0] (
300`ifdef USE_POWER_PINS
301 .VPWR(vccd),
302 .VGND(vssd),
303 .VPB(vccd),
304 .VNB(vssd),
305`endif
306 .Z(la_oen_core),
307 .A(~la_oen_mprj),
308 .TE(mprj_logic1[329:202])
309 );
310
Tim Edwards32d05422020-10-19 19:43:52 -0400311 /* The conb cell output is a resistive connection directly to */
312 /* the power supply, so when returning the user1_powergood */
313 /* signal, make sure that it is buffered properly. */
314
315 sky130_fd_sc_hd__buf_8 mprj_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200316`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400317 .VPWR(vccd),
318 .VGND(vssd),
319 .VPB(vccd),
320 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200321`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500322 .A(mprj_logic1[458]),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400323 .X(user1_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400324 );
325
326 sky130_fd_sc_hd__buf_8 mprj2_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200327`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400328 .VPWR(vccd),
329 .VGND(vssd),
330 .VPB(vccd),
331 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200332`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500333 .A(mprj2_vdd_logic1),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400334 .X(user2_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400335 );
336
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400337 sky130_fd_sc_hd__buf_8 mprj_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200338`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400339 .VPWR(vccd),
340 .VGND(vssd),
341 .VPB(vccd),
342 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200343`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400344 .A(mprj_vdd_logic1),
Tim Edwards581068f2020-11-19 12:45:25 -0500345 .X(user1_vdd_powergood)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400346 );
347
348 sky130_fd_sc_hd__buf_8 mprj2_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200349`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400350 .VPWR(vccd),
351 .VGND(vssd),
352 .VPB(vccd),
353 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200354`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400355 .A(mprj2_vdd_logic1),
356 .X(user2_vdd_powergood)
357 );
Tim Edwards53d92182020-10-11 21:47:40 -0400358endmodule
Tim Edwards581068f2020-11-19 12:45:25 -0500359`default_nettype wire