libgeda: Don't double free path argument
[geda-gaf.git] / docs / wiki / pcb-drc.html
blob87414a4d17032b03d496d10e20d21ae338fb9d1a
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <head>
5 <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
6 <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
7 <link rel="stylesheet" media="print" type="text/css" href="./print.css" />
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 </head>
11 <body>
13 <p>
14 This page will serve to document the design rule checker. This is presently documented &quot;as-is&quot;.
15 </p>
17 <p>
18 For work tasks, see the LaunchPad blueprint.
19 </p>
21 <p>
22 The DRC code makes extensive use of the <a href="pcb-connection_lookup.html" class="wikilink1" title="pcb-connection_lookup.html"> &quot;connection lookup&quot;</a> code.
23 </p>
25 <h2 id="drcviolations">DRC Violations</h2>
26 <div class="level2">
27 <ul>
28 <li class="level1"><div class="li"> Line/arc/silk width is too thin</div>
29 </li>
30 <li class="level1"><div class="li"> Pin/via annular ring too small</div>
31 </li>
32 <li class="level1"><div class="li"> Pin/via drill size too small</div>
33 </li>
34 <li class="level1"><div class="li"> Pad too thin</div>
35 </li>
36 <li class="level1"><div class="li"> Silk lines in elements</div>
37 </li>
38 <li class="level1"><div class="li"> No paste</div>
39 </li>
40 <li class="level1"><div class="li"> Insufficient copper overlap</div>
41 </li>
42 <li class="level1"><div class="li"> Insufficient copper spacing</div>
43 </li>
44 <li class="level1"><div class="li"> Hole too close to line/pad/pin/via</div>
45 </li>
46 <li class="level1"><div class="li"> Hole touches arc</div>
47 </li>
48 <li class="level1"><div class="li"> Insufficient clearance inside polygon</div>
49 </li>
50 <li class="level1"><div class="li"> Joined line not connected to polygon</div>
51 </li>
52 </ul>
54 </div>
56 <h2 id="process">Process</h2>
57 <div class="level2">
59 <p>
60 Presently, the violations are identified in find.c, and then appended to a list in the gtk hid. In the lesstif and batch hids, you get a pop-up window or a text prompt that describes the error.
61 </p>
63 <p>
64 Executing the DRC() action will wipe out the selected, found, and DRC flags on most objects, although, apparently not elements.
65 </p>
66 <ol>
67 <li class="level1"><div class="li"> Execute the DRC() action.</div>
68 </li>
69 <li class="level1"><div class="li"> Generate the &quot;DRC doesn&#039;t catch everything&quot; warning.</div>
70 </li>
71 <li class="level1"><div class="li"> Save layer state and turn on all layers.</div>
72 </li>
73 <li class="level1"><div class="li"> Clear the FOUNDFLAG, DRCFLAG, and SELECTEDFLAG on all objects. DRC uses these flags to find errors. After clearing all the flags, the undo serial number is incremented. When we&#039;re done, we&#039;ll clear all the flags again, and execute an &quot;undo&quot; to restore the state.</div>
74 </li>
75 <li class="level1"><div class="li"> InitConnectionLookup -- This resets all of the lists that are used for building the connectivity map.</div>
76 </li>
77 <li class="level1 node"><div class="li"> Use DRCFind to check for &quot;insufficient overlap&quot; and &quot;insufficient clearance&quot; in copper objects.</div>
78 <ol>
79 <li class="level2"><div class="li"> For every element pin, pad, and via, execute DRCFind. DRCFind builds a connection list starting from the given pin/pad/via four times using the <a href="pcb-connection_lookup.html" class="wikilink1" title="pcb-connection_lookup.html"> &quot;connection lookup&quot;</a> code.</div>
80 </li>
81 <li class="level2 node"><div class="li"> Check for insufficient overlap:</div>
82 <ol>
83 <li class="level3"><div class="li"> Apply a global bloat of value &quot;Shrink&quot;, and build a connection list, with global drc set to false. This will set the DRCFLAG and SELECTEDFLAG on every object that is touching the given pin/pad/via.</div>
84 </li>
85 <li class="level3"><div class="li"> Apply a global bloat of value 0, and build a connection list with global &quot;drc&quot; set to true.</div>
86 </li>
87 <li class="level3"><div class="li"> With &quot;drc&quot; set to true, the add_object_to_list function will exit with a return status when it finds something that doesn&#039;t have the SELECTEDFLAG set. &quot;Thing&quot; is set to the new object.</div>
88 </li>
89 <li class="level3"><div class="li"> This status propagates back up, and the connection lookup is terminated early.</div>
90 </li>
91 <li class="level3"><div class="li"> A drc_violation is created that includes the &quot;Thing&quot; object.</div>
92 </li>
93 </ol>
94 </li>
95 <li class="level2 node"><div class="li"> Check for insufficient clearance:</div>
96 <ol>
97 <li class="level3"><div class="li"> Do the same routine as above, except starting with a global bloat of 0, and using a bloat of &quot;Bloat&quot; for the second run through.</div>
98 </li>
99 </ol>
100 </li>
101 </ol>
102 </li>
103 <li class="level1 node"><div class="li"> Check for minimum copper line widths:</div>
104 <ol>
105 <li class="level2"><div class="li"> Iterate over all copper lines with COPPERLINE_LOOP</div>
106 </li>
107 <li class="level2"><div class="li"> Test the thickness value of the line</div>
108 </li>
109 <li class="level2"><div class="li"> Generate a drc_violation if the thickness is too thin.</div>
110 </li>
111 <li class="level2"><div class="li"> Iterate over all copper arcs with COPPERARC_LOOP</div>
112 </li>
113 <li class="level2"><div class="li"> ditto</div>
114 </li>
115 </ol>
116 </li>
117 <li class="level1"><div class="li"> Check pin annular rings</div>
118 </li>
119 <li class="level1"><div class="li"> Check drill sizes</div>
120 </li>
121 <li class="level1"><div class="li"> Check pad widths</div>
122 </li>
123 <li class="level1"><div class="li"> Check via annular rings</div>
124 </li>
125 <li class="level1"><div class="li"> Check via drill sizes</div>
126 </li>
127 <li class="level1"><div class="li"> Check silk line widths</div>
128 </li>
129 <li class="level1"><div class="li"> Check element silk line widths</div>
130 </li>
131 <li class="level1"><div class="li"> Restore the layer stack visibility</div>
132 </li>
133 <li class="level1"><div class="li"> return the number of violations found</div>
134 </li>
135 </ol>
137 </div>
139 <h2 id="todolist">To Do List</h2>
140 <div class="level2">
142 </div>
144 <h3 id="newdrcviolations">New DRC Violations</h3>
145 <div class="level3">
148 Some useful DRC violations to add:
149 </p>
150 <ul>
151 <li class="level1"><div class="li"> Check for text on copper layers (which is not tested by the DRC)</div>
152 </li>
153 <li class="level1"><div class="li"> Check for object proximity to the edge of the board</div>
154 </li>
155 <li class="level1"><div class="li"> Violations for holes being too close together</div>
156 </li>
157 <li class="level1"><div class="li"> Floating copper</div>
158 </li>
159 <li class="level1"><div class="li"> Pin/pad exit violations</div>
160 </li>
161 <li class="level1"><div class="li"> Silk screen over pins/pads</div>
162 </li>
163 <li class="level1"><div class="li"> Overlapping elements</div>
164 </li>
165 </ul>
167 </div>
169 <h3 id="drctests">DRC tests</h3>
170 <div class="level3">
173 This is to describe ways of testing the DRC code, not things the DRC should check for.
174 </p>
175 <ul>
176 <li class="level1"><div class="li"> Go through the DRC code for different kinds of violations to check that all possible code paths are being tested</div>
177 </li>
178 <li class="level1"><div class="li"> Review the DRC tests and check that the results are correct! (Done: 201901xx)</div>
179 </li>
180 <li class="level1"><div class="li"> Generate graphical output for the DRC report</div>
181 </li>
182 <li class="level1"><div class="li"> Generate LaTeX output for the DRC report (wishlist!)</div>
183 </li>
184 <li class="level1"><div class="li"> Figure out what else uses the &quot;ConnectionLookup&quot; code and write tests so that we don&#039;t break anything else as we&#039;re reworking the DRC</div>
185 </li>
186 </ul>
188 </div>
190 <h4 id="additionaltestcases">Additional test cases</h4>
191 <div class="level4">
194 As I work through the code, I&#039;m going to jot some things down here regarding tests that ought to be done. Much of this stuff tests the more general geometry code too, so, maybe two birds with one stone.
195 </p>
196 <ul>
197 <li class="level1"><div class="li"> Square pads <br/>
198 In lots of cases, square pads are handled differently than ones with round ends, so, square pads should definitely be tested.</div>
199 </li>
200 <li class="level1"><div class="li"> Objects in the same layer group (physical layer) but on different (logical) layers</div>
201 </li>
202 <li class="level1"><div class="li"> End points of lines/arcs <br/>
203 The end point condition is frequently tested for, and a separate test is called for these cases.</div>
204 </li>
205 </ul>
207 </div>
209 <h3 id="drcbackendwork">DRC backend work</h3>
210 <div class="level3">
211 <ul>
212 <li class="level1 node"><div class="li"> Separate the DRC code from the &quot;ConnectionLookup&quot; code.<br/>
213 This is mostly complete, however, there are a few reasons why this is not going to completely happen for a while. </div>
214 <ul>
215 <li class="level2"><div class="li"> The global &quot;drc&quot; variable is going to be difficult to get rid of, since we do want the code to do certain things during a DRC check that we otherwise might not. </div>
216 </li>
217 <li class="level2"><div class="li"> The global bloat parameter is also going to be tough to get rid of completely. I think what should happen, is that the DRC should generate a list of connected objects, then bloat/shrink all of them as appropriate, and then run the lookup code again. The lookup code shouldn&#039;t need to know anything about bloating things. However, because of the way the lists are generated (separate lists for every type for every layer!) it will be some work to actually do this.</div>
218 </li>
219 </ul>
220 </li>
221 <li class="level1"><div class="li"> Get rid of the &quot;drc&quot;, &quot;User&quot;, and &quot;AndDraw&quot; parameters. (Still trying to figure out what the implications of this would be)</div>
222 </li>
223 <li class="level1"><div class="li"> Factor all of the different DRC tests into separate functions so that they can be executed individually.</div>
224 </li>
225 <li class="level1"><div class="li"> Parameterize the DRC functions, and use those parameters to generate the pane in the preferences widnow.</div>
226 </li>
227 <li class="level1"><div class="li"> Have DRC functions operate on &quot;DataType&quot; objects so that you can selectively apply the DRC to, say, the objects in the buffer</div>
228 </li>
229 <li class="level1"><div class="li"> Work through more of Peter C&#039;s work to see how much of it we should incorporate (home/cparker/peterc_drc, he has quite a bit of good stuff here, but I&#039;d like to include it intelligently instead of just picking the commits.)</div>
230 </li>
231 <li class="level1"><div class="li"> Write functions to compute the distance between objects.</div>
232 </li>
233 <li class="level1"><div class="li"> Put the testing into a background thread so that the GUI is still responsive while the test is executing</div>
234 </li>
235 </ul>
237 </div>
239 <h3 id="onlinedrc">Online DRC</h3>
240 <div class="level3">
243 The online part of the DRC is that part that is active during normal design activities. It does things like preventing you from drawing traces too close together.
244 </p>
247 Right now this functionality exists only for lines and is present in the line.c source file.
248 </p>
250 </div>
252 <h3 id="multi-clearance">Multi-clearance</h3>
253 <div class="level3">
256 One of the primary hurdles with implementing multi-clearance DRC, or, different DRC requirements for different traces or nets, is the way in which our DRC is implemented. Presently we use an algorithm that bloats or shrinks the objects we&#039;re testing, and looks for changes in connectivity. In a multi-clearance DRC environment, the amount that you would need to bloat your object now depends on the objects around it, which may not have been discovered yet.
257 </p>
259 </div>
261 <h3 id="drcinterface">DRC interface</h3>
262 <div class="level3">
263 <ul>
264 <li class="level1"><div class="li"> Create a DRC panel in the preferences window that allows for adjusting settings (possibly with image descriptions of the violations) and running specific tests individually. This will require that parameterization in the back-end work to be finished first.</div>
265 </li>
266 </ul>
268 </div>
270 <h3 id="drcbugs">DRC bugs</h3>
271 <div class="level3">
272 <ul>
273 <li class="level1"><div class="li"> Highlight both offending objects instead of just one (done: 4.2.0)</div>
274 </li>
275 <li class="level1"><div class="li"> Find more than one &quot;insufficient overlap&quot; or &quot;insufficient gap&quot; per pin/pad/via <br/>
276 The insufficient overlap case cannot propagate, due to the nature of how it works, however, the insufficient gap one can, and it does now as of the 4.2.0 release.</div>
277 </li>
278 <li class="level1"><div class="li"> Check for duplicate DRC errors before appending a new one (can happen if more than one pin is connected to an object) (done: 4.2.0)</div>
279 </li>
280 <li class="level1"><div class="li"> On MacOS the images in the DRC window of the GTK HID are garbled</div>
281 </li>
282 </ul>
284 </div>
285 </body>
286 </html>