1%---------------------------------------------------------------------------- 2% Magic tutorial number 1 3%---------------------------------------------------------------------------- 4 5\NeedsTeXFormat{LaTeX2e}[1994/12/01] 6\documentclass[letterpaper,twoside,12pt]{article} 7\usepackage{epsfig,times} 8 9\setlength{\textwidth}{8.5in} 10\addtolength{\textwidth}{-2.0in} 11\setlength{\textheight}{11.0in} 12\addtolength{\textheight}{-2.0in} 13\setlength{\oddsidemargin}{0in} 14\setlength{\evensidemargin}{0pt} 15\setlength{\topmargin}{-0.5in} 16\setlength{\headheight}{0.2in} 17\setlength{\headsep}{0.3in} 18\setlength{\topskip}{0pt} 19 20\def\hinch{\hspace*{0.5in}} 21\def\starti{\begin{center}\begin{tabbing}\hinch\=\hinch\=\hinch\=hinch\hinch\=\kill} 22\def\endi{\end{tabbing}\end{center}} 23\def\ii{\>\>\>} 24\def\mytitle{Magic Tutorial \#1: Getting Started} 25 26%---------------------------------------------------------------------------- 27 28\begin{document} 29 30\makeatletter 31\newcommand{\ps@magic}{% 32 \renewcommand{\@oddhead}{\mytitle\hfil\today}% 33 \renewcommand{\@evenhead}{\today\hfil\mytitle}% 34 \renewcommand{\@evenfoot}{\hfil\textrm{--{\thepage}--}\hfil}% 35 \renewcommand{\@oddfoot}{\@evenfoot}} 36\newcommand{\ps@mplain}{% 37 \renewcommand{\@oddhead}{}% 38 \renewcommand{\@evenhead}{}% 39 \renewcommand{\@evenfoot}{\hfil\textrm{--{\thepage}--}\hfil}% 40 \renewcommand{\@oddfoot}{\@evenfoot}} 41\makeatother 42\pagestyle{magic} 43\thispagestyle{mplain} 44 45 46\begin{center} 47 {\bfseries \Large \mytitle} \\ 48 \vspace*{0.5in} 49 {\itshape John Ousterhout} \\ 50 \vspace*{0.5in} 51 Computer Science Division \\ 52 Electrical Engineering and Computer Sciences \\ 53 University of California \\ 54 Berkeley, CA 94720 \\ 55 \vspace*{0.25in} 56 {\itshape (Updated by others, too.)} \\ 57 \vspace*{0.25in} 58 This tutorial corresponds to Magic version 7. \\ 59\end{center} 60\vspace*{0.5in} 61 62\section{What is Magic?} 63 64Magic is an interactive system for creating and modifying 65VLSI circuit layouts. With Magic, you use a color graphics 66display and a mouse or graphics tablet 67to design basic cells and to combine them 68hierarchically into large structures. Magic is different from 69other layout editors you may have used. The most important 70difference is that Magic is more than just a color painting 71tool: it understands quite a bit about the nature of circuits 72and uses this information to provide you with 73additional operations. 74For example, Magic has built-in knowledge of layout rules; as 75you are editing, it continuously checks for rule violations. 76Magic also knows about connectivity and transistors, and 77contains a built-in hierarchical 78circuit extractor. Magic also has a {\itshape plow} 79operation that you can use to stretch or compact 80cells. Lastly, Magic has routing tools that you can 81use to make the global interconnections in your circuits. 82 83Magic is based on the Mead-Conway style of design. This means 84that it uses simplified design rules and circuit structures. 85The simplifications make it easier for you to design circuits 86and permit Magic to provide powerful assistance that would 87not be possible otherwise. However, they 88result in slightly less dense circuits than you could get with 89more complex rules and structures. For example, Magic permits 90only {\itshape Manhattan} designs (those whose edges are 91vertical or horizontal). Circuit designers tell us that our 92conservative design rules cost 5-10\% in density. We 93think that the density sacrifice is compensated for 94by reduced design time. 95 96\begin{table}[ht] 97 \begin{center} 98 \begin{tabular}{|l|} \hline 99 Magic Tutorial \#1: Getting Started \\ 100 Magic Tutorial \#2: Basic Painting and Selection \\ 101 Magic Tutorial \#3: Advanced Painting (Wiring and Plowing) \\ 102 Magic Tutorial \#4: Cell Hierarchies \\ 103 Magic Tutorial \#5: Multiple Windows \\ 104 Magic Tutorial \#6: Design-Rule Checking \\ 105 Magic Tutorial \#7: Netlists and Routing \\ 106 Magic Tutorial \#8: Circuit Extraction \\ 107 Magic Tutorial \#9: Format Conversion for CIF and Calma \\ 108 Magic Tutorial \#10: The Interactive Route \\ 109 Magic Tutorial \#11: Using RSIM with Magic \\ \hline 110 Magic Maintainer's Manual \#1: Hints for System Maintainers \\ 111 Magic Maintainer's Manual \#2: The Technology File \\ 112 Magic Maintainer's Manual \#3: Display Styles, Color Maps, and Glyphs \\ 113 Magic Maintainer's Manual \#4: Using Magic Under X Windows \\ \hline 114 Magic Technology Manual \#1: NMOS \\ 115 Magic Technology Manual \#2: SCMOS \\ \hline 116 \end{tabular} 117 \end{center} 118 \caption{The Magic tutorials, maintenance manuals, and technology manuals.} 119 \label{tutorials} 120\end{table} 121 122\section{How to Get Help and Report Problems} 123 124There are several ways you can get help about Magic. 125If you are trying to learn about the system, you should start 126off with the Magic tutorials, of which this is the first. 127Each tutorial introduces a particular set of facilities in Magic. 128There is also a set of manuals intended for system maintainers. 129These describe things like how to create new technologies. 130Finally, there is a set of technology manuals. Each one of 131the technology manuals describes the features peculiar to 132a particular technology, such as layer names and design rules. 133Table~\ref{tutorials} lists all of the Magic manuals. 134The tutorials are designed to be read while you are running Magic, 135so that you can try out the new commands as they are explained. 136You needn't read all the tutorials at once; each tutorial 137lists the other tutorials that you should read first. 138 139The tutorials are not necessarily complete. Each one 140is designed to introduce a set of facilities, but it doesn't 141necessarily cover every possibility. The ultimate authority 142on how Magic works is the reference manual, which is a standard 143Unix {\itshape man} page. The {\itshape man} page gives concise 144and complete descriptions of all the Magic commands. 145Once you have a general idea how a command works, the {\itshape man} 146page is probably easier to consult than the tutorial. However, 147the {\itshape man} page may not make much sense until after you've 148read the tutorial. 149 150A third way of getting help is available on-line through Magic 151itself. The {\bfseries :help} command will print 152out one line for each Magic command, giving the command's syntax 153and an extremely brief description of the command. 154This facility is useful if you've forgotten the name or exact 155syntax of a command. After each 156screenful of help information, {\bfseries :help} stops and prints ``--More--''. 157If you type a space, the next screenful of data will be output, and 158if you type {\bfseries q} the rest of the output will be skipped. 159If you're interested in information about a particular subject, 160you can type 161 162\starti 163 \ii {\bfseries :help} {\itshape subject} 164\endi 165 166This command will print out each command description that 167contains the {\itshape subject} string. 168 169If you have a question or problem that can't be answered 170with any of the above approaches, you may contact the Magic authors 171by sending mail to {\ttfamily magic@ucbarpa.Berkeley.EDU}. 172This will log your message in a file (so we can't forget about it) and 173forward the message to the Magic maintainers. 174Magic maintenance is a mostly volunteer effort, so 175when you report a bug or ask a question, {\itshape please} be specific. 176Obviously, the more specific you are, the more likely we can answer your 177question or reproduce the bug you found. 178We'll tend to answer the specific bug reports first, since they involve less 179time on our part. Try to describe 180the exact sequence of events that led to the problem, what you 181expected to happen, and what actually happened. If possible, 182find a small example that reproduces the problem and 183send us the relevant (small!) files so we can make it happen here. 184Or best of all, send us a bug fix along with a small example of the problem. 185 186\section{Graphics Configuration} 187 188Magic can be run with different graphics hardware. The most common 189configuration is to run Magic under X11 on a workstation. Another way 190to run Magic is under SunView on a Sun workstation, or under OpenGL 191(in an X11 environment) on an SGI workstation or Linux box with 192accelerated 3D video hardware and drivers. Legacy code exists 193supporting AED graphics terminals and X10 (the forerunner of X11). 194The rest of this section concerns X11. 195 196Before starting up magic, make sure that your {\ttfamily DISPLAY} variable is 197set correctly. If you are running magic and your X server on the same 198machine, set it to {\ttfamily unix:0}: 199 200\starti 201 \ii {\bfseries setenv} {\ttfamily DISPLAY unix:0} 202\endi 203 204The Magic window is an ordinary X window, and can be moved and resized using 205the window manager. 206 207For now, you can skip to the next major section: "Running Magic". 208 209\section{Advanced X Use} 210 211The X11 driver can read in window sizing and font preferences from 212your {\itshape .Xdefaults} file. The following specifications are recognized: 213 214\starti 215 \> {\bfseries magic.window:} \ii 1000x600+10+10 \\ 216 \> {\bfseries magic.newwindow:} \ii 300x300+400+100 \\ 217 \> {\bfseries magic.small:} \ii helvetica8 \\ 218 \> {\bfseries magic.medium:} \ii helvetica12 \\ 219 \> {\bfseries magic.large:} \ii helvetica18 \\ 220 \> {\bfseries magic.xlarge:} \ii helvetica24 221\endi 222 223{\bfseries magic.window} is the size and position of the initial window, 224while {\bfseries magic.newwindow} is the size and position of subsequent 225windows. If these are left blank, you will be prompted to give 226the window's position and size. {\bfseries small}, {\bfseries medium}, 227{\bfseries large}, and {\bfseries xlarge} are various fonts magic uses 228for labels. 229Some X11 servers read the {\ttfamily .Xdefaults} file only when you initially 230log in; you may have to run {\ttfamily xrdb -load \~{}/.Xdefaults} 231for the changes to take 232effect. 233 234Under X11, Magic can run on a display of any depth for which there are 235colormap and dstyle files. Monochrome, 4 bit, 6 bit, 7 bit, and 24 bit 236files for MOS are distributed in this release. You can explicitly specify 237how many planes Magic is to use by adding a suffix numeral between 2381 and 7 to ``XWIND'' when used with Magic's ``-d'' option. 239For example, ``magic -d XWIND1'' runs magic on a monochrome 240display and ``magic -d XWIND7'' runs magic on a 7 plane display. 241If this number is not specified, magic checks the depth of the display 242and picks the largest number in the set \{1, 4, 6, 7, 16, 24\} that the display 243will support. 244Another way to force the display type is to set an environment variable 245called {\ttfamily MAGIC\_COLOR} to one of the strings ``8bit'', ``16bit'', 246or ``24bit''. 247 248\medskip 249\noindent {\bfseries \itshape Linux note:} \\ 250Magic's ``native'' display (except when using the OpenGL interface) 251is the 8-bit PseudoColor visual type. 24-bit TrueColor visuals prevent 252Magic from allocating colors for bit-plane logical operations, so the 25324-bit interface is visually somewhat sub-par, requiring stipple 254patterns on all metal layers, for instance. Under Linux, a few 255(commercial) X drivers will support 8-bit overlays on top of 24-bit 256TrueColor when using 32-bit color. This is the ideal way to use 257magic, because the colormap for the rest of the display is preserved 258when the cursor is inside the Magic window. Otherwise, the X session 259may have to be started using ``{\ttfamily startx --bpp 8}'' to force 260it to use the 8-bit PseudoColor visual. 261 262\medskip 263\noindent {\bfseries \itshape X11 remote usage note:} \\ 264When running Magic remotely on an X terminal, the colormap allocation 265may differ for the local machine compared to the remote machine. In 266some cases, this can cause the background of magic to appear black, 267usually with a black-on-black cursor. This is known to be true of 268X11 drivers for Windows (such as PC-XWare), due to the way the Windows 2698-bit PseudoColor colormap is set up. This behavior can be corrected 270by setting two environment variables on the remote machine as follows: 271 272\starti 273 \ii {\bfseries setenv} {\ttfamily X\_COLORMAP\_BASE 128} \\ 274 \ii {\bfseries setenv} {\ttfamily X\_COLORMAP\_DEFAULT 0} \\ 275\endi 276 277This causes Magic to avoid trying to allocate the first color 278in the colormap, which under Windows is fixed as black. 279 280\section{Running Magic} 281 282From this point on, you should be sitting at a Magic workstation 283so you can experiment with the program as you read the manuals. 284Starting up Magic is usually pretty simple. Just log in and, if needed, 285start up your favorite window system. Then type the shell command 286 287\starti 288 \ii {\bfseries magic tut1} 289\endi 290 291{\bfseries Tut1} is the name of a library cell that you will play 292with in this tutorial. 293At this point, several colored rectangles should appear 294on the color display along with a white box and a cursor. 295A message will be printed on the text display to tell you that 296{\bfseries tut1} isn't writable (it's in a read-only library), 297and a ``$>$'' prompt should appear. 298If this has happened, then you can skip the rest of this 299section (except for the note below) and go directly to Section 5. 300 301Note: in the tutorials, when you see things printed in boldface, 302for example, {\bfseries magic tut1} from above, they refer to things 303you type exactly, such as command names and file names. These 304are usually case sensitive ({\bfseries A} is different from {\bfseries a}). 305When you see things printed in italics, they refer to classes of 306things you might type. Arguments in square brackets are optional. 307For example, a more complete description 308of the shell command for Magic is 309 310\starti 311 \ii {\bfseries magic} [{\itshape file}] 312\endi 313 314You could type any file name for {\itshape file}, and 315Magic would start editing that file. It turns out that {\bfseries tut1} 316is just a file in Magic's cell library. If you didn't type a 317file name, Magic would load a new blank cell. 318 319If things didn't happen as they should have when you tried to 320run Magic, any of several things could be wrong. If a message 321of the form ``magic: Command not found'' appears on your screen 322it is because the shell couldn't find the Magic program. The 323most stable version of Magic is the directory {\ttfamily \~{}cad/bin}, 324and the newest public version is in {\ttfamily \~{}cad/new}. You should 325make sure that both these directories are in your shell path. 326Normally, {\ttfamily \~{}cad/new} should appear before {\ttfamily \~{}cad/bin}. 327If this sounds like gibberish, find a Unix hacker and have him or her 328explain to you about paths. If worst comes to worst, you can invoke 329Magic by typing its full name: 330 331\starti 332 \ii {\bfseries \~{}cad/bin/magic tut1} 333\endi 334 335Another possible problem is that 336Magic might not know what kind of display you are using. 337To solve this, use magic's {\bfseries -d} flag: 338\starti 339 \ii {\bfseries magic -d} {\itshape display} {\bfseries tut1} 340\endi 341{\itshape Display} is usually the model number of the workstation you are using or 342the 343name of your window system. Look in the manual page for a list of valid 344names, or just guess something. Magic will print out the list of valid names 345if you guess wrong. 346 347If you are using a graphics terminal (not a workstation), 348it is possible that Magic doesn't know which serial line to use. To learn 349how to fix 350this, read about the {\bfseries -g} switch in the magic(1) manual page. Also read 351the displays(5) manual page. 352 353\section{The Box and the Cursor} 354 355Two things, called the {\itshape box} and the {\itshape cursor}, are used 356to select things on the color display. As you move the 357mouse, the cursor moves on the screen. The cursor starts out 358with a crosshair shape, but you'll see later that its shape 359changes as you work to provide feedback about what you're 360doing. The left and right 361mouse buttons are used to position the box. If you press the 362left mouse button and then release it, the box will move so 363that its lower left corner is at the cursor position. If 364you press and release the right mouse button, the upper right 365corner of the box will move to the cursor position, but the 366lower left corner will not change. These two buttons are 367enough to position the box anywhere on the screen. Try using 368the buttons to place the box around each of the colored rectangles 369on the screen. 370 371Sometimes it is convenient to move the box by a corner other 372than the lower left. To do this, press the left mouse button 373and {\itshape hold it down}. The cursor shape changes to show you 374that you are moving the box by its lower left corner: 375 376\begin{center} 377 \begin{tabular}{|c|} \hline 378 \hspace*{0.1in} \\ \hline 379 \end{tabular} 380\end{center} 381 382While 383holding the button down, move the cursor near the lower right 384corner of the box, and now click the right mouse button (i.e. 385press and release it, while still holding down the left 386button). The cursor's shape will change to indicate that 387you are now moving the box by its lower right corner. Move 388the cursor to a different place on the screen and release 389the left button. The box should move so that its lower right 390corner is at the cursor position. Try using this feature to 391move the box so that it is almost entirely off-screen to the 392left. Try moving the box by each of its corners. 393 394You can also reshape the box by corners other than the upper 395right. To do this, press the right mouse button and hold 396it down. The cursor shape shows you that you are reshaping 397the box by its upper right corner: 398 399\begin{center} 400 \begin{tabular}{c|} \hline 401 \hspace*{0.1in} \\ 402 \end{tabular} 403\end{center} 404 405Now move the cursor 406near some other corner of the box and click the left button, 407all the while holding the right button down. The cursor 408shape will change to show you that now you are reshaping the 409box by a different corner. When you release the right button, 410the box will reshape so that the selected corner is at 411the cursor position but the diagonally opposite corner is unchanged. 412Try reshaping the box by each of its corners. 413 414\section{Invoking Commands} 415 416Commands can be invoked in Magic in three ways: by pressing 417buttons on the mouse; by typing single keystrokes on the 418text keyboard (these are called 419{\itshape macros}); or by typing longer commands on the text 420keyboard (these are called {\itshape long commands}). Many of the 421commands use the box and cursor to help guide the command. 422 423To see how commands can be invoked from the buttons, first 424position the box over a small blank area in the middle of the 425screen. Then move the cursor over the red rectangle and 426press the middle mouse button. At this point, the area of the box should 427get painted red. Now move the cursor over empty space and 428press the middle button again. The red paint should go away. 429Note how this command uses both the cursor and box locations 430to control what happens. 431 432As an example of a macro, type the {\bfseries g} key on 433the text keyboard. A grid will appear on the color display, along 434with a small black box marking the origin of the cell. 435If you type {\bfseries g} again, the grid will go away. You 436may have noticed earlier that the box corners didn't move to 437the exact cursor position: you can see now that the box is 438forced to fall on grid points. 439 440Long commands are invoked by typing a colon (``:'') or 441semi-colon (``;''). After you 442type the colon or semi-colon, the ``$>$'' prompt on the text 443screen will be replaced by a ``:'' prompt. This indicates 444that Magic is waiting for a long command. At this point 445you should type a line of text, followed by a return. 446When the long command has been processed, the ``$>$'' prompt 447reappears on the text display. Try typing semi-colon followed by 448return to see how this works. Occasionally a ``]'' (right bracket) 449prompt will appear. This means that the design-rule checker is reverifying 450part of your design. For now you can just ignore this and treat 451``]'' like ``$>$''. 452 453Each long command consists of the name of the command followed 454by arguments, if any are needed by that command. The command 455name can be abbreviated, just as long as you type enough 456characters to distinguish it from all other long commands. 457For example, {\bfseries :h} and {\bfseries :he} may be used as abbreviations for 458{\bfseries :help}. On the other hand, {\bfseries :u} may not be used as an 459abbreviation for {\bfseries :undo} because there is another command, 460{\bfseries :upsidedown}, that has the same abbreviation. Try typing 461{\bfseries :u}. 462 463As an example of a long command, put the box over empty space on 464the color display, then invoke the long command 465 466\starti 467 \ii {\bfseries :paint red} 468\endi 469 470The box should fill with the red color, just as if you had 471used the middle mouse button to paint it. Everything you can 472do in Magic can be invoked with a long command. It turns out that 473the macros are just conveniences that are expanded into long 474commands and executed. For example, the long command equivalent 475to the {\bfseries g} macro is 476 477\starti 478 \ii {\bfseries :grid} 479\endi 480 481Magic permits you to define new macros if you wish. Once you've 482become familiar with Magic you'll almost certainly want to add 483your own macros so that you can invoke quickly the commands you 484use most frequently. See the 485{\itshape magic(1)} man page under the command {\bfseries :macro}. 486 487One more long command is of immediate use to you. It is 488 489\starti 490 \ii {\bfseries :quit} 491\endi 492 493Invoke this command. Note that before exiting, Magic will 494give you one last chance to save the information that you've 495modified. Type {\bfseries y} to exit without saving anything. 496 497\end{document} 498