blob: 5e5356dca05dc284c9fd68b60631b91f7074879e [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
131 make Generate local staging area
132 make install-local Migrate to install directory
133
134 (2) Distributed install: Use the distributed install when the PDK
135 will be run from multiple hosts, but will be installed into a
136 different location such as a git repo which is then distributed to
137 all hosts, and may not itself reside in the same root directory tree.
138
139 The distributed install sequence is:
140
141 make Generate local staging area
142 make install-dist Migrate to distribution directory
143
144 Note that local installs may opt to make symbolic links back to the
145 foundry sources, where possible (see options for foundry_install.py,
146 below). Distributed installs and local installs may also make
147 symbolic links from any PDK variant back to a "master" PDK variant,
148 where possible (that is, where the files are the same). For example,
149 a standard cell library will probably be compatible with all metal
150 back-end stacks, and so only one copy of all the library files is
151 needed in one of the PDK variants. For the other PDK variants, the
152 same files are all symbolic links to the files in the first PDK
153 variant. But an I/O library would have different layouts for different
154 metal back-end stacks, so layout-dependent files like GDS would be
155 different for each PDK, but layout-independent files like verilog
156 might be symbolic links to files in the first PDK.
157
158Prerequisites:
159
160 The following tools/software stacks are needed to run open_pdks:
161
162 python3
163
164 magic opencircuitdesign.com/magic or github.com/RTimothyEdwards
165
166 assumed to be installed and discoverable in the standard
167 search path as defined by the shell (version 8.2+ required)
168
169How to make or update an open PDK:
170
171 The backbone of the open_pdks system is a set of scripts found in the
172 common/ subdirectory. The two main scripts are "preproc.py" and
173 "foundry_install.py", with a host of supporting scripts.
174
175 Creating a new PDK starts with generating a Makefile, which can be
176 done by copying a Makefile from an existing project. The first thing
177 to do is to define the number of PDK variants (usually based on back-end
178 metal stacks available, but can also include front-end options, especially
179 if they are mutually exclusive rather than simply additional masks).
180 Then create the make and make-install targets for local and distributed
181 install, including install (plain), install-vendor, and install-custom.
182 Define the default source and target paths.
183
184 (Needed: A "make makefile" script that generates the "local" and "dist"
185 automatically, and potentially can also make all the different PDK
186 targets automatically, from a much shorter and simpler master Makefile.)
187
188 Create the basic scripts for tools. Since foundries do not support open
189 EDA tools, it is inevitable that these files need to be created by hand
190 unless there is an option to import other formats. Because Magic is used
191 heavily by open_pdks to create missing file formats from other existing
192 file formats, a Magic techfile is critical. Each of the basic scripts
193 will contain #ifdef ... #endif and similar conditionals to allow the
194 script to be parsed for each target PDK variant. Each of these scripts
195 is passed through common/preproc.py to handle the conditionals. Of course,
196 it is possible to make a separate file for each PDK variant as long as the
197 Makefile handles them properly, but use of the preproc.py script allows
198 all the PDK variants to be handled in the same way, simplifying the Makefile.
199
200 --------------------------------------------------------------------------
201 preproc.py Usage:
202
203 preproc.py input_file [output_file] [-D<variable> ...]
204
205 Where <variable> may be a keyword or a key=value pair
206
207 Syntax: Basically like cpp. However, this preprocessor handles
208 only a limited set of keywords, so it does not otherwise mangle
209 the file in the belief that it must be C code. Handling of boolean
210 relations is important, so these are thoroughly defined (see below)
211
212 #if defined(<variable>) [...]
213 #ifdef <variable>
214 #ifndef <variable>
215 #elseif <variable>
216 #else
217 #endif
218
219 #define <variable> [...]
220 #undef <variable>
221
222 #include <filename>
223
224 <variable> may be
225 <keyword>
226 <keyword>=<value>
227
228 <keyword> without '=' is effectively the same as <keyword>=1
229 Lack of a keyword is equivalent to <keyword>=0, in a conditional.
230
231 Boolean operators (in order of precedence):
232 ! NOT
233 && AND
234 || OR
235
236 Comments:
237 Most comments (C-like or Tcl-like) are output as-is. A
238 line beginning with "###" is treated as a preprocessor
239 comment and is not copied to the output.
240
241 Examples;
242 #if defined(X) || defined(Y)
243 #else
244 #if defined(Z)
245 #endif
246
247 --------------------------------------------------------------------------
248
249 The script common/foundry_install.py handles all the IP library processing
250 and installation. It generates the local directory structure and populates
251 the directories with foundry vendor data, and filters or otherwise uses
252 open EDA tools to generate missing standard file formats or create file
253 formats needed by the open EDA tools.
254
255 foundry_install.py Usage:
256
257 foundry_install.py [option [option_arguments]] ...
258
259 All options begin with "-" and may be followed by one or more
260 arguments (that do not begin with "-"). The foundry_install.py
261 script may be called multiple times, although it is best to
262 group together all files for the installation of an IP library,
263 since the options given will be used to determine what files are
264 missing and need to be generated.
265
266 Global options:
267 -link_from <type>
268 Make symbolic links to vendor files from target
269 Types are: "none", "source", or a PDK name.
270 Default "none" (copy all files from source)
271 -source <path>
272 Path to source data top level directory
273 -target <path>
274 Path to target top level directory
275 -local <path>
276 For distributed installs, this is the local
277 path to target top level directory.
278
279 -library <type> <name>
280 The install target is an IP library with
281 name <name>.
282 -ef_format
283 Use the original efabless format for file
284 installs. This has several differences from
285 then no-efabless install. The most important
286 is that the order of directories for IP libraries
287 is <file_format>/<library_name> instead of
288 <library_name>/<file_format>. As the efabless
289 platform migrates to the open_pdks developing
290 standard, this use should eventually be
291 deprecated. In open_pdks, the option is set
292 from the EF_FORMAT variable setting in the Makefile.
293
294 All other options represent installation into specific directories.
295 The primary rule is that if foundry_install.py is passed an option
296 "-library" (see syntax below), then all other non-global options
297 represent subdirectories of the IP library, given the same name as
298 the option word following the "-". If the foundry_install.py command
299 line does not have an option "-library", then all non-global options
300 represent per-EDA tool subdirectories, where the name of the subdirectory
301 is the same as the option word following the "-".
302
303 Each tool install option has the syntax:
304
305 -<tool_name> <path> [<option_arguments>]
306
307 Each IP library install option has the syntax:
308
309 -<file_format_name> <path> [<option_arguments>]
310
311 The <path> is a directory path that is relative to the path prefix
312 given by the -source option. The path may be wildcarded with the
313 escape string "%l", which is replaced by the name of the library,
314 and for simplicity with versioning, "%v" will be interpreted to
315 match any versioning string in the form "major[.minor[.rev]]".
316 Note that only the numerical part of a versioning string is
317 represented, so, for example, to match "/V1.1.0/" the <path> should
318 use "/V%v/". In the unlikely event of a percent character in the
319 path, use the escape string "%%".
320
321 "*" has the usual meaning of matching any characters in a name (see
322 python glob.glob() command for reference). However, for backwards
323 compatibility with earlier versions of open_pdks, the library name
324 in the path may also be wildcarded with "*" in the specific text
325 "/*/".
326
327 Library name wildcarding in either form is only valid if "-library"
328 is given as an an option.
329
330 (Note that the INSTALL variable in the Makefile starts with "set -f"
331 to suppress the OS from doing wildcard substitution; otherwise the
332 wildcards in the install options will get expanded by the OS before
333 being passed to the install script.)
334
335 Library option:
336
337 -library <type> <name> [<target>]
338
339 <type> may be one of the following:
340
341 digital Digital standard cells
342 primitive Primitive devices
343 general All others
344
345 Analog and I/O libraries fall under the category "general".
346
347 <name> is the vendor name of the library.
348
349 [<target>] is the (optional) local name of the library. If omitted,
350 then the vendor name is used for the target (there is no particular
351 reason to specify a different local name for a library).
352
353 Any number of libraries may be supported, and one "-library" option
354 may be provided for each supported library. The use of multiple
355 libraries for a single run of foundry_install.py only works if the
356 formats (gds, cdl, lef, etc.) happen to all work with the same wildcards.
357 But it is generally most common to declare only one library name per
358 call to foundry_install.py.
359
360 Common foundry_install.py options when used with "-library":
361
362 -techlef <path> [option_arguments] Technology LEF file
363 -doc <path> [option_arguments] library documentation
364 -lef <path> [option_arguments] LEF file
365 -spice <path> [option_arguments] SPICE netlists
366 -cdl <path> [option_arguments] CDL netlists
367 -lib <path> [option_arguments] Liberty timing files
368 -gds <path> [option_arguments] GDS layout data
369 -verilog <path> [option_arguments] Verilog models
370
371 Any name can be used after the "-" and the installation of files
372 will be made into a directory of that name, which will be created
373 if it does not exist. The names used above are preferred, for
374 the sake of compatibility between EDA tools.
375
376 Of special note is "techlef", as technology LEF files are often
377 associated with a PDK and not an IP library. In this system,
378 the technology LEF file should be associated with each standard
379 cell library for which it is intended.
380
381 [option_arguments] may be one of the following:
382
383 up <number>
384 Any tool option can use this argument to indicate that
385 the source hierarchy should be copied entirely, starting
386 from <number> levels above the files indicated by <path>.
387 For example, if liberty files are kept in multiple
388 directories according to voltage level, then
389
390 -liberty x/y/z/PVT_*/*.lib
391
392 would install all .lib files directly into
393 libs.ref/<libname>/liberty/*.lib while
394
395 -liberty x/y/z/PVT_*/*.lib up 1
396
397 would install all .lib files into
398 libs.ref/liberty/<libname>/PVT_*/*.lib.
399
400 nospec
401 Remove timing specification before installing (used with
402 verilog files only; could be extended to liberty files).
403
404 compile
405 Create a single library from all components. Used when a
406 foundry library has inconveniently split an IP library
407 (LEF, CDL, verilog, etc.) into individual files.
408
409 compile-only
410 Same as argument "compile", except that the individual
411 files are not copied to the target; only the compiled
412 library is created.
413
414 stub
415 Remove contents of subcircuits from CDL and SPICE netlist,
416 or verilog files. This is useful to LVS and other tools
417 to know the order of pins in a circuit (for CDL or SPICE),
418 or simply to ignore the contents of the file (any format)
419 so that the circuit in question is treated as a "black box".
420
421 priv
422 Mark the contents being installed as privleged, and put
423 them in a separate root directory libs.priv where they
424 can be given additional read/write restrictions.
425
426 rename <file_name>
427 Rename the file being copied to the name of the argument.
428 This can be used to copy one file into multiple destination
429 libraries and give each copy a name related to the
430 destination library.
431
432 filter <script_file_path>
433 Process all files through the script <script_file_path>,
434 which is given as a relative path to the directory
435 containing the Makefile. The filter script traditionally
436 is put in local subdirectory custom/scripts/. The filter
437 script should be written to take a single argument, which
438 is the path to a file, and process that file, and overwrite
439 the file with the result. Commonly used filters are found
440 in the common/ directory. See common/fixspice.py for an
441 example.
442
443 noclobber
444 Mainly diagnostic. When specified, any temporary files
445 used during installation will be retained instead of
446 deleted after use. This includes, for example, scripts
447 passed to magic for running extraction or file format
448 generation. It is useful when debugging problems with
449 the install.
450
451 anno
452 Currently only supported for LEF files. This argument
453 indicates that the vendor LEF files should be used only
454 for annotating GDS input with port location information,
455 but the LEF files themselves should not be installed.
456
457 File conversions handled by foundry_install.py:
458
459 The following file format conversions can be done automatically by
460 foundry_install.py:
461
462 CDL to SPICE: A CDL netlist or library can be converted to a
463 general-purpose SPICE netlist that can be read
464 by any tool that can read Berkeley SPICE 3f5
465 syntax.
466
467 GDS to LEF: An abstract view can be generated from a full
468 layout view using Magic.
469
470 GDS to SPICE: In the absence of any netlist, Magic will
471 extract a SPICE netlist from a full layout.
472
473 SPICE (any) to SPICE (ngspice): The fixspice.py script will
474 attempt to convert any SPICE model file,
475 cell library, or netlist to a form that is
476 compatible with ngspice version 30.
477
478 open_pdks additional Makefile notes:
479
480 The "make install-local" ("make install-dist") step is generally
481 broken into individual make sections, one for each tool (e.g.,
482 magic, netgen, klayout). There is an additional section called
483 "general" which installs a ".config" directory at the PDK top
484 level, containing a file "nodeinfo.json" which has general
485 information about the PDK that may be used by any tool that
486 understands the key:value pairs used in the JSON file. Keys used
487 are as follows:
488
489 foundry : Short name of the foundry, equal to the foundry
490 directory root, above the PDK variants.
491 foundry-name : Long name of the foundry.
492 node : The name of the PDK variant
493 feature-size : The foundry process feature size (e.g., 130nm)
494 status : "active" or "inactive". May be used by tools
495 to present or hide specific PDK variants.
496 description : Long text description of the process variant
497 (e.g., 6-metal stack + MiM caps)
498 options : List of options, corresponding to the definitions
499 used in the Makefile and passed to preproc.py.
500 stdcells : List of standard cell libraries available for this
501 PDK variant.
502 iocells : List of I/O pad cell libraries available for this
503 PDK variant.
504
505 Note that the JSON file is, like other EDA tool setup files, usually a
506 master file that is parsed by preproc.py; therefore when specifying
507 "options", use #undef before specifying each option name so that the
508 option name itself is ignored by the pre-processor.
509
510
511Goals of the open_pdks project:
512
513 The intended goal of open_pdks is to be able to support as many open source
514 EDA tools as practical, and to be able to generate all needed files for
515 those tools from any sufficiently complete set of vendor files.
516
517 A number of file converions are not available but would be useful to have:
518
519 SPICE to liberty: Create timing files by running simulations
520 on SPICE netlists using ngspice.
521
522 liberty to verilog: Use the function statements in liberty
523 format to create verilog primitives. Maybe
524 use liberty timing information to generate
525 LEF specify sections.
526
527 verilog to liberty: Reverse of the above. Use verilog logic
528 tables and specify sections to generate liberty
529 functions and timing tables.
530
531 File formats that need to be supported:
532
533 Schematic and symbol: There are few standards, so either everyone
534 needs to agree on a good format to use, or there
535 needs to be a lot of scripts to do conversions
536 between formats. Open EDA tools that could be
537 supported include:
538
539 electric, xcircuit, kicad, sue2
540
541 Other open source EDA tools that need to be supported:
542
543 OpenROAD
544 Coriolis2
545 (add more here. . .)
546
547 Commercial EDA tools can potentially be supported under this same system,
548 provided sufficient compatibility with the file system structure.
549
550 Other scripts needed:
551
552 Project setup script: It would be useful to define a "standard
553 project file structure" that is similar to the standard PDK file
554 structure defined in open_pdks. The preferred project setup
555 based on the efabless model is:
556
557 <project_name>
558 .config/
559 techdir (symbolic link to open_pdks PDK)
560 project.json (information file for tools)
561 <tool_name> (magic, qflow, ngspice, etc.) or
562 <format_name> (spice, gds, verilog, etc.)
563
564 In general, <tool_name> directories are intended to be workspaces
565 for specific EDA tools (and may have their own nested hierarchies;
566 e.g., qflow/<digital_block>/source,synthesis,layout) while
567 <format_name> is a place to keep (final) files of a specific format,
568 with the intention that any project can easily be made into an
569 IP library and folded into the open_pdks scheme with little effort.
570
571 The project.json file contains project information that can be used
572 by a script to build a setup for any EDA tool. One goal of the
573 project.json file is to define "datasheet" (documented elsewhere)
574 that can be used to drive characterization simulations and create
575 a datasheet for the project. Field "ip-name" of "datasheet" is
576 the canonical name of the project, which can be distinguished from
577 the project directory top-level name, such that the project can be
578 moved or copied without affecting the tool flows.