Repository navigation
Proposal: human-readable intermediate representation of configuration bits (write_config_ir) #2918
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.
Proposal 1: A human-readable intermediate representation of configuration bits
Status: draft for maintainer review
Part of a two-proposal series. Proposal 2 covers emitting a design's
configuration in a form that uses this representation, and depends on this one.
1. Summary
Add an OpenFPGA shell command that writes an intermediate representation
(IR) of the fabric's configuration bits. The IR says, for every configurable
element, what can be chosen, what each choice is called, and which
configuration bits implement it. A reader can follow it without knowing how
OpenFPGA encodes anything:
The IR is produced from the data structures that already decide the bit
layout, so it cannot disagree with the bitstream that OpenFPGA writes.
2. Motivation
OpenFPGA produces configuration bits in two forms today:
configuration protocol, and
Both say what the bits are. Neither says what they mean. Given a
bit string
1011on a routing mux memory, there is no OpenFPGA output thatsays "this selects input 2, which is
CHAN.RIGHT_IN[47]". To learn that,a reader or tool has to re-implement OpenFPGA's rules for mux encoding,
input ordering and mode values. Several uses need exactly this knowledge:
or what a configuration actually selects, without decoding bits by hand.
a mode or a mux to an input for timing or power analysis, or for
functional simulation of a single tile, without a full place-and-route.
2 to input 5" rather than "bits 481 to 484 changed".
bits through one table, instead of each writer encoding bits itself.
Today, tools that need this meaning build it themselves by parsing
OpenFPGA's output files (architecture XML, GSB XML dumps, the fabric key)
and re-deriving the layout. That has three problems:
select values of a mux depend on its circuit model (for example local
encoders, and tree or multi-level structure; see
build_mux_bitstream.cpp). A reconstruction typically assumes a simplerule, such as
ceil(log2(N))select bits with the input index in binary,and is silently wrong wherever the circuit model differs.
bit names to match the ones OpenFPGA generates, so a naming change in
OpenFPGA breaks it without any error in OpenFPGA.
OpenFPGA and again in every consumer, so a change must be made in
several places.
The proposal is to make OpenFPGA, which already owns this mapping, publish
it.
3. Proposal
3.1 Command
(Name and options are open; see section 8.) It runs after the fabric and
its bitstream layout have been built. It needs the layout, not the bit
values of any design, so it describes the fabric and not one design.
3.2 Contents
The IR has these sections.
LOGIC_BLOCKvalues.INTERCONNECTinputslists each input by name, in select order.ROUTING<box>.<output>, withinputsin select order.INSTANCE_MAPEvery entry has:
bits: the number of configuration bits it uses.with placeholders for the instance coordinates (
X,Y) and for theindices of repeated sub-blocks. Each placeholder has a valid range.
values: name to bit string.inputs: for each input, its name and its select code.A consumer never has to know the encoding rule. It looks the code up.
character of every bit string), and applies to every entry.
some inputs on a mux whose size is not a power of two) is written
x,meaning "don't care".
Top-level fields:
schema_version, so that consumers can detect a change.fabricblock with an identity value (for example a hash of the moduleand bit layout), so an IR cannot be used silently with another fabric.
3.3 Naming
Names are chosen so that a reader who knows the VPR and OpenFPGA
architecture files can predict them:
clb.clb.share.fle.fabric.frac_logic.frac_lut6__modeCHAN.<SIDE>_<IN|OUT>[n]andIPIN.<SIDE>_IN[n], qualified by the unique box (sb_2__2,cbx_1__0)<pb>[i].<port>[j], as in the VPR<mux input=...>syntax
An existing downstream tool already uses this schema and these names, so
keeping them lets that tool adopt the command without changes.
3.4 Text view
--format textprints the same information for people, one element perblock, for example:
3.5 Implementation
openfpga/src/fpga_bitstream/, next to the existingbitstream writers, with its command registered like
write_fabric_bitstream.BitstreamManagerblock tree (names), the same helpers thebuilders use to compute mux widths and select values
(
build_mux_bitstream.cpp,build_grid_bitstream.cpp,build_routing_bitstream.cpp), the circuit library (mode values), therouting graph and GSB structure (routing mux inputs), and the
ModuleManagerwith the fabric key (instance to unique module).generate the bitstream, so the IR and the bitstream cannot diverge.
Where such a helper is private to a builder, it is moved to a shared
function and the builder is changed to call it.
4. Compatibility
5. Validation
each IR entry, pick a value through the IR (a mode name, or an input),
and compare the resulting bits with those
write_fabric_bitstreamplaces for the same choice. This is the main check, since it tests the
IR against the encoding that is actually used.
BitstreamManageris named by exactly oneIR entry, or is listed as unclassified.
generated IR checked against a stored copy.
a constant input, local-encoder muxes, tree and multi-level muxes, and
bus-based muxes.
6. Alternatives considered
duplicated logic and silent mismatches described in section 2 remain.
names and values together, but it describes one design, not the fabric,
and it would grow every bitstream file.
fasm_*tags maintained in the architecture file. It duplicatesinformation that the circuit models already hold, and its view is
bit-oriented, not logical.
7. Risks
schema_versionand bylimiting the first version to the fields in section 3.2.
which describes identical boxes once.
8. Open questions for maintainers
command.
connection boxes and not GSBs?
bit field. Should it have a logical form (truth table plus pin order)?
fabricblock carry?All reactions