blob: 8168c0bb02e056da29ebfa41e60fb3d94dad4d0e [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 Edwards21a9aac2020-10-12 22:05:18 -040017`timescale 1 ns / 1 ps
18
Tim Edwardsf51dd082020-10-05 16:30:24 -040019module simple_por(
Ahmed Ghazy27200e92020-11-25 22:07:02 +020020`ifdef USE_POWER_PINS
Ahmed Ghazy69663c72020-11-18 20:15:53 +020021 inout vdd3v3,
22 inout vdd1v8,
23 inout vss,
Ahmed Ghazy27200e92020-11-25 22:07:02 +020024`endif
Ahmed Ghazy69663c72020-11-18 20:15:53 +020025 output porb_h,
26 output porb_l,
27 output por_l
Tim Edwardsf51dd082020-10-05 16:30:24 -040028);
29
30 wire mid, porb_h;
31 reg inode;
32
33 // This is a behavioral model! Actual circuit is a resitor dumping
34 // current (slowly) from vdd3v3 onto a capacitor, and this fed into
35 // two schmitt triggers for strong hysteresis/glitch tolerance.
36
37 initial begin
Tim Edwards21a9aac2020-10-12 22:05:18 -040038 inode <= 1'b0;
Tim Edwardsf51dd082020-10-05 16:30:24 -040039 end
40
41 // Emulate current source on capacitor as a 500ns delay either up or
Tim Edwards10708322020-11-20 13:55:57 -050042 // down. Note that this is sped way up for verilog simulation; the
43 // actual circuit is set to a 15ms delay.
Tim Edwardsf51dd082020-10-05 16:30:24 -040044
45 always @(posedge vdd3v3) begin
46 #500 inode <= 1'b1;
47 end
48 always @(negedge vdd3v3) begin
49 #500 inode <= 1'b0;
50 end
51
52 // Instantiate two shmitt trigger buffers in series
53
Ahmed Ghazy69663c72020-11-18 20:15:53 +020054 sky130_fd_sc_hvl__schmittbuf_1 hystbuf1 (
55`ifdef USE_POWER_PINS
Tim Edwardsf51dd082020-10-05 16:30:24 -040056 .VPWR(vdd3v3),
57 .VGND(vss),
58 .VPB(vdd3v3),
59 .VNB(vss),
Ahmed Ghazy69663c72020-11-18 20:15:53 +020060`endif
Tim Edwardsf51dd082020-10-05 16:30:24 -040061 .A(inode),
62 .X(mid)
63 );
64
Ahmed Ghazy69663c72020-11-18 20:15:53 +020065 sky130_fd_sc_hvl__schmittbuf_1 hystbuf2 (
66`ifdef USE_POWER_PINS
Tim Edwardsf51dd082020-10-05 16:30:24 -040067 .VPWR(vdd3v3),
68 .VGND(vss),
69 .VPB(vdd3v3),
70 .VNB(vss),
Ahmed Ghazy69663c72020-11-18 20:15:53 +020071`endif
Tim Edwardsf51dd082020-10-05 16:30:24 -040072 .A(mid),
73 .X(porb_h)
74 );
75
Ahmed Ghazy69663c72020-11-18 20:15:53 +020076 sky130_fd_sc_hvl__lsbufhv2lv_1 porb_level (
77`ifdef USE_POWER_PINS
78 .VPWR(vdd3v3),
79 .VPB(vdd3v3),
80 .LVPWR(vdd1v8),
81 .VNB(vss),
82 .VGND(vss),
83`endif
84 .A(porb_h),
85 .X(porb_l)
86 );
87
88 // since this is behavioral anyway, but this should be
89 // replaced by a proper inverter
Tim Edwards581068f2020-11-19 12:45:25 -050090 assign por_l = ~porb_l;
Tim Edwardsf51dd082020-10-05 16:30:24 -040091endmodule
Tim Edwards581068f2020-11-19 12:45:25 -050092`default_nettype wire