Skip to content
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 Scalar Cryptography Extension (Crossbar permutation instructions, Zbkx) #2679

Closed
wants to merge 1 commit into from

Conversation

munailwaqar
Copy link
Contributor

Introduction

This PR adds support for Zbkx extension in the CVA6 core. It also adds the documentation and tests for this extension. These changes have been tested with self-written single instruction tests and with the riscv-arch-tests. This PR is part of a series of PRs that will add the complete support for the Zkn - NIST Algorithm Suite extension.

Implementation

Zbkx Extension:
Added support for the Zbkx instruction set. It essentially expands the Bitmanip extension with additional instructions useful in cryptography. These instructions are xperm8, xperm4.

Modifications

The complete Zkn extension will be added under the ZKN bit for ease of use. This configuration will also require the RVB (bitmanip) bit to be set.
Updated the ALU and decoder to recognize and handle Zbkx instructions.
Documentation and Reference
The official RISC-V Cryptography Extensions Volume I was followed to ensure alignment with ratification. The relevant documentation for the Zbkx instruction was also added.

Verification

Assembly Tests:
The instructions were tested and verified with the K module of both 32 bit and 64 bit versions of the riscv-arch-tests to ensure proper functionality. These tests check for ISA compliance, edge cases and use assertions to ensure expected behavior. The tests include:

  • xperm8-01.S
  • xperm4-01.S

Comment on lines +785 to +786
{7'b001_0100, 3'b100} : if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM8; else illegal_instr_bm = 1'b1; // xperm8
{7'b001_0100, 3'b010} : if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM4; else illegal_instr_bm = 1'b1; // xperm4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[verible-verilog-format] reported by reviewdog 🐶

Suggested change
{7'b001_0100, 3'b100} : if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM8; else illegal_instr_bm = 1'b1; // xperm8
{7'b001_0100, 3'b010} : if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM4; else illegal_instr_bm = 1'b1; // xperm4
{
7'b001_0100, 3'b100
} :
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM8;
else illegal_instr_bm = 1'b1; // xperm8
{
7'b001_0100, 3'b010
} :
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::XPERM4;
else illegal_instr_bm = 1'b1; // xperm4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant