Skip to content

Circuits should assume that IMM is a 20 bit value #7

@Janmajayamall

Description

@Janmajayamall

IMM is 20 bit value that is used in two different manners across multiple operations. First manner, IMM is sign extended to 32 bits. Second manner, IMM is left shifted by 12 bits ( that is, the actual 20 bits occupy the most top 20 bits of the resulting value ).

Some circuits that work with IMM assume that IMM is preprocessed into a 32 bit value. For instance, since same add circuit is used for ADD and ADD_I operation, ADD_I circuit assumes that IMM is preprocessed into a 32 bit value. On the other hand, some circuits assume that IMM is a 20 bit value ( PC_UPDATE, for instance ). The choice seems arbitrary.

There's also additional cost to preprocessing IMM to fit into the circuit. We pay it either when retrieving IMM from RAM or at runtime ( to sign extend, etc.).

I find it better to by default assume that IMM is a 20 value. This means we cannot re-use add and other arithmetic circuits defined for rs1,rs2 ops for immediate counterparts. But that's ok! Immediate counterparts will be slightly more efficient anyways.

One drawback of this is that it slightly less than doubles the no. of codegen files. But this is a different problem that can be solved by doing the codegen at compile time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions