calyxir / calyx

Intermediate Language (IL) for Hardware Accelerator Generators
https://calyxir.org
MIT License
494 stars 50 forks source link

Calyx Standard Library Revamp #1596

Open rachitnigam opened 1 year ago

rachitnigam commented 1 year ago

Summarizing discussion from our meeting today, we were trying to figure out what the right way to develop and integrate the Calyx standard library is. Specifically, we need to start caring about long-term stability and integration with CIRCT as top-level concerns for the library.

To summarize:

Proposed Changes

Here is a couple of proposed changes for the primitives library:

These changes will likely break code from all our frontends and so we need to coordinate with the Dahlia stuff and CIRCT before merging. Once done, we should do a new major release of the compiler

bcarlet commented 1 year ago

While we're considering breaking changes to the standard primitives, I'll also throw #497 in for consideration (as a potential breaking change to std_slice, specifically the change described here). I find myself needing a more general slice primitive fairly frequently, and I feel like the current version is oddly restrictive.

rachitnigam commented 1 year ago

Absolutely! Do you want to take a shot at implementing a version that had both a start index and an end index? @andrewb1999 do you know if this matches the semantics of the CIRCT slice primitive?

EclecticGriffin commented 1 year ago

Just wanted to flag a little weirdness in the fixed point prims. There are exactly three comparison ops

There's no equality op (presumably since the std_eq works if we assume both fixed point numbers have the same fixed point, which is the operating assumption for all the fixed prims). It does seem a bit weird that we have a signed less than but no less than op (which of course can be realized with gt), probably we should either commit to a very minimal set of ops (removing slt) or we should make the full suite of standard comparisons for fixed point numbers if they're something we intend to provide as stable

EclecticGriffin commented 1 year ago

Follow up, why does std_seq exist for signed bitnums, seems like that would be equivalent to the standard unsigned equality since we mandate the inputs be of the same width anyway?

rachitnigam commented 1 year ago

@EclecticGriffin Agreed! This is weird. There should be exactly one equality and it should handle all these different formats. Also, yeah, each unsigned thing should have a signed counterpart. I'm not too worried about keeping it minimal so maybe we can add all the signed counterparts and remove the useless eq ones? Wanna take a shot at it?

sampsyo commented 1 year ago

Awesome! This is very much a good plan.

Just to iterate (i.e., bike-shed) on the details, here are a few assorted suggestions:

rachitnigam commented 1 year ago

they're not strictly speaking unsynthesizable

I think combinational multipliers are also not technically unsynthesizable but maybe a different point here is that unsynthesizable is a little strong; these modules are fine if you want to do modeling maybe?

On the other hand, @paili0628 is currently working on dual ported memories as well which will go into their own file. Long term maybe we just want all the memories in one place?

moved out of the Calyx distribution and were in separate modules, but that is obviously a problem for another day.

Right! This can be a part of the modules discussion. We almost want a calyx-extras package that ships all of these extra modules and generators that @anshumanmohan has been building up.