Matt Venn | 08cd6eb | 2020-11-16 12:01:14 +0100 | [diff] [blame] | 1 | `default_nettype none |
Tim Edwards | 21a9aac | 2020-10-12 22:05:18 -0400 | [diff] [blame] | 2 | `timescale 1 ns / 1 ps |
| 3 | |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 4 | module simple_por( |
Ahmed Ghazy | 27200e9 | 2020-11-25 22:07:02 +0200 | [diff] [blame] | 5 | `ifdef USE_POWER_PINS |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 6 | inout vdd3v3, |
| 7 | inout vdd1v8, |
| 8 | inout vss, |
Ahmed Ghazy | 27200e9 | 2020-11-25 22:07:02 +0200 | [diff] [blame] | 9 | `endif |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 10 | output porb_h, |
| 11 | output porb_l, |
| 12 | output por_l |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 13 | ); |
| 14 | |
| 15 | wire mid, porb_h; |
| 16 | reg inode; |
| 17 | |
| 18 | // This is a behavioral model! Actual circuit is a resitor dumping |
| 19 | // current (slowly) from vdd3v3 onto a capacitor, and this fed into |
| 20 | // two schmitt triggers for strong hysteresis/glitch tolerance. |
| 21 | |
| 22 | initial begin |
Tim Edwards | 21a9aac | 2020-10-12 22:05:18 -0400 | [diff] [blame] | 23 | inode <= 1'b0; |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 24 | end |
| 25 | |
| 26 | // Emulate current source on capacitor as a 500ns delay either up or |
Tim Edwards | 1070832 | 2020-11-20 13:55:57 -0500 | [diff] [blame] | 27 | // down. Note that this is sped way up for verilog simulation; the |
| 28 | // actual circuit is set to a 15ms delay. |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 29 | |
| 30 | always @(posedge vdd3v3) begin |
| 31 | #500 inode <= 1'b1; |
| 32 | end |
| 33 | always @(negedge vdd3v3) begin |
| 34 | #500 inode <= 1'b0; |
| 35 | end |
| 36 | |
| 37 | // Instantiate two shmitt trigger buffers in series |
| 38 | |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 39 | sky130_fd_sc_hvl__schmittbuf_1 hystbuf1 ( |
| 40 | `ifdef USE_POWER_PINS |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 41 | .VPWR(vdd3v3), |
| 42 | .VGND(vss), |
| 43 | .VPB(vdd3v3), |
| 44 | .VNB(vss), |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 45 | `endif |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 46 | .A(inode), |
| 47 | .X(mid) |
| 48 | ); |
| 49 | |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 50 | sky130_fd_sc_hvl__schmittbuf_1 hystbuf2 ( |
| 51 | `ifdef USE_POWER_PINS |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 52 | .VPWR(vdd3v3), |
| 53 | .VGND(vss), |
| 54 | .VPB(vdd3v3), |
| 55 | .VNB(vss), |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 56 | `endif |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 57 | .A(mid), |
| 58 | .X(porb_h) |
| 59 | ); |
| 60 | |
Ahmed Ghazy | 69663c7 | 2020-11-18 20:15:53 +0200 | [diff] [blame] | 61 | sky130_fd_sc_hvl__lsbufhv2lv_1 porb_level ( |
| 62 | `ifdef USE_POWER_PINS |
| 63 | .VPWR(vdd3v3), |
| 64 | .VPB(vdd3v3), |
| 65 | .LVPWR(vdd1v8), |
| 66 | .VNB(vss), |
| 67 | .VGND(vss), |
| 68 | `endif |
| 69 | .A(porb_h), |
| 70 | .X(porb_l) |
| 71 | ); |
| 72 | |
| 73 | // since this is behavioral anyway, but this should be |
| 74 | // replaced by a proper inverter |
Tim Edwards | 581068f | 2020-11-19 12:45:25 -0500 | [diff] [blame] | 75 | assign por_l = ~porb_l; |
Tim Edwards | f51dd08 | 2020-10-05 16:30:24 -0400 | [diff] [blame] | 76 | endmodule |
Tim Edwards | 581068f | 2020-11-19 12:45:25 -0500 | [diff] [blame] | 77 | `default_nettype wire |