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