Tuesday, August 18, 2026

svn add everything that starts with ?

The white space always gets me. SVN to add all unversioned files:

svn status | sed -n 's/^?       //p' | while IFS= read -r f; do svn add -- "$f"; done

Wednesday, July 29, 2026

macportseda: open-source EDA tools on macOS that I use for SKY130.

I put together a MacPorts port tree for the open-source EDA tools I use, and I've been running it on macOS 13, 15, and 26 on arm64. It's called macportseda and it's up on GitHub: https://github.com/bpdegnan/macportseda

My work is mostly analog and mixed-signal, and the tools I need either aren't in stock MacPorts or the versions that are there don't fit together into a working flow. I wanted an open ADC design flow that runs on a Mac without Docker or a Linux VM, so I packaged the pieces myself.

What's in it right now: OpenSTA, KLayout, Magic, netgen (LVS), xschem, ngspice, OpenVAF, Yosys, OpenROAD, KiCad, the Xyce/Trilinos/Charon TCAD stack, and most recently CACE for analog characterization, plus the smaller glue tools around them. There's a metaport, eda-icall, that pulls the whole sky130 toolchain in one command.

It coexists with stock MacPorts instead of fighting it; where I need a pinned version that would collide, it installs into a private prefix. Every source tarball is checksummed and archived locally, because upstream URLs rot. And when a build fails, the ports point you at a GitHub issue on my repo instead of the MacPorts maintainers, since these aren't official ports.

Once the tree's path is registered in /opt/local/etc/macports/sources.conf (above the rsync line), the whole toolchain is one command:

  cd macportseda
  portindex
  sudo port install eda-icall

I'm a hardware person, not a software engineer, and I'm still bad at git. This tree is maintained for one user, me, so versions are pinned on purpose and some staleness is fine. But if it's useful to you, it's all there.

Sunday, May 17, 2026

Add .tex files and .afdesign files to SVN.

I forgot that macos doesn't have "xargs -d"
svn status \
| awk '/^\?/ && ($2 ~ /\.(tex|afdesign)$/) {print substr($0,9)}' \
| tr '\n' '\0' | xargs -0 svn add

Tuesday, September 30, 2025

gtkwave update

My previous version of getting gtkwave working was fine, but the window didn't always refresh correctly.
sudo port install gtk2 +quartz 
sudo port install gtk-quartz-engine +quartz
sudo port install gtkwave +quartz  

Sunday, April 27, 2025

When you need the last 1MiB of a file.

MacOS/BSD doens't have the "head -c -1M" construct to get the last 1MiB of my file
filesize=$(stat -f %z main.log) && dd if=main.log bs=1 \ 
skip=$((filesize - 1048576)) > ~/chunk.log

Sunday, December 8, 2024

package management when you don't have root.

Sometimes, you don't have root. The bsd-style ports tree let's you do this.

https://github.com/bpdegnan/redbash is a project that I have been using to install my bsd-style tools on commerical systems.

Friday, August 9, 2024

Primewave can execute a script before the command runs.

I just found that Primewave can execute a script before the simulator runs. In the Setup->Simulator panel, there's a "command prefix" field that will execute a script on the command line.

Thursday, July 25, 2024

using ngspice with the skywater pdk.

I had a terrible time getting ngspice-43 working with skywater 130. There's some weird stuff in the PDK models, as it definitely is still the "IBM way". Firstly, you need to comment out any includes for any devices that aren't working in the sky130.lib.spice file. For me, it was all of the nfet_05v0_nvt devices.
* .include "../cells/nfet_05v0_nvt/sky130_fd_pr__nfet_05v0_nvt__tt.corner.spice"
The next issue is that "decks" have the devices have .models as a units of 1 meter. If you take a look at the sky130_fd_pr__nfet_01v8.pm3.spice file, you see how the subcircut (subckt) is generated.
.subckt  sky130_fd_pr__nfet_01v8 d g s b
+ 
.param  l = 1 w = 1 ad = 0 as = 0 pd = 0 ps = 0 nrd = 0 nrs = 0 sa = 0 sb = 0 sd = 0 mult = 1 nf = 1.0
msky130_fd_pr__nfet_01v8 d g s b sky130_fd_pr__nfet_01v8__model l = {l} w = {w} ad = {ad} as = {as} pd = {pd} ps = {ps} nrd = {nrd} nrs = {nrs} sa = {sa} sb = {sb} sd = {sd} nf = {nf}
.model sky130_fd_pr__nfet_01v8__model.0 nmos
This means that you need to create a .spiceinit file the same directory where you run the simulation. For me, I did this:
* .spiceinit for use with Skywater PDK and ngspice KLU
set ngbehavior=hsa     ; set compatibility for reading PDK libs
set skywaterpdk        ; skip some checks for faster lib loading
set ng_nomodcheck      ; don't check the model parameters
set num_threads=8      ; CPU processor cores available
option noinit          ; don't print operating point data
option klu             ; select KLU as matrix solver
optran 0 0 0 100p 2n 0 ; don't use dc operating point, but transient op%    
If you've gotten this far, this is how I did the whole thing. You need to install git, ngspice-43 and have some time download the 45GiB that is the skywater PDK.
git clone https://github.com/google/skywater-pdk.git
cd skywater-pdk
git checkout main
git submodule init
git submodule update
In the same directory as the .spiceinit file, I made this inverter.sp file:
* Inverter simulation using SkyWater 130nm PDK
.lib "$HOME/skywater-pdk/libraries/sky130_fd_pr/latest/models/sky130.lib.spice" tt
* Power supply
VDD VDD 0 1.8
* Input voltage source
VIN IN 0 PULSE(0 1.8 0 1n 1n 10n 20n)
* NMOS transistor
X1 OUT IN 0 0 sky130_fd_pr__nfet_01v8 
* PMOS transistor
X2 OUT IN VDD VDD sky130_fd_pr__pfet_01v8 
* Load capacitor
CL OUT 0 1p

