agorararmard | 6c766a8 | 2020-12-10 18:13:12 +0200 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: 2020 Efabless Corporation |
agorararmard | e5780bf | 2020-12-09 21:27:56 +0000 | [diff] [blame] | 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. |
agorararmard | afa96ea | 2020-12-09 23:37:31 +0200 | [diff] [blame] | 14 | // SPDX-License-Identifier: Apache-2.0 |
agorararmard | e5780bf | 2020-12-09 21:27:56 +0000 | [diff] [blame] | 15 | |
Matt Venn | 08cd6eb | 2020-11-16 12:01:14 +0100 | [diff] [blame] | 16 | `default_nettype none |
Tim Edwards | 21a9aac | 2020-10-12 22:05:18 -0400 | [diff] [blame] | 17 | `timescale 1 ns / 1 ps |
| 18 | |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 19 | module simple_por( |
Ahmed Ghazy | 27200e9 | 2020-11-25 22:07:02 +0200 | [diff] [blame] | 20 | `ifdef USE_POWER_PINS |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 21 | inout vdd3v3, |
| 22 | inout vdd1v8, |
| 23 | inout vss, |
Ahmed Ghazy | 27200e9 | 2020-11-25 22:07:02 +0200 | [diff] [blame] | 24 | `endif |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 25 | output porb_h, |
| 26 | output porb_l, |
| 27 | output por_l |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 28 | ); |
| 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 Edwards | 21a9aac | 2020-10-12 22:05:18 -0400 | [diff] [blame] | 38 | inode <= 1'b0; |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 39 | end |
| 40 | |
| 41 | // Emulate current source on capacitor as a 500ns delay either up or |
Tim Edwards | 1070832 | 2020-11-20 13:55:57 -0500 | [diff] [blame] | 42 | // down. Note that this is sped way up for verilog simulation; the |
| 43 | // actual circuit is set to a 15ms delay. |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 44 | |
| 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 Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 54 | sky130_fd_sc_hvl__schmittbuf_1 hystbuf1 ( |
| 55 | `ifdef USE_POWER_PINS |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 56 | .VPWR(vdd3v3), |
| 57 | .VGND(vss), |
| 58 | .VPB(vdd3v3), |
| 59 | .VNB(vss), |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 60 | `endif |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 61 | .A(inode), |
| 62 | .X(mid) |
| 63 | ); |
| 64 | |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 65 | sky130_fd_sc_hvl__schmittbuf_1 hystbuf2 ( |
| 66 | `ifdef USE_POWER_PINS |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 67 | .VPWR(vdd3v3), |
| 68 | .VGND(vss), |
| 69 | .VPB(vdd3v3), |
| 70 | .VNB(vss), |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 71 | `endif |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 72 | .A(mid), |
| 73 | .X(porb_h) |
| 74 | ); |
| 75 | |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 76 | 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 Edwards | 581068f | 2020-11-19 12:45:25 -0500 | [diff] [blame] | 90 | assign por_l = ~porb_l; |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 91 | endmodule |
Tim Edwards | 581068f | 2020-11-19 12:45:25 -0500 | [diff] [blame] | 92 | `default_nettype wire |