-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for ZCMT Extension for Code-Size Reduction in CVA6 #2659
base: master
Are you sure you want to change the base?
Conversation
❌ failed run, report available here. |
Hi @JeanRochCoulon how can we know which line in the code this spyglass failure refers to? |
@ASintzoff do you know how to help ? |
❌ failed run, report available here. |
❌ failed run, report available here. |
❌ failed run, report available here. |
5973264
to
645d24f
Compare
❌ failed run, report available here. |
@JeanRochCoulon |
is the extension completely optional? All the RTL added for Zcmt should be removed when the extension is not set. If not, it can increase the gate count. |
❌ failed run, report available here. |
1 similar comment
❌ failed run, report available here. |
❌ failed run, report available here. |
✔️ successful run, report available here. |
5c681dc
to
2b395d1
Compare
@farhan-108 can you rebase ? (mandatory to merge) |
2b395d1
to
964b2b8
Compare
@JeanRochCoulon Done |
❌ failed run, report available here. |
✔️ successful run, report available here. |
I have restarted the failed job and it passed. The remainder of the jobs (which were blocked by the failed job) are now running. |
✔️ successful run, report available here. |
Introduction
This PR implements the ZCMT extension in the CVA6 core, targeting the 32-bit embedded-class platforms. ZCMT is a code-size reduction feature that utilizes compressed table jump instructions (cm.jt and cm.jalt) to reduce code size for embedded systems
Note: Due to implementation complexity, ZCMT extension is primarily targeted at embedded class CPUs. Additionally, it is not compatible with architecture class profiles.(Ref. Unprivilege spec 27.20)
Key additions
Added zcmt_decoder module for compressed table jump instructions: cm.jt (jump table) and cm.jalt (jump-and-link table)
Implemented the Jump Vector Table (JVT) CSR to store the base address of the jump table in csr_reg module
Implemented a return address stack, enabling cm.jalt to behave equivalently to jal ra (jump-and-link with return address), by pushing the return address onto the stack in zcmt_decoder module
Implementation in CVA6
The implementation of the ZCMT extension involves the following major modifications:
compressed decoder
The compressed decoder scans and identifies the cm.jt and cm.jalt instructions, and generates signals indicating that the instruction is both compressed and a ZCMT instruction.
zcmt_decoder
A new zcmt_decoder module was introduced to decode the cm.jt and cm.jalt instructions, fetch the base address of the JVT table from JVT CSR, extract the index and construct jump instructions to ensure efficient integration of the ZCMT extension in embedded platforms. Table.1 shows the IO port connection of zcmt_decoder module. High-level block diagram of zcmt implementation in CVA6 is shown in Figure 1.
Table. 1 IO port connection with zcmt_decoder module
branch unit condition
A condition is implemented in the branch unit to ensure that ZCMT instructions always cause a misprediction, forcing the program to jump to the calculated address of the newly constructed jump instruction.
JVT CSR
A new JVT csr is implemented in csr_reg which holds the base address of the JVT table. The base address is fetched from the JVT CSR, and combined with the index value to calculate the effective address.
No MMU
Embedded platform does not utilize the MMU, so zcmt_decoder is connected with cache through port 0 of the Dcache module for implicit read access from the memory.
Figure. 1 High level block diagram of ZCMT extension implementation
Known Limitations
The implementation targets 32-bit instructions for embedded-class platforms without an MMU. Since the core does not utilize an MMU, it is leveraged to connect the zcmt_decoder to the cache via port 0.
Testing and Verification
Test Plan
A test plan is developed to test the functionality of ZCMT extension along with JVT CSR. Directed Assembly test executed to check the functionality.
Table. 2 Test plan
Note: Please find the test under CVA6_REPO_DIR/verif/tests/custom/zcmt"