.control
* Run transient analysis
tran 0.1n 50n
* plot v(IN) v(OUT)
* Save the results
wrdata inverter_simulation.raw v(IN) v(OUT)
.endc
.end
You will get some interesting warnings. This includes that a "scale" value is set somewhere to make the models based on nanometers, instead of meters. running "ngspice -b inverter.sp" yields:
degs@kazan inverter % ngspice -b inverter.sp
Warning: can't find the initialization file spinit.
Warning: Optran step size potentially too large.

Note: Compatibility modes selected: hs a

Warning: m=xx on .subckt line will override multiplier m hierarchy!


Circuit: * inverter simulation using skywater 130nm pdk

option SCALE: Scale is set to 1e-06 for instance and model parameters
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Using KLU as Direct Linear Solver
Note: Transient op started
Note: Transient op finished successfully
 Reference value :  0.00000e+00
No. of Data Rows : 535
Note: Simulation executed from .control section 
At this point, I used Python to read the raw file via "python plot.py inverter_simulation.raw" that is here:
import numpy as np
import matplotlib.pyplot as plt
import argparse

def read_and_plot(filename):
    # Load the data from the raw file
    data = np.loadtxt(filename)

    # Assuming the columns are:
    # Column 1: Time
    # Column 2: VIN
    # Column 3: Time again (redundant)
    # Column 4: VOUT

    time = data[:, 0]  # First column is time
    vin = data[:, 1]   # Second column is VIN
    vout = data[:, 3]  # Fourth column is VOUT

    # Plot the data
    plt.figure()
    plt.plot(time, vin, label='VIN')
    plt.plot(time, vout, label='VOUT')
    plt.xlabel('Time (s)')
    plt.ylabel('Voltage (V)')
    plt.title('Inverter Simulation')
    plt.legend()
    plt.grid(True)
    plt.show()

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Plot ngspice simulation data.')
    parser.add_argument('filename', type=str, help='Path to the raw data file')
    args = parser.parse_args()

    read_and_plot(args.filename)
The results are wrong as I buggered up the netlist; however, it is actually functioning. This is a day that I will not get back. The bad graph is:

Monday, July 22, 2024

macports, building with all of the cores.

I noticed that I wasn't building on "all cores" with macports. The build.jobs addition to the command line makes it build... much faster.
port install inkscape build.jobs=8

Friday, July 19, 2024

pianobar with macports

I got stumped with default settings using pianobar (text-based Pandora client) under MacOS with macports. pianobar is highly configurable; however, something moved since I did this the last time and things did not work. it seems as if the name of the config file changed from pianobar.cfg to config.

mkdir -p ~/.config/pianobar
touch ~/.config/pianobar/config

You then can put your name and password in the file, such as

user = your@user.name
password = password

There are whole bunch of configurations for pianobar, and I sometimes tweak them.
One of the other things that you can do is remove your password explicitly from the config file. I use this:

password_command = gpg --decrypt ~/password

Tuesday, January 30, 2024

IBM 130nm notes on LVS.

Back in 2007-ish, I helped teach a VLSI class at Georgia Tech that used IBM, now Global Foundaries, 130nm design kit. My academic webpages are long gone, but there are still scans of printouts of this old webpage and I get more questions about it from people all over the world. For that reason, here's most of the original document. I don't have the HSPICE lab description document that I wrote that this document references.

