pc2 / pc2/sus-compiler

List of "Guaranteed Optimizations" in SUS

Open
#4 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue Language Design
Dominant language
Rust
Stars
126
Forks
6
PR merge metrics
No merged PRs in 30d

Description

So SUS is not doing optimization for the most part. The reason is mostly that the compiler can't know the developer's intention and thus can't know that it is actually optimizing. Be it for area, logic/register use, congestion, or critical timing paths.

However, what I do intend for SUS is to have a limited list of "Guaranteed Optimizations". These are there to reduce the number of distinct concepts (eliminating integer wire cutoffs as in Verilog for instance), or to undo pessimizations the Language's syntax forced upon the user.

  • Divisions & multiplies by constant powers of 2 are optimized to bitshifts (which is just wires)
  • Modulo by constant power of 2 also just becomes cutting of wires
  • Elimination of conditions on multiplexer if all valid Mux inputs are identical.

To illustrate that last one, take the following code:

module UseFIFO {
    interface pushData : bool pushValid, int data

    FIFO::<DEPTH=32; int> myFifo
    
    if pushValid {
        myFifo.push(data);
    }

    // ... pop blah blah
}

On myFIFO.data, there is a dependency from pushValid, just because it happens to be in a conditional scope because we only want to call myFifo.push(int data) when pushValid. While any synthesis tool probably optimizes the condition out as well (as the alternative is 'x), it still affects Latency Counting. It could be that data is available earlier than the condition, and we don't want to add an unnecessary dependency on that.

On the other hand, for looking at the waveform it might be nicer to preserve this 'x information, so I'm still not entirely decided on this one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are identified. Clarify which guaranteed optimizations are in scope and decide whether mux-condition elimination should preserve “x” waveform information; completion would be an agreed implementation plan.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.