Skip to content
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

A real numerics library for Calyx #416

Closed
rachitnigam opened this issue Mar 6, 2021 · 3 comments
Closed

A real numerics library for Calyx #416

rachitnigam opened this issue Mar 6, 2021 · 3 comments
Labels
C: Library Calyx's standard library S: In progress Issue is being worked on

Comments

@rachitnigam
Copy link
Contributor

The current state of the numerics operators in Calyx is not great. The goal of this PR is to build a realistic, well-designed, and well-tested numerics library for Calyx that has robust supported for signed and unsigned computations for bitnum and fixedpoint numbers.

Current State

Most of the numeric operators live under primitives/{bitnum,fixed}/{signed,unsigned}.sv. There are broadly three problems:

  1. No Standardized Guidelines: For example the sqrt implementation used blocking assignments at the time of submission which are widely discouraged when writing synthesizable RTL code. Similarly, the code does minor annoying things like not capitalizing parameter names.
  2. Unspecified Interfaces: The fixedpoint implementations only work with number of the same width and don't really have guarantees on how things overflow.
  3. Unnecessary Code Duplication: The bitnum implementations should "just work" for FP since the FP format is just powers of two. It shouldn't be necessary to have two separate implementations. Plus, all primitives in the library should be synthesizable; currently they are not (std_div, std_fp_div)

Brave New World

The new numerics library should be carefully redesigned to provide support for all computations that Dahlia supports and support operators like sqrt and exp. We should define a standard way to build new primitives and clear guidelines on when things need to be written in Calyx and when they can be written in Verilog.

@rachitnigam rachitnigam added S: Discussion needed Issues blocked on discussion C: Library Calyx's standard library labels Mar 6, 2021
@sampsyo
Copy link
Contributor

sampsyo commented Mar 6, 2021

Seems like a good vision! One question on a very low-level detail: what should the general policy be for operations that combine bit widths---for example, adding an 8-bit integer to a 16-bit integer? I can think of two policies:

  • Permissive: The operations try to support flexible combinations of formats whenever they can, so this "16+8" example could be done with a single adder.
  • Orthogonal: Operations work on strictly matching formats, and there also "width adjusting" primitives that can be applied to get widths to match. So if you want to do the "16+8" thing, you presumably first sign-extend the 8-bit number and then do the operation.

I feel like the orthogonal option would be my first instinct because it makes the actual semantics of operations a little clearer (which is more important for fixed-point and, eventually, floating point than it is for integers!). But there are possibly practical reasons why the exact-match restrictions would complicate the operations themselves.

@rachitnigam
Copy link
Contributor Author

Yeah, the Orthogonal approach is also what the CIRCT people seem to have adopted for now so seems reasonable. TLDR, the more magic we have in the primitives, the more complicated handling logic we need to write for passes.

@rachitnigam rachitnigam added S: Available Can be worked upon S: In progress Issue is being worked on and removed S: Discussion needed Issues blocked on discussion S: Available Can be worked upon labels Mar 15, 2021
@rachitnigam
Copy link
Contributor Author

This is done thanks to @cgyurgyik hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Library Calyx's standard library S: In progress Issue is being worked on
Projects
None yet
Development

No branches or pull requests

2 participants