blob: 2e03158703671e2d2296dcf4a300a8407894ef9b [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.
14
Matt Venn08cd6eb2020-11-16 12:01:14 +010015`default_nettype none
Tim Edwards53d92182020-10-11 21:47:40 -040016/*----------------------------------------------------------------------*/
17/* Buffers protecting the management region from the user region. */
18/* This mainly consists of tristate buffers that are enabled by a */
19/* "logic 1" output connected to the user's VCCD domain. This ensures */
20/* that the buffer is disabled and the output high-impedence when the */
21/* user 1.8V supply is absent. */
22/*----------------------------------------------------------------------*/
23/* Because there is no tristate buffer with a non-inverted enable, a */
24/* tristate inverter with non-inverted enable is used in series with */
25/* another (normal) inverter. */
26/*----------------------------------------------------------------------*/
27/* For the sake of placement/routing, one conb (logic 1) cell is used */
28/* for every buffer. */
29/*----------------------------------------------------------------------*/
30
31module mgmt_protect (
Ahmed Ghazyfe9c3bb2020-11-26 15:29:48 +020032`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -040033 inout vccd,
34 inout vssd,
35 inout vccd1,
36 inout vssd1,
Tim Edwards32d05422020-10-19 19:43:52 -040037 inout vccd2,
38 inout vssd2,
Tim Edwards05ad4fc2020-10-19 22:12:33 -040039 inout vdda1,
40 inout vssa1,
41 inout vdda2,
42 inout vssa2,
Ahmed Ghazyfe9c3bb2020-11-26 15:29:48 +020043`endif
Tim Edwards53d92182020-10-11 21:47:40 -040044
45 input caravel_clk,
Tim Edwards7a8cbb12020-10-12 11:32:11 -040046 input caravel_clk2,
Tim Edwards53d92182020-10-11 21:47:40 -040047 input caravel_rstn,
48 input mprj_cyc_o_core,
49 input mprj_stb_o_core,
50 input mprj_we_o_core,
51 input [3:0] mprj_sel_o_core,
52 input [31:0] mprj_adr_o_core,
53 input [31:0] mprj_dat_o_core,
Tim Edwards43e5c602020-11-19 15:59:50 -050054
55 // All signal in/out directions are the reverse of the signal
56 // names at the buffer intrface.
57
58 output [127:0] la_data_in_mprj,
59 input [127:0] la_data_out_mprj,
60 input [127:0] la_oen_mprj,
61
62 input [127:0] la_data_out_core,
63 output [127:0] la_data_in_core,
64 output [127:0] la_oen_core,
Tim Edwards53d92182020-10-11 21:47:40 -040065
66 output user_clock,
Tim Edwards7a8cbb12020-10-12 11:32:11 -040067 output user_clock2,
Tim Edwards53d92182020-10-11 21:47:40 -040068 output user_resetn,
Ahmed Ghazy69663c72020-11-18 20:15:53 +020069 output user_reset,
Tim Edwards53d92182020-10-11 21:47:40 -040070 output mprj_cyc_o_user,
71 output mprj_stb_o_user,
72 output mprj_we_o_user,
73 output [3:0] mprj_sel_o_user,
74 output [31:0] mprj_adr_o_user,
75 output [31:0] mprj_dat_o_user,
Tim Edwards05ad4fc2020-10-19 22:12:33 -040076 output user1_vcc_powergood,
77 output user2_vcc_powergood,
78 output user1_vdd_powergood,
79 output user2_vdd_powergood
Tim Edwards53d92182020-10-11 21:47:40 -040080);
81
Tim Edwards43e5c602020-11-19 15:59:50 -050082 wire [458:0] mprj_logic1;
83 wire mprj2_logic1;
Tim Edwards05ad4fc2020-10-19 22:12:33 -040084
85 wire mprj_vdd_logic1_h;
86 wire mprj2_vdd_logic1_h;
87 wire mprj_vdd_logic1;
88 wire mprj2_vdd_logic1;
89
90 wire user1_vcc_powergood;
91 wire user2_vcc_powergood;
92 wire user1_vdd_powergood;
93 wire user2_vdd_powergood;
Tim Edwards53d92182020-10-11 21:47:40 -040094
Tim Edwards4518c622020-11-19 17:44:25 -050095 wire [127:0] la_data_in_mprj_bar;
96
Tim Edwards43e5c602020-11-19 15:59:50 -050097 sky130_fd_sc_hd__conb_1 mprj_logic_high [458:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +020098`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -040099 .VPWR(vccd1),
100 .VGND(vssd1),
101 .VPB(vccd1),
102 .VNB(vssd1),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200103`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400104 .HI(mprj_logic1),
105 .LO()
106 );
107
Tim Edwards32d05422020-10-19 19:43:52 -0400108 sky130_fd_sc_hd__conb_1 mprj2_logic_high (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200109`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400110 .VPWR(vccd2),
111 .VGND(vssd2),
112 .VPB(vccd2),
113 .VNB(vssd2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200114`endif
Tim Edwards32d05422020-10-19 19:43:52 -0400115 .HI(mprj2_logic1),
116 .LO()
117 );
118
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400119 // Logic high in the VDDA (3.3V) domains
120
Tim Edwardsbc035512020-11-23 11:16:08 -0500121 mgmt_protect_hv powergood_check (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200122`ifdef USE_POWER_PINS
Tim Edwardsbc035512020-11-23 11:16:08 -0500123 .vccd(vccd),
124 .vssd(vssd),
125 .vdda1(vdda1),
126 .vssa1(vssa1),
127 .vdda2(vdda2),
128 .vssa2(vssa2),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200129`endif
Tim Edwardsbc035512020-11-23 11:16:08 -0500130 .mprj_vdd_logic1(mprj_vdd_logic1),
131 .mprj2_vdd_logic1(mprj2_vdd_logic1)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400132 );
133
Tim Edwards32d05422020-10-19 19:43:52 -0400134
Tim Edwards43e5c602020-11-19 15:59:50 -0500135 // Buffering from the user side to the management side.
136 // NOTE: This is intended to be better protected, by a full
137 // chain of an lv-to-hv buffer followed by an hv-to-lv buffer.
138 // This serves as a placeholder until that configuration is
139 // checked and characterized. The function below forces the
140 // data input to the management core to be a solid logic 0 when
141 // the user project is powered down.
142
Tim Edwards4518c622020-11-19 17:44:25 -0500143 sky130_fd_sc_hd__nand2_4 user_to_mprj_in_gates [127:0] (
144`ifdef USE_POWER_PINS
145 .VPWR(vccd),
146 .VGND(vssd),
147 .VPB(vccd),
148 .VNB(vssd),
149`endif
150 .Y(la_data_in_mprj_bar),
151 .A(la_data_out_core),
152 .B(mprj_logic1[457:330])
153 );
154
155 sky130_fd_sc_hd__inv_8 user_to_mprj_in_buffers [127:0] (
Tim Edwards43e5c602020-11-19 15:59:50 -0500156`ifdef USE_POWER_PINS
157 .VPWR(vccd),
158 .VGND(vssd),
159 .VPB(vccd),
160 .VNB(vssd),
161`endif
162 .Y(la_data_in_mprj),
Tim Edwards4518c622020-11-19 17:44:25 -0500163 .A(la_data_in_mprj_bar)
Tim Edwards43e5c602020-11-19 15:59:50 -0500164 );
165
166 // The remaining circuitry guards against the management
167 // SoC dumping current into the user project area when
168 // the user project area is powered down.
169
Tim Edwards53d92182020-10-11 21:47:40 -0400170 sky130_fd_sc_hd__einvp_8 mprj_rstn_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200171`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400172 .VPWR(vccd),
173 .VGND(vssd),
174 .VPB(vccd),
175 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200176`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400177 .Z(user_resetn),
178 .A(~caravel_rstn),
179 .TE(mprj_logic1[0])
180 );
181
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200182 assign user_reset = ~user_resetn;
183
Tim Edwards53d92182020-10-11 21:47:40 -0400184 sky130_fd_sc_hd__einvp_8 mprj_clk_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200185`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400186 .VPWR(vccd),
187 .VGND(vssd),
188 .VPB(vccd),
189 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200190`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400191 .Z(user_clock),
192 .A(~caravel_clk),
193 .TE(mprj_logic1[1])
194 );
195
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400196 sky130_fd_sc_hd__einvp_8 mprj_clk2_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200197`ifdef USE_POWER_PINS
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400198 .VPWR(vccd),
199 .VGND(vssd),
200 .VPB(vccd),
201 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200202`endif
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400203 .Z(user_clock2),
204 .A(~caravel_clk2),
205 .TE(mprj_logic1[2])
206 );
207
Tim Edwards53d92182020-10-11 21:47:40 -0400208 sky130_fd_sc_hd__einvp_8 mprj_cyc_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200209`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400210 .VPWR(vccd),
211 .VGND(vssd),
212 .VPB(vccd),
213 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200214`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400215 .Z(mprj_cyc_o_user),
216 .A(~mprj_cyc_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400217 .TE(mprj_logic1[3])
Tim Edwards53d92182020-10-11 21:47:40 -0400218 );
219
220 sky130_fd_sc_hd__einvp_8 mprj_stb_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200221`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400222 .VPWR(vccd),
223 .VGND(vssd),
224 .VPB(vccd),
225 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200226`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400227 .Z(mprj_stb_o_user),
228 .A(~mprj_stb_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400229 .TE(mprj_logic1[4])
Tim Edwards53d92182020-10-11 21:47:40 -0400230 );
231
232 sky130_fd_sc_hd__einvp_8 mprj_we_buf (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200233`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400234 .VPWR(vccd),
235 .VGND(vssd),
236 .VPB(vccd),
237 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200238`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400239 .Z(mprj_we_o_user),
240 .A(~mprj_we_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400241 .TE(mprj_logic1[5])
Tim Edwards53d92182020-10-11 21:47:40 -0400242 );
243
244 sky130_fd_sc_hd__einvp_8 mprj_sel_buf [3:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200245`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400246 .VPWR(vccd),
247 .VGND(vssd),
248 .VPB(vccd),
249 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200250`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400251 .Z(mprj_sel_o_user),
252 .A(~mprj_sel_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400253 .TE(mprj_logic1[9:6])
Tim Edwards53d92182020-10-11 21:47:40 -0400254 );
255
256 sky130_fd_sc_hd__einvp_8 mprj_adr_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200257`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400258 .VPWR(vccd),
259 .VGND(vssd),
260 .VPB(vccd),
261 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200262`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400263 .Z(mprj_adr_o_user),
264 .A(~mprj_adr_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400265 .TE(mprj_logic1[41:10])
Tim Edwards53d92182020-10-11 21:47:40 -0400266 );
267
268 sky130_fd_sc_hd__einvp_8 mprj_dat_buf [31:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200269`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400270 .VPWR(vccd),
271 .VGND(vssd),
272 .VPB(vccd),
273 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200274`endif
Tim Edwards53d92182020-10-11 21:47:40 -0400275 .Z(mprj_dat_o_user),
276 .A(~mprj_dat_o_core),
Tim Edwards7a8cbb12020-10-12 11:32:11 -0400277 .TE(mprj_logic1[73:42])
Tim Edwards53d92182020-10-11 21:47:40 -0400278 );
279
Tim Edwards43e5c602020-11-19 15:59:50 -0500280 /* Project data out from the managment side to the user project */
281 /* area when the user project is powered down. */
Tim Edwards53d92182020-10-11 21:47:40 -0400282
283 sky130_fd_sc_hd__einvp_8 la_buf [127:0] (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200284`ifdef USE_POWER_PINS
Tim Edwards53d92182020-10-11 21:47:40 -0400285 .VPWR(vccd),
286 .VGND(vssd),
287 .VPB(vccd),
288 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200289`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500290 .Z(la_data_in_core),
291 .A(~la_data_out_mprj),
292 .TE(mprj_logic1[201:74])
Tim Edwards53d92182020-10-11 21:47:40 -0400293 );
294
Tim Edwards43e5c602020-11-19 15:59:50 -0500295 /* Project data out enable (bar) from the managment side to the */
296 /* user project area when the user project is powered down. */
297
298 sky130_fd_sc_hd__einvp_8 user_to_mprj_oen_buffers [127:0] (
299`ifdef USE_POWER_PINS
300 .VPWR(vccd),
301 .VGND(vssd),
302 .VPB(vccd),
303 .VNB(vssd),
304`endif
305 .Z(la_oen_core),
306 .A(~la_oen_mprj),
307 .TE(mprj_logic1[329:202])
308 );
309
Tim Edwards32d05422020-10-19 19:43:52 -0400310 /* The conb cell output is a resistive connection directly to */
311 /* the power supply, so when returning the user1_powergood */
312 /* signal, make sure that it is buffered properly. */
313
314 sky130_fd_sc_hd__buf_8 mprj_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200315`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400316 .VPWR(vccd),
317 .VGND(vssd),
318 .VPB(vccd),
319 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200320`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500321 .A(mprj_logic1[458]),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400322 .X(user1_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400323 );
324
325 sky130_fd_sc_hd__buf_8 mprj2_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200326`ifdef USE_POWER_PINS
Tim Edwards32d05422020-10-19 19:43:52 -0400327 .VPWR(vccd),
328 .VGND(vssd),
329 .VPB(vccd),
330 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200331`endif
Tim Edwards43e5c602020-11-19 15:59:50 -0500332 .A(mprj2_vdd_logic1),
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400333 .X(user2_vcc_powergood)
Tim Edwards32d05422020-10-19 19:43:52 -0400334 );
335
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400336 sky130_fd_sc_hd__buf_8 mprj_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200337`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400338 .VPWR(vccd),
339 .VGND(vssd),
340 .VPB(vccd),
341 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200342`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400343 .A(mprj_vdd_logic1),
Tim Edwards581068f2020-11-19 12:45:25 -0500344 .X(user1_vdd_powergood)
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400345 );
346
347 sky130_fd_sc_hd__buf_8 mprj2_vdd_pwrgood (
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200348`ifdef USE_POWER_PINS
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400349 .VPWR(vccd),
350 .VGND(vssd),
351 .VPB(vccd),
352 .VNB(vssd),
Ahmed Ghazy69663c72020-11-18 20:15:53 +0200353`endif
Tim Edwards05ad4fc2020-10-19 22:12:33 -0400354 .A(mprj2_vdd_logic1),
355 .X(user2_vdd_powergood)
356 );
Tim Edwards53d92182020-10-11 21:47:40 -0400357endmodule
Tim Edwards581068f2020-11-19 12:45:25 -0500358`default_nettype wire