Skip to content

Instantly share code, notes, and snippets.

@widlarizer
Created April 10, 2024 22:19
Show Gist options
  • Save widlarizer/a5f161f607f53cf8d89dabb9c793cc16 to your computer and use it in GitHub Desktop.
Save widlarizer/a5f161f607f53cf8d89dabb9c793cc16 to your computer and use it in GitHub Desktop.
big $macc with fries

Big $macc with fries

Oddities of the yosys $macc cell. To all "losses" in modifications, add in your head the necessity of creating a v2 cell with compatibility wrapping of some kind.

Factor length field has variable bit length

Length of the factor length fields, known as variable num_bits in docs and code, is recorded in the CONFIG parameter and capped at effectively 15. We can set it to const 16 for example, simplifying CONFIG parsing.

Gains: simplifies from_cell, to_cell, simlib.v,

Losses: RTLIL becomes slightly less size efficient for $macc, which is typically an internal-only cell.

Zero length second factors

Second factors having zero length is special cased as if they were fed with a constant 1.

Gains: simplifies everything around macc

Losses: techmap limitations? Adds constant 1 whenever a simple unmultiplied addition is folded into $macc

Redundant B port

The B port, also called bit_ports in struct Macc, containts single bit unmultiplied summands and is equivalent and in the current codebase always considered equivalent. The optimize method of struct Macc shows that it's preferred over having single bit summands be part of the A port.

Gains: simplifies everything around macc

Losses: techmap limitations? Same as above, plus harder to special case carry aware hardware?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment