pc2 / sus-compiler

A new Hardware Design Language that keeps you in the driver's seat
GNU General Public License v3.0
70 stars 4 forks source link

List of "Guaranteed Optimizations" in SUS #4

Open VonTum opened 3 months ago

VonTum commented 3 months ago

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.

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.