-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Seq] Add FirRom op #5798
base: main
Are you sure you want to change the base?
[Seq] Add FirRom op #5798
Conversation
Add a new `FirRomOp` to the Seq dialect to capture the semantics of FIRRTL ROM at the HW level. The intent behind this change is the same as for `FirMemOp`. ROMs are represented as a declaration with the `seq.firrom` which returns a value representing the ROM itself. This value is of type `!seq.firrom<12 x 42>` which represents an opaque handle to the ROM; it encodes the `depth (12)` and `width (42)` of the ROM. ROM ports are represented as separate operations: - `seq.firrom.read_port` These operations take the ROM itself as their first operand. The remaining operands are the specific signals required for the corresponding type of port: clocks, enables, mode select, etc. Read ports also return the read data as their result. Enables are optional to allow for more concise IR for simple memory configurations. The reason why adding a new `FirRomOp` instead of reusing the `FirMemOp` to process Read-Only-Memory is because there are still huge differences in the behaviors of ROM, SRAM, and RegFile in different foundry memory compilers, and their DFT processing is also very different. If they are all merged into `FirMemOp`, a lot of attributes must be added to `FirMemOp`, resulting in the post-processing having to judge these attributes, which increases the burden of post-processing. Therefore, adding `FirRomOp` as a new op is conducive to behavior distinction and later maintenance, especially when we want to add DFT and physical implementation details in the real chip design process, it will be more conducive to implementation, and reduce the cost of code errors caused by maintenance. This commit merely adds the `FirRomOp` alongside some canonicalization and general tests, but the op isn't used by any part of CIRCT yet. Use in FIRRTL-to-HW lowering follows as a separate commit. Signed-off-by: Huang Rui <[email protected]>
My main question with this is what is the plan on the FIRRTL Dialect side? I'm not against the existence of a FIRRTL ROM primitive. However, I'm curious about the intent of putting this into the HW dialect directly. The rationale for adding the FIRRTL ops into All that is about preserving upstream dialect semantics into downstream dialects. We do not currently have a FIRRTL ROM construct. What is the plan for how this interfaces with FIRRTL Dialect (and Chisel)? How should this be differentiated from a FIRRTL Memory with no write ports? |
I think the ROM is another special case for Chisel Mem API(for now): It can be constructed via
Basically I think for both I think we may eventually get rid of the
IMHO, here is my roadmap of the ROM API:
|
|
||
A `seq.firrom` declares the ROM and captures the memory-level parameters | ||
such as width and depth or how read/write collisions are resolved. The read | ||
port are expressed as separate operations that take the declared memory as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, in general is a weird representation. Operations can return multiple values. A property of a rom is how many ports it has, one shouldn't have to walk the IR to find that out.
One known defficiency of seq.firmem is the lack of explicit representation of initialization. Once that is in, it isn't clear that a rom can't just be that op. It would help to have a more complete justification for the difference. One thing which may help is outlining how you imagine processing memories and roms in the pipeline. Essentially, where do target-specific considerations come in to the pipeline? You don't really want the compiler to be hard-coding process-specific transformations. Doing so indicates capturing the wrong thing in the IR. |
As an aside, intmodule is really not intended as a replacement for constructs which should be directly in the langauge. If a new memory or rom construct is needed to replace the (broken) current ones, then that seems pretty core to the representation. |
Basically, from the view of ASIC engineer. there are three main macro macro we need to take care about. SRAM, ROM and RF. IMHO, RF and SRAM can be merged together, ROM should be a standalone implementation since the metadata, DFT are different between RAM and ROM.
I think |
Add a new
FirRomOp
to the Seq dialect to capture thesemantics of FIRRTL ROM at the HW level. The intent behind this
change is the same as for
FirMemOp
.ROMs are represented as a declaration with the
seq.firrom
which returns a value representing the ROM itself. This value
is of type
!seq.firrom<12 x 42>
which represents an opaquehandle to the ROM; it encodes the
depth (12)
andwidth (42)
of the ROM.ROM ports are represented as separate operations:
seq.firrom.read_port
These operations take the ROM itself as their first operand. The
remaining operands are the specific signals required for the
corresponding type of port: clocks, enables, mode select, etc.
Read ports also return the read data as their result. Enables
are optional to allow for more concise IR for simple memory
configurations.
The reason why adding a new
FirRomOp
instead of reusing theFirMemOp
to process Read-Only-Memory is because there arestill huge differences in the behaviors of ROM, SRAM, and
RegFile in different foundry memory compilers, and their DFT
processing is also very different. If they are all merged into
FirMemOp
, a lot of attributes must be added toFirMemOp
, resulting in the post-processing having to judgethese attributes, which increases the burden of post-processing.
Therefore, adding
FirRomOp
as a new op is conducive tobehavior distinction and later maintenance, especially when we
want to add DFT and physical implementation details in the real
chip design process, it will be more conducive to implementation,
and reduce the cost of code errors caused by maintenance.
This commit merely adds the
FirRomOp
alongside somecanonicalization and general tests, but the op isn't used by any
part of CIRCT yet. Use in FIRRTL-to-HW lowering follows as a
separate commit.