chipsalliance / fpga-interchange-schema

https://fpga-interchange-schema.readthedocs.io/
Apache License 2.0
51 stars 20 forks source link

Macro parameter mapping #41

Closed gatecat closed 3 years ago

gatecat commented 3 years ago

Consider the following design with initialized LUTRAM, for the xc7:

module top(
    input clk, we,
    input [6:0] wa, ra,
    input wd,
    output [1:0] rd
);
    RAM128X1D #(
        .INIT(128'hFFEEDDCCBBAA99887766554433221100)
    ) ram_i (
        .WCLK(clk), .WE(we),
        .A(wa), .DPRA(ra),
        .D(wd),
        .SPO(rd[0]), .DPO(rd[1])
    );
endmodule

Opening the implemented design in Vivado and running:

get_property INIT [get_cells ram_i/DP.LOW]
64'h7766554433221100
get_property INIT [get_cells ram_i/DP.HIGH]
64'hFFEEDDCCBBAA9988

you can see that the INIT parameter of the RAM128XD macro has been split into two for the constituent cells.

Currently the schema appears to have no way to describe a parameter mapping like this, which will need to be fixed to support initialised LUTRAM and some other macros like LUT6_2.

cc @clavin-xlnx as I don't think RapidWright currently provides this kind of data either?

gatecat commented 3 years ago

Parameter transforms we would probably want to support:

GitHub
YosysHQ/nextpnr
nextpnr portable FPGA place and route tool. Contribute to YosysHQ/nextpnr development by creating an account on GitHub.
mithro commented 3 years ago

@gatecat - I don't /think/ we want to support these types of transforms in the interchange format. Instead I think we want to make the synthesis tool do the work?

gatecat commented 3 years ago

Macro transforms are currently part of the interchange format, and discussions with litghost concluded that they were in scope, because of the potential complex interactions between macro expansions and placement (and for example, how macro expansions only affect the physical and not logical netlist) mean they will be something that nextpnr-interchange supports.

See SymbiFlow/nextpnr#264 for some more discussion (I might be able to dig out some IRC logs about this too).

mithro commented 3 years ago

@gatecat - Just confirming, #264 is converting a single block into multiple blocks, right?

gatecat commented 3 years ago

Yes, but importantly only from a physical netlist point of view and not from a logical netlist point of view.

mithro commented 3 years ago

This looks to be the relevant section?

https://github.com/SymbiFlow/fpga-interchange-schema/blob/5208d794d318e9151b93120d7e5ba75d8aef45e7/interchange/DeviceResources.capnp#L267-L286

mithro commented 3 years ago

Looks like @litghost didn't write down all that much about what he planned to do here - https://fpga-interchange-schema.readthedocs.io/device_resources.html#parameters

Device Resources — SymbiFlow FPGA Interchange Format 0.0-53-g5208d79 documentation
mithro commented 3 years ago

Some parameters attached to cell instances may be relevant for the place and route problem. A common example is LUT equation sharing, which can happen on fracturable LUTs. See the schema for details.

gatecat commented 3 years ago

This looks to be the relevant section?

Nope, that's totally different. That's describing how physical cells map onto bels.

Macro expansions are about creating a hierarchy of multiple physical cells out of a single logical cell (which then follow those rules to map onto bels, for example a RAMD64E onto a LUT6 bel); as used for LUTRAM, complex IO, etc.

Some parameters attached to cell instances may be relevant for the place and route problem. A common example is LUT equation sharing, which can happen on fracturable LUTs. See the schema for details.

This affects more than just the place and route problem, it also affects FASM generation for example.

There isn't, imo, a great philosophical debate to be had here, just a relatively simple omission from the macro expansion rules (which are otherwise well documented in #264).

gatecat commented 3 years ago

I think the two ways of solving this would be:

mithro commented 3 years ago

@gatecat - I think either approach could work, do you want to try both and see which works better? @clavin-xlnx - Do you have an opinion?

clavin-xlnx commented 3 years ago

Yes, deriving parameter values on the primitives as a function of the parent's value makes sense to me. Given the two options, I would probably prefer the latter (augmenting PrimToMacroExpansion) just to keep the scope of the solution tight.

gatecat commented 3 years ago

Fixed by #42