Magic

From Vlsiwiki
Revision as of 21:12, 10 March 2015 by Mrg (Talk | contribs) (Cells, Paint and Layers)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Magic is an interactive system for creating and modifying VLSI circuit layouts. With Magic, you use a color graphics display and a mouse to design basic cells and to combine them hierarchically into larger structures. Magic has built-in knowledge of layout rules - as you are editing, it continuously checks for rule violations. It has a built-in circuit extractor: from the layout, the extractor creates an output file suitable for use with circuit simulation tools such as Spice (for detailed, mixed-signal simulation) or IRSIM (for digital simulation).

Starting Magic, Text and Graphics Windows

Magic must be run from a workstation that supports the Unix X Windows system (although it can be easily compiled for Linux or OSX at home is also available in Macports). It is *highly* recommended that you have a three button mouse for X Windows programs. Once you login to the Unix machine that runs Magic and setup your environmental variables (using source magic.cshrc), Magic is started by the shell command:

   prompt> magic [-Ttechnology] [file without .mag extension]

where technology is the name of the fabrication technology that the design is intended for, and file is the name of the file that you edit. You could type any file name for file, and Magic would start editing that file. If a file with this name does not exist, Magic will create it. If the technology option is omitted, the layout is done in a default technology. Fortunately, I have set up the default technology as AMI C5N 0.5u which is the technology we plan on using for this class. Therefore, just invoking magic is sufficient. If you wish to learn how to set up the default technology, feel free to contact me.

After starting Magic, a graphics (paint) window pops up, and a ">" prompt appears in the text (shell) window. Magic starts editing the file.

Magic is not a menu-driven program: the layout shows up in the graphics window, but all commands must be entered in the text window. The graphics window is an ordinary X window, and can be moved and resized using the mouse. With a two-button mouse (on a PC with X-server), pressing both buttons at the same time is equivalent to pressing the middle button (which is available on Unix systems). The graphics window is where you draw your layout. To work in this window, move the cursor to the window and click the left mouse button. This makes the graphics window active. The mouse should always point to the graphics window.

The text window is the same window from which you started Magic. It is convenient to position this window under the graphics window so that both windows are visible at the same time. All commands you want to invoke should be typed in the text window. All error messages are also displayed in this window. Commands can be invoked in Magic in three ways:

  1. By pressing buttons on the mouse;
  2. By typing long commands on the keyboard at the prompt ">" in the text window. The long commands are preceded by a colon :
  3. By typing single-character macros on the keyboard at the prompt ">" in the text window.

Before trying to use any command, make sure you have the graphics window active and that the mouse cursor is pointing to the active graphics window. The commands show up in the text window, but affect only the active graphics window.

Scalable Design, Lambda and the Grid

Magic uses what is called scalable or "lambda-based" design. In scalable design, layout items are aligned to a grid which represents a basic unit of spacing. For a particular technology, lambda represents an actual distance (e.g., lambda = 0.3 um for the AMI C5N 0.5u SCMOS technology. However, in Magic all designs are done in terms of lambda, not in terms of actual distances. The paint window is a layout surface on which items can be placed with a resolution of one lambda.

Magic has a grid which can be set to an arbitrary multiple of lambda. The default value of this grid is one lambda by one lambda. The grid of n lambda by n lambda can be displayed using the :grid n command. The g macro toggles the grid on and off.

The Cursor and the Tools

The mouse cursor is used to select, point to, and manipulate objects on the graphics window. The shape of the cursor indicates which of the four available tools is currently being used. Pressing the space bar macro toggles between the 4 tools available:

The box tool is sufficient for basic editing. The purpose of the box tool is to specify a rectangular area of the layout for editing. The left and right mouse buttons are used to position the box. If you click on the left mouse button, the box will move so that its lower left corner is at the cursor position. If you click on the right mouse button, the upper right corner of the box will move to the cursor position, but the lower left corner will not change. The two mouse clicks are sufficient to position the box with arbitrary size anywhere on the screen.

Some Useful Global Commands

Here is a short list of useful global commands. These commands can be typed in at any time.

  • :help command prints out a brief description of all the commands or the specified command.
  • :load circuit-name loads circuit-name into the window; if circuit-name doesn't exist, Magic creates a new empty circuit.
  • :save circuit-name saves all the changes to the circuit.
  • :view or v fits the window with everything drawn thus far.
  • :grid or g toggles a grid. Useful for lining up various cells, wires, etc.
  • :zoom amount zooms in and out by a factor of amount, i.e. :zoom 2 zooms in twice as much, and :zoom 0.5 zooms out twice as much. The z macro zooms out to fit the box on the paint window. The Z macro zooms in the same as the :zoom 2 command
  • :macro displays all current macros
  • :quit quits Magic.

Cells, Paint and Layers

In Magic, a circuit layout is a hierarchical collection of cells. Each cell contains three things: colored shapes, called paint, that define the circuit's structure; textual labels attached to the paint; and subcells, which are instances of other cells.

The two basic layout operations are painting and erasing. They can be invoked using the :paint and :erase commands, or using the mouse buttons.

  • :paint layers (paints rectangular regions, specified by the box)
  • :erase layers (deletes the specified layers from the region under the box)

In each of these commands layers is one or more names separated by commas. In Magic there is one paint layer for each kind of conducting material (polysilicon, ndiffusion, metal1, etc.), plus one additional paint layer for each kind of transistor (n-transistor, p-transistor, etc.), and, finally, one further paint layer for each kind of contact (pcontact, ndcontact, m2contact, etc.)

The easiest way to paint and erase is with mouse buttons. To paint, position the box over the area you'd like to paint, then move the cursor over an existing color and click the middle mouse button (i.e. click both the left and the right mouse button at the same time on a two-button mouse). To erase everything in an area, place the box over the area, move the cursor over a blank spot, and click the middle mouse button. While you are painting, white dots may occasionally appear and disappear. These are design rule violations and will be explained in Design Rule Checking.

Here's a legend of relevant colors/layers:

Layers



Some layers are created by crossing two layers. For example drawing poly over ndiff (or vice versa) will produce an n-transistor. Contacts are made by placing the box over the region of the contact and by painting the appropriate contact. For example, to create a contact between ndiffusion and metal1 layers, place a box over an overlap between the two layers and type :paint ndc command. For a complete list of layers use the Magic command :layers.