Okay, this is the quick and dirty overview of how to do IBM layout. There are some new tools and some new quirks, and this will cover DRC and LVC with Assura. The first thing which you should is copy my layers file to your working directory. Check out the ~degs/ece6130/ directory.
cp ~degs/ece6130/IBM.layers.degs ./_your_IBM_directory_

This will give you a managable subset of layers. Next, start up the kit as specificed in the HSPICE lab.

Adding the example library

I have made a test project, so you should first add it. From the "Library Manager" window, click on Edit->Library Path. You should get a dialog thta gives and edit lock error.

As multiple people can be working on the same project, Cadence only allows one person to edit things at a time regarding the libraries. You next need to get an exclusive lock.

Now that you have an exclusive lock, you can add my sample project to your library. The project is called "ex_assura".
~degs/ece6130
The above directory is where you should look for the ex_assura project.

After you add the direcotry, you should see it in the list.

You can then go to File->Save and save the new library path. You may then close the dialog.

Examining the example cell

You should see that in the "assura_ex" library, you have several cells. We will be introducing a few new layers to you, as well, how to manage the layers. There is a layer called "align" which you may use to put an alignment box around your cells which makes it easy to align them with respect to other cells. In the IBM toolkit, the "align" layer is white filled by default, which is annoying. Open up the layout for the NAND, and you should see the following image. I'll get to the big, horking white box in a moment.
In order to make this usable, we will introduce you to layer management, which is stored locally stored in the display.drf file in your startup directory. As should see in your layer map has more layers than you'd ever use. You might want to go to your layers window, and click on "Edit->Load", and then load the layers file which you copied in the begining of this tutorial. That will remove most of the layers which you won't be using.
note: you'll want to add and remove layers depending on your design decisions.
You can add and remove layers from the layers palette by going to the layers window and selecting "Edit->Set Valid Layers". The layers with "dg" next to them are the drawing layers. Generally, you'll need "dg" and "nt". You should go down the list and find the "align" layer and make sure that "dg" is set. The layer can be present on your screen, but you cannot select it unless you have it in your palette window!

Once you have found "align", you can then save the layers file. From here, you need to go to "Edit->Display Resource Editor" in the palette window. You can then change the fill style of the align layer. After you change the style, hit "apply" to update the information. You must then save in order to update the "display.drf" file which hold the layer information.

After you have saved your new display file, as soon as you update the layout window (pushing "f" for instance), you'll see that the align layer is no longer filed and it's just a white outline.

You have just learned how to leverage the display manager.

Layout

Gravity. Gravity is the reason that when you first open up the cell, that things are funny with your cursor. You need to turn it off if you want your pointer to actually go where you say for it to go. In the Virtuoso® (yeah, don't you love using software which reminds you that they've registered their quirks) layout window, go to "Options->Layout Editor" and then turn off "Gravity"; furthermore, I'd set the types to "none" as things don't always seem to obey without it.
Now that you have no gravity, and the layers aren't funny, you are set to go.
So, here's the introduction to new things. The new things live in the PDK->misc menu. The two options which you will use the most often are the "substrate contact based on RX" which is called "subc". This contact is your p-well tie down. The other contact is the "nwell contact based on RX", which is your nwell contact. As this a mixed mode process (analog is where the money is), there are some things which you need to do make things behave digitally. If you push "q" to bring up the properties window, and click around on the layers, you will notice a layer called "grlogic". The grlogic layer turns an analog process into something which goes by digital rules. For instance, if you are in "analog mode", subc is extracted and must be in your schematic. There is a cell called "NAND_analog" which you should open to see the differences in the schematics for identical layout.
We will assume that you can just look at what I've done, and then look at the example to get you started on your way to making your own cells. Assura is a good tool for DRC and LVS. It's slow for 10 transistors, but fast for 100000 when compared to DIVA DRC which you learned how to use the other labs. As usual, all of the magic happens from the PDK menu. You can feel free to try everything in that menu. "IBM_PDK->Checking" is where all of the checking tools live. I have made a broken cell for you already called "NAND_drcerror", you should open that cell up, and run DRC. Go to "IBM_PDK->Assura->DRC" to run DRC.

You will be asked if you want to overwrite old data possibly. The answer is yes, unless you and your partner are working out of the same account. If you are, you should change your "Run Directory" so that you don't step on each others toes. You probably want to make a run directory anyway so you don't have 1000 files in your project root. It will take a moment to fire up and you'll eventually get the following screen. You can either select what you want to look at, and then the update the layout window (via pressing "f" for example) to see the highlighted shapes. Alternatively, you can just hit "AV" for all view and then update the layout window to see everything highlighted at once. For specific errors, click on "View->Explain" and select which neon box of interest and a window will pop up which gives details about the error. Also, you may ignore any output which starts with: #INFO, it's only information.

