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