Zcmp extension support
Created by: rohan-10xe
Zcmp Extension
Introduction
This PR is adding a set of instructions(cm.push, cm.pop, cm.popret, cm.popretz, cm.mvsa01, and cm.mva01s) that may be executed as a series of existing 32-bit RISC-V instructions. The objective is to reduce the overall code size for embedded platforms.
Adding Support in CVA6
Since the new set of instructions is executed as a series of existing 32-bit instructions we need a special sequential decoder that stalls the fetching of a new instruction until all the corresponding instructions are generated (one instruction in every cycle) and issued.
This new decoder extends the existing compressed decoder and the main decoder in the instruction decode stage.
Our new zcmp_decoder has the following important features:
It has an input signal to indicate that the current instruction is a zcmp instruction and needs to be decoded into a series of 32-bit instructions.
It has an input signal from the Issue Stage indicating the last issued instruction has been acknowledged. So, we can decode and send the next instruction in the series.
It has an output signal to indicate that the zcmp decoder is busy decoding the current instruction into a series of instructions and instruction fetching should be stalled as long as it is busy.
Design Changes
compressed_decoder
Updated the compressed decoder to indicate that the current compressed instruction is of zcmp extension.
id_stage
As mentioned we need to instantiate and connect our new zcmp_decoder between the compressed decoder and the main larger decoder when the zcmp extension is enabled in the cva6 configuration. Furthermore, we need to stall the fetching of new instructions until our zcmp_decoder is busy.
Test Plan
Sr. No. | Test Name | Description | Passing Criteria | Status |
---|---|---|---|---|
1 | C_test | A simple program in C where we call a method to add two numbers and return true if the result is correct | The program executes successfully with zcmp extension instructions in asm file | Pending |
2 | Cm_push_pop_test | A simple assembly program where cm.push and cm.pop is used instead of the push/pop instructions | The program behaves the same way when used push/pop instructions | Passing |
3 | Cm_popretz_test | A simple assembly program where cm.popretz is used instead of the pop and ret instructions | The program behaves the same way when used pop and ret instructions | Passing |
4 | Cm_popret_test | A simple assembly program where cm.popret is used instead of pop and ret instructions | The program behaves the same way when used pop and ret instructions | Passing |
5 | Cm_mvsa01_test | A simple assembly program where cm.mvsa01 instruction is used instead of pairs of c.mv | The program behaves the same way when used pairs of c.mv instructions | Passing |
6 | Cm_mva01s_test | A simple assembly program where cm.mva01s instruction is used instead of pairs of c.mv | The program behaves the same way when used pairs of c.mv instructions | Passing |
Please find the tests under CVA6_REPO_DIR/verif/tests/custom/Zcmp/ along with the command to build the test binary file.