blob: 521f84cd7e0170edddf0d62d5476c57184dd4c52 [file] [log] [blame]
Tim Edwards55f4d0e2020-07-05 15:41:02 -04001open_pdks : A system for installing silicon foundry PDKs for open-source EDA tools
2(also maybe works for installing commercial tools)
3
4----------------------------------------------------------------------------------
5
6Written by Tim Edwards 2019 / 2020 for efabless (efabless.com)
7and Open Circuit Design (opencircuitdesign.com)
8
9----------------------------------------------------------------------------------
10
11Introduction:
12
13 Silicon foundry PDKs are notoriously non-standard, and files obtained
14 from the foundry may end up in any possibly configuration of files and
15 folders. In addition, silicon foundries are notorious among open source
16 EDA tool enthusiasts for supplying user setups for commercial EDA tools
17 and all but ignoring open source EDA tools. Open_pdks aims to mitigate
18 the problem by defining a standard layout of files and directories for
19 known open standard formats (e.g., SPICE, verilog, liberty, LEF, etc.)
20 and for various open source EDA tools (e.g., magic, netgen, OpenROAD,
21 klayout) using a Makefile system and a number of conversion scripts to
22 ensure that for any process, all files needed by all EDA tools can be
23 found in predictable locations.
24
25 The scripts aim to be as general-purpose as possible to allow easy
26 adaptation to new tools, formats, and foundries. Where foundry data
27 is intractably unusable, custom install files can be added to overwrite
28 or annotate vendor data as needed.
29
30 Each foundry process is a subdirectory of the open_pdks top level and
31 has its own Makefile. The typical install process is to cd to the
32 foundry top level and run "make" (see below for details).
33
34 The general file structure created by open_pdks is as follows:
35
36 <foundry_root>/
37 <name_of_pdk_variant_1>/
38 <name_of_pdk_variant_2>/
39 ...
40 <name_of_pdk_variant_x>/
41 libs.tech/
42 <name_of_EDA_tool_1>/
43 <name_of_EDA_tool_2>/
44 ...
45 <name_of_EDA_tool_x>/
46 <EDA_tool_setup_files>
47 libs.ref
48 <name_of_IP_library_1>/
49 <name_of_IP_library_2>/
50 ...
51 <name_of_IP_library_x>/
52 <name_of_file_format_1>
53 <name_of_file_format_2>
54 ...
55 <name_of_file_format_x>
56 <vendor_files>
57
58 Note that this format is very general and does not constrain the
59 EDA tools supported or file formats supported, so long as there
60 are scripts in the system to provide that support. It is intended
61 that open_pdks can be extended as needed to support new tools or
62 new file formats.
63
64 Current EDA tools supported in this version of open_pdks:
65 Tool Directory name
66 --------------------------
67 ngspice ngspice
68 magic magic
69 netgen netgen
70 klayout klayout
71 qflow qflow
72 openlane openlane
73
74 Current IP library file formats supported in this version of open_pdks*:
75 Format Directory name
76 --------------------------
77 CDL cdl
78 SPICE spice
79 magic mag, maglef
80 LEF lef
81 GDS gds
82 verilog verilog
83 liberty lib
84 PDF** doc
85
86 (* "Supported" meaning expected/handled by conversion scripts;
87 as noted, the install is very general purpose and any name
88 can be used as a target for any vendor or custom files.)
89 (** or HTML or any valid document format, plus supporting files.)
90
91How to use open_pdks:
92
93 There are a seriously limited number of open foundry PDKs. Those that
94 are known (SkyWater, MOSIS SCMOS) are included in the repository. In
95 other cases (X-Fab XH035, XH018) it is possible to get an extension to
96 open_pdks from a known trusted source through NDA verification with
97 the foundry. In all other cases, foundries should be berated until
98 they agree to support the open_pdks format.
99
100 Open_pdks does not attempt to keep any foundry data to the extent
101 possible. Instead, it adapts to the file structure available from
102 whatever system each foundry uses for downloads. Each foundry
103 directory should contain a README file that details how to obtain
104 downloads from the foundry, and what files need to be downloaded.
105 Since the download methods vary wildly, it is up to the user to obtain
106 the foundry data as instructed. The Makefile in the open_pdks foundry
107 directory then needs to be edited to set the correct path to the
108 foundry source data.
109
110 The installation is a bootstrapping process, so needs to be done in
111 stages. The first stage installs setup files for all the EDA tools.
112 The second stage installs IP libraries (e.g., standard cells, padframe
113 I/O, analog circuits) and depends heavily on the use of the open EDA
114 tools themselves to fill in any missing file formats. Therefore the
115 tool setup files need to be installed first, and then the IP libraries.
116 If using a distributed install (see below), then the tool setup files
117 need to be installed and distributed (relocated to the final run-time
118 location) before the IP libraries are installed.
119
120 There are two distinct install types supported by open_pdks:
121
122 (1) Local install: Use a local install when the EDA tools will be run
123 on a single host, and all the PDK data are on the same host.
124
125 The local install sequence is:
126
127 make
128 make install-local Install EDA tool setup
129 make install-vendor-local Install IP libraries
130
131 (2) Distributed install: Use the distributed install when the PDK
132 will be run from multiple hosts, but will be installed into a
133 different location such as a git repo which is then distributed to
134 all hosts, and may not itself reside in the same root directory tree.
135
136 The distributed install sequence is:
137
138 make
139 make install-dist Install EDA tool setup
140 make install-vendor-dist Install IP libraries
141
142 Note that local installs may opt to make symbolic links back to the
143 foundry sources, where possible (see options for foundry_install.py,
144 below). Distributed installs and local installs may also make
145 symbolic links from any PDK variant back to a "master" PDK variant,
146 where possible (that is, where the files are the same). For example,
147 a standard cell library will probably be compatible with all metal
148 back-end stacks, and so only one copy of all the library files is
149 needed in one of the PDK variants. For the other PDK variants, the
150 same files are all symbolic links to the files in the first PDK
151 variant. But an I/O library would have different layouts for different
152 metal back-end stacks, so layout-dependent files like GDS would be
153 different for each PDK, but layout-independent files like verilog
154 might be symbolic links to files in the first PDK.
155
156Prerequisites:
157
158 The following tools/software stacks are needed to run open_pdks:
159
160 python3
161
162 magic opencircuitdesign.com/magic or github.com/RTimothyEdwards
163
164 assumed to be installed and discoverable in the standard
165 search path as defined by the shell (version 8.2+ required)
166
167How to make or update an open PDK:
168
169 The backbone of the open_pdks system is a set of scripts found in the
170 common/ subdirectory. The two main scripts are "preproc.py" and
171 "foundry_install.py", with a host of supporting scripts.
172
173 Creating a new PDK starts with generating a Makefile, which can be
174 done by copying a Makefile from an existing project. The first thing
175 to do is to define the number of PDK variants (usually based on back-end
176 metal stacks available, but can also include front-end options, especially
177 if they are mutually exclusive rather than simply additional masks).
178 Then create the make and make-install targets for local and distributed
179 install, including install (plain), install-vendor, and install-custom.
180 Define the default source and target paths.
181
182 (Needed: A "make makefile" script that generates the "local" and "dist"
183 automatically, and potentially can also make all the different PDK
184 targets automatically, from a much shorter and simpler master Makefile.)
185
186 Create the basic scripts for tools. Since foundries do not support open
187 EDA tools, it is inevitable that these files need to be created by hand
188 unless there is an option to import other formats. Because Magic is used
189 heavily by open_pdks to create missing file formats from other existing
190 file formats, a Magic techfile is critical. Each of the basic scripts
191 will contain #ifdef ... #endif and similar conditionals to allow the
192 script to be parsed for each target PDK variant. Each of these scripts
193 is passed through common/preproc.py to handle the conditionals. Of course,
194 it is possible to make a separate file for each PDK variant as long as the
195 Makefile handles them properly, but use of the preproc.py script allows
196 all the PDK variants to be handled in the same way, simplifying the Makefile.
197
198 --------------------------------------------------------------------------
199 preproc.py Usage:
200
201 preproc.py input_file [output_file] [-D<variable> ...]
202
203 Where <variable> may be a keyword or a key=value pair
204
205 Syntax: Basically like cpp. However, this preprocessor handles
206 only a limited set of keywords, so it does not otherwise mangle
207 the file in the belief that it must be C code. Handling of boolean
208 relations is important, so these are thoroughly defined (see below)
209
210 #if defined(<variable>) [...]
211 #ifdef <variable>
212 #ifndef <variable>
213 #elseif <variable>
214 #else
215 #endif
216
217 #define <variable> [...]
218 #undef <variable>
219
220 #include <filename>
221
222 <variable> may be
223 <keyword>
224 <keyword>=<value>
225
226 <keyword> without '=' is effectively the same as <keyword>=1
227 Lack of a keyword is equivalent to <keyword>=0, in a conditional.
228
229 Boolean operators (in order of precedence):
230 ! NOT
231 && AND
232 || OR
233
234 Comments:
235 Most comments (C-like or Tcl-like) are output as-is. A
236 line beginning with "###" is treated as a preprocessor
237 comment and is not copied to the output.
238
239 Examples;
240 #if defined(X) || defined(Y)
241 #else
242 #if defined(Z)
243 #endif
244
245 --------------------------------------------------------------------------
246
247 The script common/foundry_install.py handles all the IP library processing
248 and installation. It generates the local directory structure and populates
249 the directories with foundry vendor data, and filters or otherwise uses
250 open EDA tools to generate missing standard file formats or create file
251 formats needed by the open EDA tools.
252
253 foundry_install.py Usage:
254
255 foundry_install.py [option [option_arguments]] ...
256
257 All options begin with "-" and may be followed by one or more
258 arguments (that do not begin with "-"). The foundry_install.py
259 script may be called multiple times, although it is best to
260 group together all files for the installation of an IP library,
261 since the options given will be used to determine what files are
262 missing and need to be generated.
263
264 Global options:
265 -link_from <type>
266 Make symbolic links to vendor files from target
267 Types are: "none", "source", or a PDK name.
268 Default "none" (copy all files from source)
269 -source <path>
270 Path to source data top level directory
271 -target <path>
272 Path to target top level directory
273 -local <path>
274 For distributed installs, this is the local
275 path to target top level directory.
276
277 -library <type> <name>
278 The install target is an IP library with
279 name <name>.
280 -ef_format
281 Use the original efabless format for file
282 installs. This has several differences from
283 then no-efabless install. The most important
284 is that the order of directories for IP libraries
285 is <file_format>/<library_name> instead of
286 <library_name>/<file_format>. As the efabless
287 platform migrates to the open_pdks developing
288 standard, this use should eventually be
289 deprecated. In open_pdks, the option is set
290 from the EF_FORMAT variable setting in the Makefile.
291
292 All other options represent installation into specific directories.
293 The primary rule is that if foundry_install.py is passed an option
294 "-library" (see syntax below), then all other non-global options
295 represent subdirectories of the IP library, given the same name as
296 the option word following the "-". If the foundry_install.py command
297 line does not have an option "-library", then all non-global options
298 represent per-EDA tool subdirectories, where the name of the subdirectory
299 is the same as the option word following the "-".
300
301 Each tool install option has the syntax:
302
303 -<tool_name> <path> [<option_arguments>]
304
305 Each IP library install option has the syntax:
306
307 -<file_format_name> <path> [<option_arguments>]
308
309 The <path> is a directory path that is relative to the path prefix
310 given by the -source option. The path may be wildcarded with the
311 character "*". The specific text "/*/" is always replaced by the
312 name of the IP library (if "-library" is an option). Otherwise,
313 "*" has the usual meaning of matching any characters in a name
314 (see python glob.glob() command for reference).
315
316 (Note that the INSTALL variable in the Makefile starts with "set -f"
317 to suppress the OS from doing wildcard substitution; otherwise the
318 wildcards in the install options will get expanded by the OS before
319 being passed to the install script.)
320
321 In some cases, it may be required to process an option like "compile"
322 (see below) on files already in the target path without adding any
323 source files. In that case, <path> may be any keyword that does not
324 point to a valid directory; "none" is a recommended choice.
325
326 Library option:
327
328 -library <type> <name> [<target>]
329
330 <type> may be one of the following:
331
332 digital Digital standard cells
333 primitive Primitive devices
334 general All others
335
336 Analog and I/O libraries fall under the category "general".
337
338 <name> is the vendor name of the library.
339
340 [<target>] is the (optional) local name of the library. If omitted,
341 then the vendor name is used for the target (there is no particular
342 reason to specify a different local name for a library).
343
344 Any number of libraries may be supported, and one "-library" option
345 may be provided for each supported library. The use of multiple
346 libraries for a single run of foundry_install.py only works if the
347 formats (gds, cdl, lef, etc.) happen to all work with the same wildcards.
348 But it is generally most common to declare only one library name per
349 call to foundry_install.py.
350
351 Common foundry_install.py options when used with "-library":
352
353 -techlef <path> [option_arguments] Technology LEF file
354 -doc <path> [option_arguments] library documentation
355 -lef <path> [option_arguments] LEF file
356 -spice <path> [option_arguments] SPICE netlists
357 -cdl <path> [option_arguments] CDL netlists
358 -lib <path> [option_arguments] Liberty timing files
359 -gds <path> [option_arguments] GDS layout data
360 -verilog <path> [option_arguments] Verilog models
361
362 Any name can be used after the "-" and the installation of files
363 will be made into a directory of that name, which will be created
364 if it does not exist. The names used above are preferred, for
365 the sake of compatibility between EDA tools.
366
367 Of special note is "techlef", as technology LEF files are often
368 associated with a PDK and not an IP library. In this system,
369 the technology LEF file should be associated with each standard
370 cell library for which it is intended.
371
372 [option_arguments] may be one of the following:
373
374 up <number>
375 Any tool option can use this argument to indicate that
376 the source hierarchy should be copied entirely, starting
377 from <number> levels above the files indicated by <path>.
378 For example, if liberty files are kept in multiple
379 directories according to voltage level, then
380
381 -liberty x/y/z/PVT_*/*.lib
382
383 would install all .lib files directly into
384 libs.ref/<libname>/liberty/*.lib while
385
386 -liberty x/y/z/PVT_*/*.lib up 1
387
388 would install all .lib files into
389 libs.ref/liberty/<libname>/PVT_*/*.lib.
390
391 nospec
392 Remove timing specification before installing (used with
393 verilog files only; could be extended to liberty files).
394
395 compile
396 Create a single library from all components. Used when a
397 foundry library has inconveniently split an IP library
398 (LEF, CDL, verilog, etc.) into individual files.
399
400 compile-only
401 Same as argument "compile", except that the individual
402 files are not copied to the target; only the compiled
403 library is created.
404
405 stub
406 Remove contents of subcircuits from CDL and SPICE netlist,
407 or verilog files. This is useful to LVS and other tools
408 to know the order of pins in a circuit (for CDL or SPICE),
409 or simply to ignore the contents of the file (any format)
410 so that the circuit in question is treated as a "black box".
411
412 priv
413 Mark the contents being installed as privleged, and put
414 them in a separate root directory libs.priv where they
415 can be given additional read/write restrictions.
416
417 filter <script_file_path>
418 Process all files through the script <script_file_path>,
419 which is given as a relative path to the directory
420 containing the Makefile. The filter script traditionally
421 is put in local subdirectory custom/scripts/. The filter
422 script should be written to take a single argument, which
423 is the path to a file, and process that file, and overwrite
424 the file with the result. Commonly used filters are found
425 in the common/ directory. See common/fixspice.py for an
426 example.
427
428 noclobber
429 Mainly diagnostic. When specified, any temporary files
430 used during installation will be retained instead of
431 deleted after use. This includes, for example, scripts
432 passed to magic for running extraction or file format
433 generation. It is useful when debugging problems with
434 the install.
435
436 anno
437 Currently only supported for LEF files. This argument
438 indicates that the vendor LEF files should be used only
439 for annotating GDS input with port location information,
440 but the LEF files themselves should not be installed.
441
442 noconvert
443 Install files from source to target, but do not perform
444 any additional conversions (such as CDL to SPICE, or
445 GDS or LEF to magic).
446
447 ignore=<keyword>[,...]
448 Specifically for CDL and SPICE netlists, ignore any
449 parameter found matching <keyword>
450
451 rename=<new-name>
452 For single files copied from source to target, the
453 target file should be named <new-name> and not be
454 given the same name as the source file. When used
455 with the "compile" or "compile-only" options, then
456 the compiled file gets the name <new-name> rather
457 than taking the name of the library.
458
459 exclude=<file>[,...]
Tim Edwards4697a172021-11-05 22:47:07 -0400460 Exclude file(s) from the comma-separated list when
461 copying from source to target. The list items may
462 include glob-style wildcards.
463
464 excludefrom=<dir>
465 Exclude all files in the listing of directory <dir>
466 from the comma-separated list when copying from source
467 to target.
Tim Edwards55f4d0e2020-07-05 15:41:02 -0400468
469 File conversions handled by foundry_install.py:
470
471 The following file format conversions can be done automatically by
472 foundry_install.py:
473
474 CDL to SPICE: A CDL netlist or library can be converted to a
475 general-purpose SPICE netlist that can be read
476 by any tool that can read Berkeley SPICE 3f5
477 syntax.
478
479 GDS to LEF: An abstract view can be generated from a full
480 layout view using Magic.
481
482 GDS to SPICE: In the absence of any netlist, Magic will
483 extract a SPICE netlist from a full layout.
484
485 SPICE (any) to SPICE (ngspice): The fixspice.py script will
486 attempt to convert any SPICE model file,
487 cell library, or netlist to a form that is
488 compatible with ngspice version 30.
489
490 open_pdks additional Makefile notes:
491
492 The "make install-local" ("make install-dist") step is generally
493 broken into individual make sections, one for each tool (e.g.,
494 magic, netgen, klayout). There is an additional section called
495 "general" which installs a ".config" directory at the PDK top
496 level, containing a file "nodeinfo.json" which has general
497 information about the PDK that may be used by any tool that
498 understands the key:value pairs used in the JSON file. Keys used
499 are as follows:
500
501 foundry : Short name of the foundry, equal to the foundry
502 directory root, above the PDK variants.
503 foundry-name : Long name of the foundry.
504 node : The name of the PDK variant
505 feature-size : The foundry process feature size (e.g., 130nm)
506 status : "active" or "inactive". May be used by tools
507 to present or hide specific PDK variants.
508 description : Long text description of the process variant
509 (e.g., 6-metal stack + MiM caps)
510 options : List of options, corresponding to the definitions
511 used in the Makefile and passed to preproc.py.
512 stdcells : List of standard cell libraries available for this
513 PDK variant.
514 iocells : List of I/O pad cell libraries available for this
515 PDK variant.
516
517 Note that the JSON file is, like other EDA tool setup files, usually a
518 master file that is parsed by preproc.py; therefore when specifying
519 "options", use #undef before specifying each option name so that the
520 option name itself is ignored by the pre-processor.
521
522
523Goals of the open_pdks project:
524
525 The intended goal of open_pdks is to be able to support as many open source
526 EDA tools as practical, and to be able to generate all needed files for
527 those tools from any sufficiently complete set of vendor files.
528
529 A number of file converions are not available but would be useful to have:
530
531 SPICE to liberty: Create timing files by running simulations
532 on SPICE netlists using ngspice.
533
534 liberty to verilog: Use the function statements in liberty
535 format to create verilog primitives. Maybe
536 use liberty timing information to generate
537 LEF specify sections.
538
539 verilog to liberty: Reverse of the above. Use verilog logic
540 tables and specify sections to generate liberty
541 functions and timing tables.
542
543 File formats that need to be supported:
544
545 Schematic and symbol: There are few standards, so either everyone
546 needs to agree on a good format to use, or there
547 needs to be a lot of scripts to do conversions
548 between formats. Open EDA tools that could be
549 supported include:
550
551 electric, xcircuit, kicad, sue2
552
553 Other open source EDA tools that need to be supported:
554
555 OpenROAD
556 Coriolis2
557 (add more here. . .)
558
559 Commercial EDA tools can potentially be supported under this same system,
560 provided sufficient compatibility with the file system structure.
561
562 Other scripts needed:
563
564 Project setup script: It would be useful to define a "standard
565 project file structure" that is similar to the standard PDK file
566 structure defined in open_pdks. The preferred project setup
567 based on the efabless model is:
568
569 <project_name>
570 .config/
571 techdir (symbolic link to open_pdks PDK)
572 project.json (information file for tools)
573 <tool_name> (magic, qflow, ngspice, etc.) or
574 <format_name> (spice, gds, verilog, etc.)
575
576 In general, <tool_name> directories are intended to be workspaces
577 for specific EDA tools (and may have their own nested hierarchies;
578 e.g., qflow/<digital_block>/source,synthesis,layout) while
579 <format_name> is a place to keep (final) files of a specific format,
580 with the intention that any project can easily be made into an
581 IP library and folded into the open_pdks scheme with little effort.
582
583 The project.json file contains project information that can be used
584 by a script to build a setup for any EDA tool. One goal of the
585 project.json file is to define "datasheet" (documented elsewhere)
586 that can be used to drive characterization simulations and create
587 a datasheet for the project. Field "ip-name" of "datasheet" is
588 the canonical name of the project, which can be distinguished from
589 the project directory top-level name, such that the project can be
590 moved or copied without affecting the tool flows.