Using CD4000_v.lib and 74hc.lib in LTSpice

So, I was simulating a circuit in LTSpice and I wanted to use an 4000-series IC. Someone probably did that before, right? So I googled and found quite some posts mentioning the CD4000.lib or CD4000_v.lib library. But a lot of people are having quite some trouble using it. And soon I had the same issues and did not understand sh*t.

So let me quickly guide you through the steps that made this damn library work for me (without me necessarily understanding everything that is going on).

(The procedure is *exactly* the same for 74hc.lib, the only difference is to replace “VDD” with “VCC” everywhere.)

  • Download CD4000_v.lib here and save it into your SPICE project folder as “CD4000_v.lib”. If you already have CD4000.lib (without the “_v”) then throw it away. Those two are different with respect to the VDD connection.
  • Open LTSpice, click on File/Open and then open “CD4000_v.lib”. Choose “All Files” in the lower right corner of the menu.
  • Scroll through the .lib file and find the definition (“.SUBCKT”) of the gate that you want to use. In our example we want to create a 4013 D-FlipFlop. Right-click on this line and select “Create Symbol” from the context menu
  • Edit the autogenerated symbol in the following way (CTRL+A opens the “Symbol Attribute Editor”):
    • edit the “SpiceModel” line, and enter “VDD 0”
    • change the “SpiceLine” line to “VDD=5 SPEED=1.0 TRIPDT=1e-9”
    • delete the absolute path in “ModelFile”, it should only read “CD4000_v.lib”
    • lastly change “Symbol Type” from “Block” to “Cell”
    • close the Attribute Editor and delete the GND and the VDD pin (sounds weird, but do it!). The delete button does not work in the symbol editor, do right-click and then select “delete” from the context menu.
  • Now click on File/Save As and save a copy of this symbol in your project directory (e.g. “/path/to/project/CD4013B.asy”)
  • Now go to your main SPICE simulation file and add a component. Don’t take a symbol from the symbol lib, but choose your project directory from the “Top Directory” dropdown menu. Now select the symbol you just created and insert it into your simulation sheet.
  • Create a voltage source with the desired operating voltage (e.g. 5V or 3.3V) and put a net label with the name “VDD” on that voltage. This will be the VDD of all your 4000-series ICs. Likewise, all 4000 ICs are automatically connected to GND.
  • You should probably also change VDD to 3.3 in the SPICE attribute line underneath the IC symbol if you use 3.3V. However, it does not seem to make a big difference.
  • You are ready to go. Simulate your circuit. If the ICs are reacting too slowly, you can change the SPEED parameter from 1.0 to 0.1, then they operate in the nanosecond regime. Yes – smaller “SPEED” parameter means faster *speed*, confusing, I know. The TRIPDT parameter, however, does not influence the steepness of your edges (but the propagation delay through the gates … or something).
  • You can download the example project (LTSpice sheet and symbols) HERE.

One response to “Using CD4000_v.lib and 74hc.lib in LTSpice

  1. Pingback: Using CD4000_V.LIB and 74HC.LIB in LTSpice #EE « Adafruit Industries – Makers, hackers, artists, designers and engineers!·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.