Repository navigation
Proposal: design directory for OpenFPGA (one portable unit per design) #2896
ganeshgore
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Status: proposal for discussion. Not implemented. Comments on the layout, the manifest and the requirements are welcome. It is the counterpart of the device package spec (
docs/spec_device_package.md): the device package describes a device, the design directory describes a design.Overview
A design directory is one directory that holds everything that belongs to one design: the RTL, optionally a netlist that was already synthesized, the testbench, the memory initialization files, the timing constraints, and a manifest that says what each file is.
Today a design is a set of loose files. Nothing says which of several Verilog files is the top, which
.hexfile a memory reads, which SDC file belongs to the design, or whether a BLIF file still matches the RTL next to it. This spec defines the layout, the manifest and the rules for a design directory. It does not change any file format.Glossary
design.jsonat the root of a design directory.rtlorsdc(R-20).Goals and non-goals
Goals:
Non-goals:
Layout
Paths in the manifest are relative to the design directory. The directory names are a convention; the manifest decides what a file is (R-20).
Manifest
design.jsonis validated byopenfpga_flow/schemas/design.schema.json.{ "format_version": "1.0", "name": "dual_port_ram_8x16", "version": "0.1.0", "description": "Dual-port RAM, 8-bit address, 16-bit data, initialized from a hex file", "license": "MIT", "origin": { "source": "opencores", "url": "https://opencores.org/projects/example", "revision": "r42" }, "top": "dual_port_ram_8x16", "files": [ { "role": "rtl", "path": "rtl/dual_port_ram.v" }, { "role": "rtl", "path": "rtl/dual_port_ram_8x16.v" }, { "role": "rtl_include", "path": "rtl/include/defs.vh" }, { "role": "mem_init", "path": "mem/init.hex", "format": "hex", "used_by": "rtl/dual_port_ram.v" }, { "role": "sdc", "path": "constraints/dual_port_ram_8x16.sdc", "stage": "implementation" }, { "role": "sdc", "path": "constraints/dual_port_ram_8x16_synth.sdc", "stage": "synthesis" }, { "role": "testbench", "path": "tb/dual_port_ram_8x16_tb.v", "top": "dual_port_ram_8x16_tb", "stage": "functional" }, { "role": "netlist", "path": "netlist/dual_port_ram_8x16_yosys.blif", "label": "yosys", "made_from": { "rtl_sha256": "<hash>", "tool": "yosys 0.51", "lut_size": 6 } } ], "rtl": { "include_dirs": ["rtl/include"], "defines": { "DATA_WIDTH": "16" }, "read_options": ["-nolatches"] }, "clocks": [ { "name": "clk", "port": "clk", "period_ns": 5.0 } ], "needs": { "min_lut_size": 4, "features": ["bram"] } }Requirements
Structure
design.jsonat its root, or it is an archive (.tar.gzor.zip) that unpacks to such a directory. The manifest is required.format_versionusesmajor.minor. A tool refuses a higher major version and accepts a higher minor version with a warning for fields it does not know.namematches[a-z][a-z0-9_]*and equals the directory name..., no absolute path, no symlink that leaves it) and exists.topnames one module.checkverifies that anrtlfile declares a module (Verilog, SystemVerilog) or an entity (VHDL) of that name (a text scan, no elaboration). A design with anetlistand nortltakes its top from the.modelof a BLIF or EBLIF netlist, or from thedesignstatement of an EDIF netlist.files, other thandesign.json,README.md,LICENSEandCHECKSUMS.sha256.`includethroughrtl.include_dirsor relative to the file, and$readmemhand$readmembthroughmem_initfiles. A name that is absolute, starts with~or has..makescheckfail.license(SPDX identifier, orLicenseRef-<name>with the text inLICENSE). A file may have its ownlicensewhen it comes from another project.originis optional and says where a design that was copied comes from:source,urlandrevision.Content
rtlfile or onenetlistfile. Anrtlfile is Verilog (.v), SystemVerilog (.sv) or VHDL (.vhd,.vhdl); the suffix says which, and a file may carry"language"withverilog,systemverilogorvhdlto override it. A design may mix languages. A tool that cannot read a language says so and does not skip the file.rtl.definesareNAME: valuepairs with a name and a value of letters, digits and_.rtl.read_optionsis a list of options of the front end that reads the RTL (for Yosysread_verilog, a letter or more after-); the options that a language needs, for example-sv, are added by the tool. Nothing else from the manifest is written into a synthesis script.needssays what the design requires from a device:min_lut_size, andfeaturesfrombram,dsp,carry. It is advice about the design, not a constraint on the flow. A tool that knows the device reports what is missing before synthesis.clockslists each clock with itsname, theportthat carries it andperiod_ns. When ansdcfile of the stageimplementationor of both stages is present,checkcompares: a clock with nocreate_clockfor its port, or the reverse, is a warning; a different period is an error.testbenchwith the stagepost_layoutis for the netlist written after place and route, and one with the stagefunctionalis for the RTL or the synthesized netlist. A design may have one of each; the manifest states which is which and a tool does not decide it from the file name.Roles
x_; tools ignore them.rtl.v), SystemVerilog (.sv) or VHDL (.vhd,.vhdl) design filertl_other.vm) or a data tablertl_include`include.vh,.svhnetlist.blif,.eblifor.edif; derived; several allowed, each with alabel(R-25)testbenchtop;stageisfunctional(default) orpost_layout(R-19)stimulusmem_initformat:hex,bin,mem,mif;used_bynames thertlfile that reads itsdcstage:synthesis,implementationor both (default); R-23pin_constraintsformat:xml(OpenFPGA, default),csvorpcf; R-24placement_constraints.place)repack_constraintsactivity.act)docMemory initialization
mem_initfile is listed with itsformatand thertlfile that reads it. Yosys reads a$readmemhpath relative to its working directory, so a tool that synthesizes the design provides the file there under the name the RTL uses, as a copy in the output directory.checkverifies that every$readmemhand$readmembin anrtlfile names amem_initfile by its base name, and that everymem_initfile is named by one. A missing file is an error. A name that differs only in the directory part is a warning. Amem_initfile with the formatmifis a warning: Yosys does not read it, so the design does not synthesize with it as it is.Constraints
sdcfile of the stageimplementationor of both stages is given to VPR (--sdc_file); a file of the stagesynthesisis given to the synthesis step only. VPR readscreate_clock,set_input_delay,set_output_delay,set_clock_groups,set_false_path,set_max_delayandset_multicycle_path;checkwarns for any other command because it is ignored.pin_constraints,placement_constraintsandrepack_constraintsare given to the commands of the flow that take them. Apin_constraintsfile has aformat(xml,csvorpcf), and a tool that cannot read a format says so. When the device also has default constraints of the same kind, the file of the design is used.Derived files
netlistis derived and never overrides the RTL. A design may list several netlists, each with a uniquelabel(for example the tool or the configuration that made it) and its ownmade_from: the hash of thertl,rtl_otherandrtl_includefiles and of the options ofrtl(rtl_sha256), the tool and its version, and the LUT size. A tool uses thertland synthesizes it, and uses anetlistonly when asked, by its label, or when the design has nortl(and then the design has one netlist, or the user gives the label).checkwarns whenrtl_sha256of a netlist differs from the hash of the current files. A netlist with nomade_fromis accepted as a source, for example a circuit from a benchmark set.Integrity
rtlfiles, 1 MiB per source file and 256 MiB per design directory.CHECKSUMS.sha256lists every file.checkfails when a file is missing, extra or changed. The file is optional while a design is in development (check --no-checksums).Commands
openfpga-design check <dir>validates the manifest against the schema, applies R-2 to R-13, R-19, R-21 to R-27, and exits non-zero with one line per problem.openfpga-design create <dir>writes a manifest for an existing directory: it classifies files by suffix and folder, finds the top when exactly one module is not instantiated by another, and reports any file it cannot classify and leaves it out. It does not guess a top that is not unique.openfpga-design pack <dir>andunpack <archive>convert between the directory and the archive, deterministically (sorted entries, fixed times, fixed owner).openfpga-design info <dir> --jsonprints the manifest with resolved absolute paths in the envelope{schema_version, kind: "design", data}of the other JSON queries, with a schema inopenfpga_flow/schemas/.Test plan
check. Each of these fails with a message that names the problem: missing file, path with.., symlink out of the directory, extra file, changed file, badformat_version, atopthat no file declares, adefinesvalue with a space or;.`include "/etc/passwd",$readmemh("../x.hex")or a path with~failscheck.$readmemh("init.hex")withinit.hexinmem/passes. The same with nomem_initentry fails. Amem_initthat no file reads is a warning, and so is amiffile.clocksfailscheck. A clock in one and not the other is a warning. A command outside the VPR subset is a warning.rtland a matchingnetlistis synthesized from thertlby default. After a change of an RTL file,checkwarns about the netlist. A netlist withoutmade_fromgives no warning..svfile and a.vfile passescheck. A.vfile with"language": "systemverilog"is read as SystemVerilog. A tool that cannot read SystemVerilog fails with the file name and does not skip it. Atopdeclared in a.svfile is found.netlistand nortlpassescheck, and its top is the one in thedesignstatement. The same holds for.blifand.eblif, with the top from.model. Anetlistof another suffix fails.createon a directory with one top gives a manifest that passescheck. With two candidate tops it makes none and lists them. A file it cannot classify is reported and left out.packrun twice gives the same bytes;unpackthencheckpasses.info --jsonvalidates against its schema..vhdfile and a.svfile and anrtl_otherfile passescheck. Atopdeclared as a VHDL entity is found. A design withoriginpasses, andinfo --jsonshows it.sdcfile of the stagesynthesisis not given to VPR and is not compared withclocks. Apin_constraintsfile withformatcsvorpcfpassescheck, and one with another format fails.functionaland apost_layouttestbench passescheck. Atestbenchwith another stage fails.check. A duplicate label fails. Each netlist warns separately when the RTL changes. A tool with no label and withrtlsynthesizes; with a label it reads that netlist.The tests are a task in
openfpga_flow/tasks/and run in the regression tests. The example designs are made from existing benchmarks.All reactions