PrincetonUniversity / prga

Open-source FPGA research and prototyping framework.
http://parallel.princeton.edu/prga/
BSD 3-Clause "New" or "Revised" License
192 stars 24 forks source link

Make context creation independent to configuration circuitry type #21

Closed angl-dev closed 3 years ago

angl-dev commented 3 years ago

Currently the entrypoint of PRGA is *.new_context, and file rendering engine is created by *.new_renderer, in which * is a configuration circuitry type (magic, scanchain, or pktchain). This forces the selection of configuration circuitry types before describing the architecture. It also makes *.InsertProgCircuitry pass error-prone.

We should instead start with a generic context, and then leave the configuration circuitry selection to later steps. We can use magic as the default configuration circuitry type, which is not real, but helps with debugging the FPGA architecture at the abstract level. Then, the context may be "materialize" to a specific configuration circuitry type.

For example:

ctx = Context()

ctx.create_global(...)
ctx.create_segment(...)
ctx.build_logic_block(...)
...

flow = Flow(
    Translation(),
    SwitchPathAnnotation(),
    InsertProgCircuitry(),  # calls Magic._InsertProgCircuitry under the hood
    VPRArchGeneration("vpr/arch.xml"),
    VPR_RRG_Generation("vpr/rrg.xml"),
    VerilogCollection('rtl'),
    YosysScriptsCollection(r, "syn"),
    ).run(ctx)

# Until now everything is using `magic` as the configuration circuitry type.

ctx = Scanchain.materialize(ctx)

flow = Flow(
    Translation(),
    SwitchPathAnnotation(),
    InsertProgCircuitry(),  # calls Scanchain._InsertProgCircuitry under the hood
    VPRArchGeneration("vpr/arch.xml"),
    VPR_RRG_Generation("vpr/rrg.xml"),
    VerilogCollection('rtl'),
    YosysScriptsCollection(r, "syn"),
    ).run(ctx)
angl-dev commented 3 years ago

Done with the latest release (0.3.5).