1%----------------------------------------------------------------------------
2% Magic tutorial number 6
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 \#6: Design-Rule Checking}
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{\noindent\bfseries\large Tutorials to read first:}
63\starti
64   \> Magic Tutorial \#1: Getting Started \\
65   \> Magic Tutorial \#2: Basic Painting and Selection \\
66   \> Magic Tutorial \#4: Cell Hierarchies
67\endi
68
69{\noindent\bfseries\large Commands introduced in this tutorial:}
70\starti
71   \> :drc
72\endi
73
74{\noindent\bfseries\large Macros introduced in this tutorial:}
75
76\starti
77   \> y
78\endi
79
80\vspace*{0.75in}
81\section{Continuous Design-Rule Checking}
82
83When you are editing a layout with Magic, the system automatically
84checks design rules on your behalf.  Every time you paint or
85erase, and every time you move a cell or change an array structure,
86Magic rechecks the area you changed to be sure you haven't
87violated any of the layout rules.  If you do violate rules,
88Magic will display little white dots in the vicinity of the
89violation.  This error paint will stay around until you
90fix the problem;  when the violation is corrected, the error paint
91will go away automatically.  Error paint is written to disk
92with your cells and will re-appear the next time the cell is
93read in.  There is no way to get rid of it except to fix the
94violation.
95
96Continuous design-rule checking means that
97you always have an up-to-date picture
98of design-rule errors in your layout.  There is never any need
99to run a massive check over the whole design unless you
100change your design rules.  When you
101make small changes to an existing layout, you will find out
102immediately if you've introduced errors, without
103having to completely recheck the entire layout.
104
105To see how the checker works, run Magic on the
106cell {\bfseries tut6a}.  This cell contains several
107areas of metal (blue), some of which are too close to each
108other or too narrow.  Try painting and erasing metal to make
109the error paint go away and re-appear again.
110
111\section{Getting Information about Errors}
112
113In many cases, the reason for a design-rule violation will
114be obvious to you as soon as you see the error paint.
115However, Magic provides several commands for you to use
116to find violations and figure what's wrong in case it
117isn't obvious.  All of the design-rule checking commands
118have the form
119
120\starti
121   \ii {\bfseries :drc} {\itshape option}
122\endi
123
124where {\itshape option} selects one of several commands understood
125by the design-rule checker.  If you're not sure why error
126paint has suddenly appeared, place the box around the error paint
127and invoke the command
128
129\starti
130   \ii {\bfseries :drc why}
131\endi
132
133This command will recheck the area underneath the box, and print
134out the reasons for any violations that were found.  You can
135also use the macro {\bfseries y} to do the same thing.  Try this
136on some of the errors in {\bfseries tut6a}.  It's a good
137idea to place the box right around the area of the error paint:
138{\bfseries :drc why} rechecks the entire area under the box, so it
139may take a long time if the box is very large.
140
141If you're working in a large cell, it may be hard to see the
142error paint.  To help locate the errors, select a cell
143and then use the command
144
145\starti
146   \ii {\bfseries :drc find} [{\itshape nth}]
147\endi
148
149If you don't provide the {\itshape nth} argument,  the command
150will place the box around one of the errors in the selected
151cell, and print out the reason for the error, just as if you
152had typed {\bfseries :drc why}.  If you invoke the command repeatedly,
153it will step through all of the errors in the selected cell.
154(remember, the ``.'' macro can be used to repeat the last long
155command;  this will save you from having to retype {\bfseries :drc find}
156over and over again).  Try this out on the errors in {\bfseries tut6a}.
157If you type a number for {\itshape nth}, the command will go to the
158{\itshape nth} error in the selected cell, instead of the next one.
159If you invoke this command with no cell selected, it searches
160the edit cell.
161
162A third drc command is provided to give you summary information
163about errors in hierarchical designs.  The command is
164
165\starti
166   \ii {\bfseries :drc count}
167\endi
168
169This command will search every cell (visible or not) that
170lies underneath the box to see if any have errors in them.
171For each cell with errors, {\bfseries :drc count} will print out
172a count of the number of error areas.
173
174
175\section{Errors in Hierarchical Layouts}
176
177The design-rule checker works on hierarchical layouts as well
178as single cells.  There are three overall rules that describe the
179way that Magic checks hierarchical designs:
180
181\begin{enumerate}
182  \item	The paint in each cell must obey all the design rules by itself,
183	without considering the paint in any other cells, including
184	its children.
185
186  \item	The combined paint of each cell and all of its descendants
187	(subcells, sub-subcells, etc.) must be consistent.  If a
188	subcell interacts with paint or with other subcells in a way
189	that introduces a design-rule violation, an error will appear
190	in the parent.  In designs with many levels of
191	hierarchy, this rule is applied separately to each
192	cell and its descendants.
193
194  \item	Each array must be consistent by itself, without considering
195	any other subcells or paint in its parent.  If the neighboring
196	elements of an array interact to produce a design-rule violation,
197	the violation will appear in the parent.
198\end{enumerate}
199
200To see some examples of interaction errors, edit the cell
201{\bfseries tut6b}.  This cell doesn't make sense electrically,
202but illustrates the features of the hierarchical checker.
203On the left are two subcells that are
204too close together.  In addition, the subcells are too close to
205the red paint in the top-level cell.  Move the subcells and/or
206modify the paint to make the
207errors go away and reappear.  On the right side of {\bfseries tut6b} is
208an array whose elements interact to produce a design-rule
209violation.  Edit an element of the array to make the
210violation go away.  When there are interaction errors between
211the elements of an array, the errors always appear near one of the
212four corner elements of the array (since the array spacing is uniform,
213Magic only checks interactions near the corners;  if these
214elements are correct, all the ones in the middle must be correct
215too).
216
217It's important to remember that each of the three overall rules
218must be satisfied independently.  This may sometimes result in
219errors where it doesn't seem like there should be any.  Edit
220the cell {\bfseries tut6c} for some examples of this.  On the
221left side of the cell there is a sliver of paint in the parent
222that extends paint in a subcell.  Although the
223overall design is correct, the sliver of paint in the parent
224is not correct by itself, as required by the first overall
225rule above.  On the right side of {\bfseries tut6c} is an array
226with spacing violations between the array elements.  Even though the
227paint in the parent masks some of the problems,
228the array is not consistent by itself so errors
229are flagged.  The three overall rules are more conservative
230than strictly necessary, but
231they reduce the amount of rechecking Magic must do.  For example,
232the array rule allows Magic to deduce the correctness of an
233array by looking only at the corner elements;  if paint from the
234parent had to be considered in checking arrays, it would be necessary
235to check the entire array since there might be parent paint masking
236some errors but not all (as, for example, in {\bfseries tut6c}).
237
238Error paint appears in different cells in the hierarchy, depending
239on what kind of error was found.  Errors resulting from paint in
240a single cell cause error paint to appear
241in that cell.  Errors resulting from interactions and arrays appear
242in the parent of the interacting cells or array.  Because of the
243way Magic makes interaction checks, errors can sometimes ``bubble
244up'' through the hierarchy and appear in multiple cells.  When
245two cells overlap, Magic checks this area by copying all the paint
246in that area from both cells (and their descendants) into a buffer
247and then checking the buffer.  Magic is unable to tell the difference
248between an error from one of the subcells and an error that comes
249about because the two subcells overlap incorrectly.  This means that
250errors in an interaction area of a cell may also appear in the
251cell's parent.  Fixing the error in the subcell will cause the error
252in the parent to go away also.
253
254\section{Turning the Checker Off}
255
256We hope that in most cases the checker will run so quickly and
257quietly that you hardly know it's there.  However, there will
258probably be some situations where the checker is irksome.  This
259section describes several ways to keep the checker out of your
260hair.
261
262If you're working on a cell with lots of design-rule violations
263the constant redisplay caused by design-rule checking may get
264in your way more than it helps.  This is particularly true if
265you're in the middle of a large series of changes and don't care
266about design-rule violations until the changes are finished.
267You can stop the redisplay using the command
268
269\starti
270   \ii {\bfseries :see no errors}
271\endi
272
273After this command is typed, design-rule errors will no longer
274be displayed on the screen.  The design-rule checker will continue
275to run and will store error information internally, but it won't
276bother you by displaying it on the screen.  When you're
277ready to see errors again, type
278
279\starti
280   \ii {\bfseries :see errors}
281\endi
282
283There can also be times when it's not the redisplay that's
284bothersome, but the amount of CPU time the checker takes to recheck
285what you've changed.
286For example, if a large subcell is moved to overlap
287another large subcell, the entire overlap area will have to be
288rechecked, and this could take several minutes.  If the prompt
289on the text screen is a ``]'' character, it means that the
290command has completed but the checker hasn't caught up
291yet.  You can invoke new commands while the checker is
292running, and the checker will suspend itself long
293enough to process the new commands.
294
295If the checker takes too long to interrupt itself and
296respond to your commands, you have several options.
297First, you can hit the interrupt key (often \^{}C) on the keyboard.
298This will stop the checker immediately and wait for your next
299command.  As soon as you issue a command or push a mouse button,
300the checker will start up again.  To turn the checker off
301altogether, type the command
302
303\starti
304   \ii {\bfseries :drc off}
305\endi
306
307From this point on, the checker will not run.  Magic will
308record the areas that need rechecking but won't do the
309rechecks.  If you save your file and quit Magic, the information
310about areas to recheck will be saved on disk.  The next time
311you read in the cell, Magic will recheck those areas, unless
312you've still got the checker turned off.  There is nothing
313you can do to make Magic forget about areas to recheck;
314{\bfseries :drc off} merely postpones the recheck operation to a
315later time.
316
317Once you've turned the checker off, you have two ways to make
318sure everything has been rechecked.  The first is to type the
319command
320
321\starti
322   \ii {\bfseries :drc catchup}
323\endi
324
325This command will run the checker and wait until everything
326has been rechecked and errors are completely up to date.
327When the command completes, the checker will still be enabled
328or disabled just as it was before the command.
329If you get tired of waiting for {\bfseries :drc catchup},
330you can always hit the interrupt key to abort the command;
331the recheck areas will be remembered for later.  To turn the
332checker back on permanently, invoke the command
333
334\starti
335   \ii {\bfseries :drc on}
336\endi
337
338\section{Porting Layouts from Other Systems}
339
340You should not need to read this section if you've created
341your layout from scratch using Magic or have read it from
342CIF using Magic's CIF or Calma reader.  However, if you are
343bringing into Magic a layout that was created using a
344different editor or an old version of Magic that didn't
345have continuous checking, read on.  You may also need to
346read this section if you've changed the design rules in
347the technology file.
348
349In order to find out about errors in a design that wasn't
350created with Magic, you must force Magic
351to recheck everything in the design.  Once this global recheck
352has been done, Magic will use its continuous checker to deal
353with any changes you make to the design; you should
354only need to do the global recheck once.  To make the global recheck,
355load your design, place the box around the entire design,
356and type
357
358\starti
359   \ii {\bfseries :drc check}
360\endi
361
362This will cause Magic to act as if the entire area under the
363box had just been modified:  it will recheck that entire area.
364Furthermore, it will work its way down through the hierarchy;
365for every subcell found underneath the box, it will recheck
366that subcell over the area of the box.
367
368If you get nervous that a design-rule violation might somehow have been
369missed, you can use {\bfseries :drc check} to force any area
370to be rechecked at any time, even for cells that were
371created with Magic.  However, this should never be
372necessary unless you've changed the design rules.  If the
373number of errors in the layout ever changes
374because of a {\bfseries :drc check}, it is a bug in Magic and you
375should notify us immediately.
376
377\end{document}
378