On to LVS, I have made a cell called "NAND4_lvserror". This cell does not follow best-practices and if I find this in your turn-ins, you'll get what's coming to you because Mooney knows rubbish when he sees it; however, it's good to demonstrate LVS. Use the "IBM_PDK->Checking->Assura->LVS (VLDB) to start LVS.

Important things to do in this window.
As I mentioned before, this is an analog process, so in order to get the digital-style circuits during the extraction, you need to go to "Set Switches" and select "NO_SUBC_IN_GRLOGIC" to change the behavior of the extraction for parts inside the GRLOGIC layer. Also, for the "Run Directory", you should change it. You can see how I've setup things in the following image. Hit "Apply" and LVS will start. If you get an error, and it dumps you to the log file, start at the end of the file and look for the answer. The errors are very, very descriptive and they tell you how to fix the problem in 96% of the cases. Try that first before running to the TA. 5 minutes of searching will save you hours of waiting.

The cell will have errors. The error are listed by type, and you can double-click on the classifcations to bring up the tool. Notice that it suggest what should be doen to fix the error.

Alternatively, you can go to "View->LVS Error Report (Current Cell)" to bring up the net list of errors, and then you can select the names to highlight the mismatches on both the schematics and layout.

The cell updated to have no LVS errors is "NAND4". These examples should get you started down the right path. Thinks small first. Also, if you happen to use DIVA DRC (because someone will), you should note that you delete the markers by going to "Verify->Markers->Delete All" in the layout window.

Saturday, June 10, 2023

MacOS and some weird compile dependency to AppleTV.

Under macports, textmate2 had the strangest error.
2023-06-10 20:23:38.897 ibtoold[54317:595388] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error getting value for parameter key 'name' of extension 'Xcode.InterfaceBuilderKit.AppleTVIntegration.Singletons' in plug-in 'com.apple.dt.IDE.IDEInterfaceBuilderAppleTVIntegration'
I tracked it down to the fact that I was missing some of the extended resources. You can install them by running the package here:
/Applications/Xcode.app/Contents/Resources/Packages/XcodeSystemResources.pkg

Thursday, February 2, 2023

GTKwave under macports

This shouldn't have been hard, but there's a few steps that were not included in the Portfile.
sudo port install gtk2 +quartz 
sudo port install gtk-quartz-engine +quartz
sudo port install gtkwave +quartz  
I am unsure what the +quartz is needed, but it seems to be rather important.

Wednesday, January 4, 2023

python not found under debian

I tried to test something for python3 on a linux server with debian. python3 was supposedly installed, but it couldn't find it.
apt install python-is-python3
The above line fixed things...somehow...so they worked.

Sunday, January 1, 2023

MPLAB X IPE has a grey connect button under MacOS

I hadn't touched MPLAB-X for a year. I have a little PIC32 EK starter kit that I use for some automation. I was attempting to make a copy of the board that I had, and at some point, the IPE stopped "allowing" the connection to the board under MacOS.
So, what I figured, which turned out to be true is that a security policy overwrote the original privleges. I went into "Security and Privacy" and added the mplab-ipe application AND the java executalbe that it uses as a developer application.
After that, everything is fine.
...except that's 2 hours of my life that I'll never get back. I'm sure there's some log file that says what has been blocked via secuirty policy, but I've yet to find it. I even asked the "Internet".

Thursday, August 11, 2022

Changes between KiCad 5.x and 6.x

Overbar was ~CEN and is now ~{CEN1}
Libraries!  This is the biggest difference.
Pins can be on the top or bottom of hierachial sheets.
Hierachial sheets can be resized by "corners".

Wednesday, July 20, 2022

Remove a known key in .ssh/known_hosts

I couldn't use the ssh tools on the system for some reason. Also, it's not a system with a lot of gnu tools. They did have perl.
To remove line 21 from known_hosts, I settled on:
perl -pi -e 's/\Q$_// if ($. == 21);' ~/.ssh/known_hosts

Tuesday, June 7, 2022

vispy segfault

You never remember the difference between computers. Vispy wasn't working.

degs:vispi% python line-draw.py
zsh: segmentation fault  python line-draw.py

This doesn't give you much to go on. After diving into the debugger, I found that I had a bad binding from Python into the Qt5 library. I fixed it with:
sudo port install Qt5
pip install PyQt5 

Friday, October 29, 2021

debian didn't have the correct locale

This was one of those frustrating things.
root@mxg:~# update-locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_All = "C.UTF-8",
	LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I fixed it with this:
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; locale-gen en_US.UTF-8
After that, reconfigure dpkg
root@mxg:~# dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.