Repository navigation
Proposal: device package for OpenFPGA (one portable unit per device) #2880
ganeshgore
started this conversation in
Ideas
Replies: 3 comments
|
0 replies
|
Some idea about the openfpga package command. If no package is read, commands will require an input file. |
0 replies
|
@tangxifan Thanks for the detailed review. I have updated the spec as below; the code follows in a separate PR.
|
0 replies
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, revised on 2026-11-27 after the first review. Implemented on a branch that is not merged yet: the manifest and its checks, the corners and the substitution of the timing variables in
read_device_package(--corner; R-16 to R-19, R-22 to R-24, R-46; the process, voltage, temperature and rc of a corner are not required yet),read_device_packageandreport_device_packagein C++ (which Python, the MCP server and the web app call), the I/O map (write_io_map,check_io_map),odc_defaults, the settings and the recipe of the bitstream (docs/spec_bitstream.md), and the line${ODC_SYNTHESIS}in the scripts of the three packages of the repository (docs/plan_odc_constraints.md). Not implemented yet, from the review of the proposal: the fieldtypein place ofroleand the typed Yosys maps (R-20),device.layout(R-7), theLICENSEfile (R-9), the cached files (R-27, R-49),fabric_bitstream_paths(R-28) andpcf_config(R-29).Changes after the review
roleof a file is nowtype(R-20).device.layoutnames a fixed layout of the VPR architecture, in place ofdevice.grid: the size of the grid is not written twice (R-7, R-14).LICENSEfile is required at the root of the package. A file may have its ownlicenseonly when it is copied unchanged from another project (R-9).openfpga-package cachethat writes them (R-49).fabric_bitstream_paths, written with--path_only, so that the bitstream of a design is written with--value_only. No architecture bitstream in a package (R-28).pcf_config, the custom PCF commands of the device (R-29).yosys_mapis split intoyosys_adder_map,yosys_dsp_map,yosys_ff_mapandyosys_bram_map, andyosys_mapstays for other techmap files (R-20).x_types (R-20), and what Liberty and SDF files are for (R-21).Added while implementing, since the proposal was first posted: the I/O map (R-25, R-48), the default ODC constraints (R-26), the line
${ODC_SYNTHESIS}of the Yosys script (R-11a), flat routing (R-14a), the VPR options and the bitstream recipe of the flow (R-14b, R-14c), the expected bitstream of the reference design (R-15), whatread_device_packagedoes in detail (R-46) and its JSON answer (R-51).Overview
This enhancement packages all files and settings required for a single FPGA device into one self-contained unit, making it easier to share, version, and use the device through the OpenFPGA interface.
At present, there is no standard format for bundling the complete set of files and settings required for one device into a single portable package. A task file links these files with paths and variables, but that information is spread across multiple files, which is beneficial for regression testing but is not portable. To share a device with someone else, or to use it from another tool, a person must know which files belong together and which settings apply to each device.
A device package is one directory (or one archive of it) that holds everything needed to target one device with the OpenFPGA flow, plus a manifest that says what each file is. A tool that gets a package needs no other input to synthesize, pack, place, route and generate a bitstream for a design on that device.
This spec defines the layout, the manifest, the rules a package must follow, and the commands that create, check and use one. It does not change the architecture or bitstream formats themselves.
Glossary
k4_N4_2x2).device_package.jsonat the root of a package.vpr_archoryosys_cell_sim. Types are listed in R-20.ss_0p72v_125c_cworst.format_version). Not the version of the device.Goals and non-goals
Goals:
Session, and from the shell.Non-goals:
Layout
Paths in the manifest are relative to the package root. Directories may be empty or absent when the device does not use that part.
Manifest
device_package.jsonis validated byopenfpga_flow/schemas/device_package_manifest.schema.json(device_package.schema.jsonis the schema of the answer ofreport_device_package, R-51).{ "format_version": "1.0", "name": "k4_N4_2x2", "version": "0.3.1", "description": "K4 N4 tileable fabric, 2x2 core", "license": "Apache-2.0", "openfpga": { "min_version": "1.2.0", "max_version": null }, "vtr": { "min_version": "9.0.0" }, "timing_units": { "time": "ps", "capacitance": "fF", "resistance": "ohm" }, "device": { "layout": "2x2", "lut_size": 4, "channel_width": 20, "flat_routing": true, "tags": ["tileable", "bram", "dsp"] }, "corners": { "default": "tt_0p80v_25c_typ", "list": [ { "name": "tt_0p80v_25c_typ", "process": "tt", "voltage": 0.80, "temperature": 25, "rc": "typ" }, { "name": "ss_0p72v_125c_cworst", "process": "ss", "voltage": 0.72, "temperature": 125, "rc": "cworst" } ] }, "files": [ { "type": "vpr_arch", "path": "arch/vpr_arch.xml" }, { "type": "timing_data", "path": "corners/tt_0p80v_25c_typ/timing_data.json", "corner": "tt_0p80v_25c_typ" }, { "type": "rr_graph", "path": "corners/tt_0p80v_25c_typ/rr_graph.bin", "corner": "tt_0p80v_25c_typ" }, { "type": "openfpga_arch", "path": "arch/openfpga_arch.xml" }, { "type": "bitstream_setting", "path": "arch/bitstream_setting.xml" }, { "type": "yosys_script", "path": "synthesis/synth_script.ys" }, { "type": "yosys_cell_sim", "path": "synthesis/techlib/cell_sim.v" }, { "type": "yosys_adder_map", "path": "synthesis/techlib/adder_map.v" }, { "type": "x_openfpga_script", "path": "reference/flow.openfpga" } ], "cache": { "vtr_version": "9.0.0" }, "flow_defaults": { "vpr_options": { "constant_net_method": "route" }, "openfpga_options": { "write_fabric_verilog": ["--default_net_type", "wire"] } } }Requirements
Structure
device_package.jsonat its root, or an archive (.tar.gz, or.zip) that unpacks to such a directory.format_versionusesmajor.minor. A tool refuses a package with a higher major version than it knows. A higher minor version is accepted, and unknown fields are ignored with a warning.namematches[a-z][a-z0-9_]*and equals the directory name.versionis a semantic version of the device content. Any change of a file in the package that changes a flow result raises it..., no absolute path) and exists. A package has no symbolic links at all, since Windows does not support them:checkfails on a link, even one that stays inside the package.files, other thandevice_package.json,README.md,LICENSEandCHECKSUMS.sha256.device.layoutnames a fixed layout (<fixed_layout name=...>) of the VPR architecture, and the size of the grid is read from it, not written again in the manifest. A device with another layout is another package. Several devices that share one architecture (device virtualization) are not covered yet.write_fabric_verilogfrom the architecture files.checkfails on a file infilesthat is a generated netlist, which it recognizes by the type: no type in R-20 allows one.licensefield with an SPDX identifier (orLicenseRef-<name>) for the package as a whole, and the package has aLICENSEfile at its root with the text of that license, as it has aREADME.md. A file infilesmay have its ownlicensefield only when it is copied unchanged from another project under another license (for example a techlib file of Yosys); it overrides the package license for that file.checkfails when the packagelicenseor theLICENSEfile is missing.createasks for the license and does not guess it.Content
vpr_archandopenfpga_arch, and one forbitstream_settingwhen the device supports bitstream generation.yosys_scriptand every techlib file that script reads. A script reads techlib files through paths the tool resolves from the manifest, and does not use absolute paths.${ODC_SYNTHESIS}right after itshierarchycommand, where the design is elaborated and still has its RTL names (spec_odc.md, R-24). A tool that runs the script without ODC replaces it with nothing.build_architecture_bitstream,build_fabric_bitstreamand the fabric writers. These includefabric_key,tile_config,repack_constraints, andpin_constraintswhen the architecture needs them.arch/cell_library/that the OpenFPGA architecture refers to are found through the package, not throughOPENFPGA_PATH.device.layout,device.lut_sizeanddevice.channel_widthare facts about the files.device.channel_widthis required, a number of tracks above 0: a session that uses the package routes at that width, which it cannot change (a package without it does not load).check(R-40) compares them with the VPR architecture and reports a mismatch (a layout that is not a fixed layout of the architecture, a LUT size that its blocks do not have). It reads the architecture with the variables replaced by the values of the default corner.device.flat_routing(true or false, false when it is missing) says that the flow, up to the bitstream, was checked with flat routing (router.flat_routing, VPR's--flat_routing on) on this device. The flow of the web app routes flat on a package only when it is true.flow_defaults.vpr_optionsmaps flags of VPR, without their dashes, to values (text, numbers or true/false): the options that the reference flow of the package gives to VPR, for example{"constant_net_method": "route"}. A session that uses the package sets them as application options, found by their VPR flag (vpr_flagofreport_app_option --json), before it reads the architectures. A value that the flow refuses stops the use of the package. These entries are not set:deviceandroute_chan_width, whichdevice.layoutanddevice.channel_widthgive (they are told when they say otherwise),circuit_format, which synthesis follows and the flow reads from the extension of the netlist, and a flag that the flow does not know (told).flow_defaults.bitstreamsays how the bitstream of the device is made in a session:link_optionsandfabric_options(flags oflink_openfpga_archandbuild_fabric,--and a name, no value) andfixups(check_netlist_naming_conflict,pb_pin_fixup,lut_truth_table_fixup). Anything else makes the package unusable.device.bitstream(true or false, true when missing) says whether the device can make one. See docs/spec_bitstream.md B-10 and B-11.reference/and the manifest records the design and the SHA-256 of the files, so the package can be tested (R-43).reference.expected.bitstreams.build_bitstreamis the SHA-256 of the file thatbuild_bitstreamwrites for the reference design in a session (synthesized with the package's script, then pack, place, route; docs/spec_bitstream.md).Corners
corners/<corner_name>/, not inarch/orsynthesis/. Files that do not depend on a corner (the netlist structure, the bitstream, the techlib) are never repeated in a corner directory.[a-z][a-z0-9_]*, is unique in the package, and equals its directory name. It is listed incorners.listwithprocess,voltage(V),temperature(degrees C) andrc, the RC extraction corner (for exampletyp,cworst,cbest,rcworst,rcbest). Two corners may differ inrconly.corners.defaultnames one of them. The flow uses the default corner when the user gives none. A package with nocornersfield has no corners; itsarch/vpr_arch.xmlthen has no timing variables and is used as it is.cornerfield infiles, and its path is inside that corner's directory. Thetiming_datafile (timing_data.json) of a corner holds the values for that corner (R-22).timing_lib), SDF (timing_sdf) and other delay tables (timing_table) are only stored and checked for now. The checks are those of every file: listed with a type and a corner (R-19), path rules (R-5), checksum (R-30). The flow does not read them, andcheckdoes not parse their content. They are for the tools that sign off the timing of a design outside OpenFPGA; VPR and OpenFPGA use onlytiming_data(R-22).arch/vpr_arch.xmlholds a variable of the form${name}in place of each timing value (delays, capacitances, resistances) that depends on the corner.timing_data.jsonof a corner maps each variable name to its value for that corner. The tool replaces the variables in memory when it reads the architecture for the selected corner. The file in the package is never changed and no annotated copy is written into the package (R-32); a copy for a run goes to the output directory. Only the values change: the grid, routing and blocks are the same for all corners. The template has no default values, so it is not valid VPR input until the variables are replaced; a tool that does not know packages cannot read it directly.checkfails when a variable invpr_arch.xmlhas no value in thetiming_data.jsonof one of the corners, and when a package with no corners has variables invpr_arch.xml. It warns when atiming_data.jsonhas a name that is not a variable ofvpr_arch.xml. A flow run fails with the variable name when a value is missing, and never runs with a variable left in the architecture.timing_unitswith a unit fortime(ns,ps,fs),capacitance(pF,fF) andresistance(ohm,kohm). All numbers in alltiming_data.jsonfiles of the package are in these units. The kind of a variable comes from the end of its name:_Tis time,_Cis capacitance and_Ris resistance, for example${lut_T},${wire_C},${switch_R}.timing_data.jsonis a flat map from the name without${}to a number, for example{"lut_T": 120, "wire_C": 3.5}. The tool converts each value to the unit VPR reads (seconds, farads, ohms) when it replaces the variable.checkfails whentiming_unitsis missing in a package withtiming_datafiles, when a unit is not in the lists, when a variable name does not end in_T,_Cor_R, and when a value is not a number.I/O map
R-25 The I/O map (type
io_map) is a CSV file, comma- or tab-separated, with a header row that names these columns, in any order. A column of another name is an error. There is one row per I/O subtile of the layout, and one per global port of the fabric.sideTOP,BOTTOM,LEFT,RIGHTof the I/O ring,COREfor an I/O inside the grid, empty for a global port. It is the name that the maker gives, not checked against the grid: the pin tables of OpenFPGA call the rowy = 0TOP, which is the bottom of the grid of VPR.write_io_mapwrites the side of the grid of VPRpin_directioninput,outputorinoutpin_typeGPIO,CONTROL,SCANorUNDEFrowyof the VPR grid,(0,0)at the bottom leftcolxof the VPR gridsubtilenetlist_namefpga_top(gfpga_pad_GPIO_PAD[3],clk[0])customer_pin_aliasLED0)The rules, which
checkapplies with the line of each problem:row,colandsubtilename an I/O subtile of the layout. A location has one row for each pin of the fabric there (the input and the output of a pad are two pins, with twonetlist_name).row,colandsubtileempty, and itspin_typeisCONTROL.netlist_name, when it is given, is unique.customer_pin_alias, when it is given, is unique among the rows of onepin_direction: the input and the output of one pad may share it (pad_fpga_io[0]forgfpga_pad_IO_A2F[0]andgfpga_pad_IO_F2A[0]).PACKAGE_PIN, butLOCstill places a port on it.ODC places a port on a pin of the I/O map by
PACKAGE_PIN(spec_odc.md, R-32). The pin table, the I/O location map and the PCF of the older commands can be written from the I/O map.R-26 A package may have an ODC file of type
odc_defaults, read before the ODC file of the user (spec_odc.md, R-46), for example the clock pins of the device.Cached files
rr_graph), the router lookahead (router_lookahead) and the placement delay lookup (place_delay_lookup). Each has acorner(R-19), as its delays are those of the corner. A session that uses the package gives the ones of its corner to VPR (--read_rr_graph,--read_router_lookahead,--read_placement_delay_lookup). The routing resource graph is made atdevice.channel_width(R-14). The manifest records, incache.vtr_version, the version of VTR that wrote them: a session with another version of VTR does not read them and computes them, with a warning, as their binary formats change between versions.openfpga-package cache <pkg>(R-49) writes them.Bitstream
fabric_bitstream_paths, inbitstream/), written once bywrite_fabric_bitstream --path_only: they are the same for every design. The bitstream of a design is then written with--value_only, which is small, and the two together give the full bitstream. The architecture bitstream (build_architecture_bitstream --write_file) is not part of a package: it is large and is for debugging the architecture, not for the user of the device.Pin constraints
pcf_config, the file format ofpcf2place --pcf_config), which a session gives topcf2placewhen the pin constraints of the user are a PCF file.Types
x_; tools ignore them, andcheckapplies to their files the rules of every file (R-5, R-6, R-30). For example, the packages of the repository list the OpenFPGA script of their reference flow as{ "type": "x_openfpga_script", "path": "reference/flow.openfpga" }and the cells that their OpenFPGA architecture refers to asx_cell_library.vpr_archopenfpga_archbitstream_settingsimulation_settingrepack_constraintspin_constraintspcf_configfabric_keytile_configio_infoio_mapodc_defaultsyosys_scriptyosys_cell_simyosys_adder_mapyosys_dsp_mapyosys_ff_mapyosys_bram_mapyosys_mapyosys_bram_rulessdctiming_datavpr_archtiming variables for one corner (hascorner)vpr_archhas variablesrr_graphcorner, R-27)router_lookaheadcorner, R-27)place_delay_lookupcorner, R-27)timing_libcorner), stored and checked onlytiming_sdfcorner), stored and checked onlytiming_tablecorner), stored and checked onlypower_datacorner)corner_infocorner.jsonof one corner (hascorner)fabric_bitstream_pathsreference_designIntegrity and compatibility
CHECKSUMS.sha256lists every file.checkfails when a file is missing, extra or changed. Comment lines that hold a date (//lines in bitstream files) are ignored in the hash.checkfails when the installed OpenFPGA or VTR version is outside the range in the manifest.createandcache(R-41, R-49). A run takes an output directory, and all generated files go there.Commands
R-40
openfpga-package check <pkg>validates the manifest against the schema, applies R-2 to R-6, R-10 to R-14, R-30 and R-31, and exits non-zero with one line per problem.R-41
openfpga-package create <name> --from-task <task>collects the files a task uses into a new package, rewrites the paths, and writes the manifest, the checksums and the files of R-27 and R-28. It does not guess: a file it cannot classify is reported and left out.R-42
openfpga-package pack <dir>andunpack <archive>convert between the directory and the archive. Packing is deterministic: the same directory gives the same archive bytes (sorted entries, fixed times, fixed owner).R-43
openfpga-package test <pkg>runs the reference design inreference/through the flow and compares the results with those recorded in the manifest: the critical path delay, the Fmax, the wirelength, the channel width and the blocks of each type, as VPR logs them, and the SHA-256 of each bitstream file without its//comment lines, which hold the date of the run.R-44 Task files accept
device_package = <path>in place of the separate architecture variables. The variables that a package defines (vpr_arch,openfpga_arch,bitstream_setting, ...) are filled in from the manifest; a value given in the task file wins and is logged.R-45 The Python
SessiontakesSession(device_package=<path>, corner=<name>), which reads the VPR architecture and the OpenFPGA architecture from the package, and gives the other files throughsession.device_package.path(type).cornerdefaults tocorners.default(R-18).R-46 The shell has
read_device_package --file <dir> [--corner <name>], in C++, which the PythonSession, the MCP server and the web app call. It is refused whencheckwould fail, or when the corner is not in the package. It:device.layout, then the OpenFPGA architecture, and gives VPR the cached files of the corner (R-27);router.route_chan_widthtodevice.channel_width, and the options offlow_defaults.vpr_options(R-14b);device.flat_routing, the Yosys script and its techlib files, the I/O map, and theodc_defaults, which it reads;simulation_settingandbitstream_setting, and keepsflow_defaults.bitstreamanddevice.bitstreamforbuild_bitstream(docs/spec_bitstream.md B-3).The package is an input of the session: a checkpoint saves it, the journal has the command, and a replay runs it.
R-49
openfpga-package cache <pkg>makes the device of each corner and writes its files of R-27 (and thefabric_bitstream_pathsof R-28) into the package, then updates the manifest (cache.vtr_version) and the checksums. It is the only command that writes into a package aftercreate.R-48
write_io_map --file <f.csv>writes a first I/O map for the device of the session: a row for each I/O subtile of the grid withside,row,colandsubtile, andnetlist_nameonce the fabric is built. The maker of the package fills inpin_type,pin_directionandcustomer_pin_alias.R-47 A task file accepts
device_corner = <name>next todevice_package.openfpga-package checkalso verifies that every corner incorners.listhas a directory and every corner directory is listed.JSON
report_device_packageanswers, as JSON (kinddevice_package), the package of the session: its name, version, device, files, flow defaults and whatread_device_packageset or did not set, and why.openfpga-package info <pkg> --jsonprints the manifest with the resolved absolute paths in the envelope{schema_version, kind: "device_package", data}used by the other JSON queries, with a schema inopenfpga_flow/schemas/.Design notes
openfpga_flow/schemasare already JSON, and it is read by Python and by C++ (nlohmann/json, vendored inlibs/EXTERNALforread_device_package).yosys_mapfiles. The field istype(it wasrolein the first drafts).sha256sumand no tool.read_device_package,report_device_package,write_io_mapand the reader of the I/O map. Theopenfpga-packagetool is Python, inopenfpga_flow/scripts/, next torun_fpga_task.py.createfrom existing tasks, one with logic only, one with BRAM and one with DSP (basic_tests/generate_fabric,fpga_verilog/bram/dpram1kandfpga_bitstream/extract_dsp_mode_bit).Test plan
check. Each of these fails with a message that names the problem: missing file, path with.., symbolic link, extra file, changed file, a layout that the VPR architecture does not have, missingLICENSE, badformat_version.checkfails whenmin_versionis higher than the installed OpenFPGA.packrun twice gives identical bytes;unpackthencheckpasses.create --from-task basic_tests/generate_fabricgives a package that passescheck, andteston it matches the golden baseline of that task.device_package = ...and with the old variables gives identical.net,.place,.routeand bitstream files.Session(device_package=...)andread_device_packagegive the same device asread_vpr_archandread_openfpga_archon the same files.info --jsonvalidates against its schema.check. Each of these fails with a message that names the problem: corner directory not incorners.list, listed corner without directory,defaultnot in the list, a corner file whosecornerfield and directory differ, a corner with norc, a variable ofvpr_arch.xmlwith no value in a corner, a name intiming_data.jsonthat is not a variable, a.libfile with a changed checksum.corner=Aand a run withcorner=Bread the files of their own corner, and a run with no corner usescorners.default. A package with no corners runs as in T-5.checkfails on a package with nolicense, and on a generated fabric netlist infiles. A package with a file-levellicensepasses, andinfo --jsonshows it.timing_data.json. The package files have the same checksums after the run. A run with a value deleted fails with the variable name.check. Each of these fails with its line: an unknown column, a location outside the grid or not an I/O subtile, a location given twice, a duplicate alias, a badpin_type. A global port with no location passes. A tab-separated file passes.write_io_mapwrites a map that passes, and the CSV made from the pin table and the I/O location map of basic_tests/io_constraints/example_pcf places the pins of its PCF aspcf2placedoes.read_device_packagegives the session of the Python reading of today: the same architectures, layout, channel width and options set or not set, and the refusals with the same reasons.report_device_packagevalidates against its schema. A checkpoint and a journal restore and replay it.cache.vtr_versionthey are not read, with a warning. A routing resource graph at another channel width failscheck.--value_only, with thefabric_bitstream_pathsof the package, equals the full bitstream.psand one innswith the values divided by 1000, give the same architecture after substitution, for_T,_Cand_Rvariables. A missingtiming_units, an unknown unit, or a variable name with no_T,_Cor_Rsuffix failscheck.The tests are a task in
openfpga_flow/tasks/and run in the regression tests.Open questions
None open.
Decided with the owner: one layout per package, named in the VPR architecture (R-7), no generated fabric netlist (R-8), license in the manifest and a
LICENSEfile (R-9), the fieldtypeof a file (R-20), cached routing files per corner (R-27), no architecture bitstream (R-28), Liberty and SDF only stored and checked (R-21), RC extraction corner is part of a corner (R-17), variables are${name}with no default values (R-22), timing units are in the manifest and the kind of a variable comes from its_T,_Cor_Rsuffix (R-24).All reactions