Magic IC Design Tool
Magic And Spice
David L. Huffman
What Is Magic?
In a nutshell, Magic is a graphical tool that a circuit designer uses to specify how an IC should be constructed. This specification is created by drawing rectangles which represent wires and transistors--the building blocks of most ICs. The rectangles are drawn in various colors and fill patterns which represent the layers used to manufacture the chip. (The ``layer'' concept is explained in more detail below.) The final drawing is usually referred to as the layout of the chip.
Don't be fooled--there's much more to designing an IC than simply making rectangles; otherwise, most any drawing program could do the job. IC design requires further assistance from the software. To that end, Magic is equipped with tools that make IC design easier. For example, it enforces design rules which guarantee that the circuit, as drawn, can be manufactured correctly, and it can extract a list of circuit components and how they're connected (a netlist) from a layout.
These capabilities help provide a basic introduction to Magic and how it's used to do real-world designs. In particular, we'll develop a simple digital circuit--an inverter, which is a ubiquitous building block for complex digital chips.
What is SPICE?
Magic is used to draw the rectangles in a layout, but how do we know that the circuit corresponding to these rectangles performs as desired? Simulation is a way to verify that the design you've drawn is actually the design you want--it's very much like using a debugger on a piece of software that you're developing. Why bother with simulation? Why not just draw it, build it, and see if it works? Simulation is necessary, because fabricating a chip is costly in a variety of ways. The manufacturing process itself is very expensive, so you want to minimize the number of times you must re-manufacture a defective design. It is also time-consuming, so you want to avoid missing a market window as a result of too many re-manufacturing cycles. Because of these costs, time invested in verifying a design through simulation pays back tremendous dividends.
One tool used to simulate circuit performance is SPICE (Simulation Program with Integrated Circuit Emphasis). Developed at the University of California at Berkeley in the mid-1970's, SPICE and its derivatives, notably PSpice from MicroSim Corporation and HSPICE from Meta-Software, are the most widely-used examples of analog circuit simulators. Using detailed models of the individual circuit components, these programs provide an accurate picture of the device's operation and can analyze many different aspects of a circuit's behavior. Later, we'll look at one aspect that is particularly useful in digital circuit design.
Magic has a WWW page (maintained by Bob Mayo of DEC's Western Research Laboratory) from which you can get source code and browse other relevant information. Point your favorite Web browser to http://www.research.digital.com/wrl/projects/magic/magic.html and follow the ``Getting the program and manuals'' link. Version 6.5 should be available and out of beta by the time you read this article.
Magic is installed in either the home directory of the user ``cad'' or the directory pointed to by the environment variable $CAD_HOME. You must either create a ``cad'' user and make its file space world-readable (assuming you want everyone to be able to run the tools), or designate a directory for the tools and set $CAD_HOME to point to it. We assume you'll choose the second method and refer to the directory specified by $CAD_HOME as the root of the directory tree in which the tools are installed.
After setting $CAD_HOME, untar magic-6.5.tar. Go to the magic-6.5 directory and enter make config. Choose options 1 (X11), 4 (Linux), 5 (Intel based systems, assuming you're on an Intel). Next is a list of optional modules. Leaving them out trades functionality for smaller executable size and compile time. For now, just accept all the optional modules. You can always recompile later if you find you don't use one feature or another. Then, following the instructions on the screen, do a make force to compile everything. After this compile finishes successfully, make install installs everything in the correct location. Don't skip this last step, because Magic depends on having all its support files in the right place.
The latest freely-available version of SPICE is 3f4. Linux-ready sources for SPICE3f4 are available at ftp://ftp.sunsite.edu/pub/Linux/apps/circuits/spice3f4.tar.gz. Compilation and installation instructions are in spice3f4.readme. Note that you must have at least version 1.14.5 of BASH in order to compile. When we compiled ours, we made only one change. We removed the -dWANT_X11 from the conf/linux file, and so did not get the X interface but did get smaller binaries. Since we are using Sigview to look at the the outputs, we don't need this interface anyway. If you don't feel like compiling, an a.out format binary is available at ftp://ftp.eos.ncsu.edu/pub/vlsi/software/Linux/spice3/.
Before getting into the details of designing with Magic, it's very helpful to have a basic understanding of the physical structure of an IC and the process by which it's constructed. There are many different types of process technologies--CMOS, GaAs, bipolar and BiCMOS are common ones. Today, CMOS (Complementary Metal Oxide Semiconductor) is the dominant technology for high-density, low-power, low-cost digital circuits; accordingly, we'll focus our examples on designing for CMOS. However, the concepts presented apply equally well to any process.
ICs are constructed by depositing, implanting or growing various materials in patterned layers on a silicon base. Several layers are stacked vertically atop one another; each is separated from the layer immediately above and below by a thin layer of insulating material. It's important to note that a layer can contain many separate objects--for example, it can contain thousands of wires, none of which touch one another.
How do IC manufacturers form the patterns? Typical manufacturing processes are similar to spray-painting, in that they coat the entire IC surface with the material used to make the layer; this obviously precludes the formation of distinct shapes or patterns. If you've ever used a template to spray-paint letters onto a poster or wall, you know that the solution to this problem is to get a piece of shielding, called a mask, cut out the areas you want to paint, and spray through the resulting holes. IC process engineers do the same thing on a vastly smaller scale.
Magic makes work easier for the designer by hiding much of this underlying physical complexity. Rather than work with mask layers directly, you manipulate abstract layers which implicitly represent one or more masks. For example, to create an m1 to m2 via, rather than draw three shapes on separate mask layers (the m1 layer, the hole layer and the m2 layer), you simply draw one shape on the abstract ``via'' layer, which has all three mask layers ``built-in''. There are also abstract layers having a one-to-one correspondence to mask layers; m1 and m2 are examples. In general, an abstract layer can represent an arbitrary number of mask layers, permitting a great simplification in design.
Lambda Rules and Scalability
In order to cram as much as possible onto the IC, modern processes define design rule measurements in microns, mm. A micron is one millionth of a meter. For example, in one particular CMOS process m1 wires must be at least 0.8mm apart from each other and at least 0.6mm wide. Each rule is independent of the others and is specified in fractions of microns.
Magic design rules, on the other hand, are expressed not in microns but in multiples of a unit called lambda, l. Introduced in Carver Mead and Lynn Conway's classic book Introduction to VLSI Systems, lambda is the ``quantum'' for the rules--all spacings and widths must be multiples of lambda. The previous rules concerning m1 spacing and width would be expressed in terms of lambda as 3
Note that using lambda rules is a little costly in terms of area. The spacing rule is now effectively 0.9~
The Technology File
As mentioned earlier, there are several different IC process technologies. Magic is technology-independent and can be used with all. The information that Magic needs about the target process resides in an external file called the technology file (tech file), which Magic reads when the program starts. By default Magic looks in $CAD_HOME/lib/magic/sys for the file scmos.tech27. Both the location and name of the tech file can be specified on the command line with the -T switch, although the name of the tech file must end with a ``.tech27'' extension. For example, to use the scmos-sub.tech27 tech file, you type magic -T scmos-sub.
Included with the Magic distribution in the scmos directory are multiple tech files for various processes offered by MOSIS. As mentioned above, when lambda gets very small, the design rules begin to change. MOSIS provides different tech files to account for this.
Items defined in the tech file include:
layer definitions (e.g., names, colors) and how layers interact with one another
device (transistor) geometry and parasitics
instructions on how to convert Magic's abstract layers to mask layers and vice versa
Knowing the tech file internals isn't necessary to use Magic; in fact, unless you're writing a tech file for a new process or modifying one for an existing process, you can think of the tech file as a ``black box''. If you're interested, you can find a complete discussion of the tech file format in Magic Maintainer's Manual #2: The Technology File, located in the doc subdirectory of the Magic source tree.