skywater-pdk icon indicating copy to clipboard operation
skywater-pdk copied to clipboard

Incorrect Bias Pin Relation in sky130_fd_sc_hd Generated Liberty Files

Open stdavids opened this issue 4 years ago • 15 comments

Expected Behavior

For a standard unbiased CMOS gate, the body pin of pfet transistors are usually tied to power and the body pin of nfet transistors are usually tied to ground. In sky130, VNB and VPB the net names for the body pins for nfet and pfet transistors respectively, as can be seen in the spice model for the sk130_fd_sc_hd library's inv_1 cell:

https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_fd_sc_hd/+/refs/heads/master/cells/inv/sky130_fd_sc_hd__inv_1.spice#19

X0 VGND A Y VNB sky130_fd_pr__nfet_01v8 w=650000u l=150000u
X1 VPWR A Y VPB sky130_fd_pr__pfet_01v8_hvt w=1e+06u l=150000u

Shown here, VNB is the body connection for sky130_fd_pr__nfet_01v8 (nfet) and VPB is the body connection for sky130_fd_pr__pfet_01v8_hvt (pfet).

Therefore, inside the sk130_fd_sc_hd library's generated lib files I expected to see the the related bias pin for VPWR be VPB, and the related bias pin for VGND be VNB.

Actual Behavior

What I am actually seeing is the opposite, where VPB is being related to ground and VNW is being related to power.

https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_fd_sc_hd/+/refs/heads/master/cells/inv/sky130_fd_sc_hd__inv_1__tt_025C_1v80.lib.json#17

"pg_pin,VGND": {
    "pg_type": "primary_ground",
    "related_bias_pin": "VPB",
    "voltage_name": "VGND"
  },

https://foss-eda-tools.googlesource.com/skywater-pdk/libs/sky130_fd_sc_hd/+/refs/heads/master/cells/inv/sky130_fd_sc_hd__inv_1__tt_025C_1v80.lib.json#32

"pg_pin,VPWR": {
    "pg_type": "primary_power",
    "related_bias_pin": "VNB",
    "voltage_name": "VPWR"
  },

Here the related_bias_pin for VGND is VPB and the related_bias_pin for VPWR is VNB which is the opposite of what I expected. I have shown this for inv_1 however this swap holds true for many (maybe all?) of the cells in this library.

Steps to Reproduce the Problem

Visually inspect the links provided.

Specifications

stdavids avatar Dec 26 '20 23:12 stdavids

Hi @stdavids I was confused as well: usually VNW is the pin connected to Nwell but here it is called VPB. Similarly, VPW is the pin for Pwell, and here it is VNB. So you are right, they are inverted in the .lib. I have corrected this locally but hopefully, @mithro / @RTimothyEdwards could fix that here.

msaligane avatar Dec 28 '20 18:12 msaligane

Seems related to: #183

20Mhz avatar Dec 29 '20 13:12 20Mhz

@RTimothyEdwards - Can you confirm?

mithro avatar Dec 29 '20 22:12 mithro

@mithro : Yes, I can confirm. Apparently every single liberty file is incorrect. "related_bias_pin" is swapped. It's wrong in the .lib.json files. I don't know the full path from the skywater-src-nda; "related_bias_pin" is not in skywater-src-nda, so it gets inserted somewhere in the build flow.

RTimothyEdwards avatar Dec 30 '20 04:12 RTimothyEdwards

@msaligane Could you share your local fix?

robtaylor avatar Apr 02 '21 09:04 robtaylor

@robtaylor see attached sky130_fd_sc_hd__tt_025C_1v80.zip

msaligane avatar Apr 02 '21 22:04 msaligane

Thank you!

robtaylor avatar Apr 03 '21 09:04 robtaylor

@msaligane did you write any script to fix it? Or what procedure did you follow?

thesukantadey avatar Apr 05 '21 09:04 thesukantadey

I've got a script attached here, unzip and execute in libraries/sky130_fd_sc_hd/latest with git grep -l "related_bias_pin" | xargs -n1 fixup.sh

fixup.sh.gz

Also my tweaked repo can be found at https://github.com/robtaylor/skywater-pdk-libs-sky130_fd_sc_hd/tree/fixes/288

robtaylor avatar Apr 05 '21 23:04 robtaylor

This seems to work however, there is an issue with a few cells: 'sky130_fd_sc_hd__dlclkp_1', dlclkp and sdlclkp cells

Error: Line 57389, Cell 'sky130_fd_sc_hd__dlclkp_1', pin 'M0', An invalid attribute 'related_ground_pin' is found.

I fixed this using 2 different solutions:

  • change related_ground_pin : "VNB"; to related_ground_pin : "VGND";

current:

pin ("M0") {
    direction : "internal";
    internal_node : "M0";
    **related_ground_pin : "VNB";**
    related_power_pin : "VPWR";
}

What works:

pin ("M0") {
    direction : "internal";
    internal_node : "M0";
    **related_ground_pin : "VGND";**
    related_power_pin : "VPWR";
}

The other way that would fix the M0 pin issue and I think it is the original way of declaring pg_pin(VNB):

pg_pin (VNB) {
    pg_type : "primary_ground";
    voltage_name : "VNB";
}

after the fix discussed above:

pg_pin ("VNB") {
    pg_type : "pwell";
    physical_connection : "device_layer";
    voltage_name : "VNB";
}

@robtaylor I hope this makes sense..

msaligane avatar Apr 08 '21 23:04 msaligane

@msaligane any thoughts on which is the most 'correct' approach?

robtaylor avatar Apr 09 '21 17:04 robtaylor

tweaked script for 1st approach: fixup.sh.gz and tweaked repo again here: https://github.com/robtaylor/skywater-pdk-libs-sky130_fd_sc_hd/tree/fixes/288

robtaylor avatar Apr 09 '21 17:04 robtaylor

@robtaylor : Definitely "VNB" should be "pwell" and not "primary_ground", and all "related_ground_pin" entries should be "VGND".

RTimothyEdwards avatar Apr 09 '21 17:04 RTimothyEdwards

Thank you @RTimothyEdwards, it's good to know i'm on the right path - I'm pretty much flying blind here!

When this is working, what's the best way to submit a PR? - against https://github.com/google/skywater-pdk-libs-sky130_fd_sc_hd ?

robtaylor avatar Apr 09 '21 17:04 robtaylor

@robtaylor : There is, unfortunately, as yet no way to submit a pull request. Only @mithro knows when that will happen.

RTimothyEdwards avatar Apr 09 '21 20:04 RTimothyEdwards