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

Add support for the Zvksed extension #245

Open
wants to merge 11 commits into
base: vector-dev
Choose a base branch
from

Conversation

charmitro
Copy link
Contributor

Implements the Zvksed (ShangMi Suite: SM4 Block Cipher) extension, as of version Draft: 20230303

The following instructions are included:

  • vsm4k.vi
  • vsm4r.[vv,vs]

All instructions were tested with VLEN & ELEN being manually adjusted; results were compared with QEMU results of each instruction.

Current revision is rebased with the latest changes of vector-dev branch.

XinlaiWan and others added 3 commits March 22, 2023 09:01
…iscv#191)

* V extension general framework and configuration setting instructions

* Update model/riscv_insts_vext_utils.sail

fix a typo

Co-authored-by: Nicolas Brunie <nibrunie@gmail.com>
Signed-off-by: BrighterW <xinlai.w@rioslab.org>

* Update model/riscv_insts_vext_vset.sail

* Revisions after Nov 22 meeting

* Update effect matching for functions in riscv_vlen.sail

* Fix code formatting issues

* Update model/riscv_insts_vext_utils.sail

Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
Signed-off-by: Xinlai Wan <xinlai.w@rioslab.org>

* Fix coding style issues

* Update vset instructions

Signed-off-by: BrighterW <xinlai.w@rioslab.org>
Signed-off-by: Xinlai Wan <xinlai.w@rioslab.org>
Co-authored-by: Nicolas Brunie <nibrunie@gmail.com>
Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
* Add vector load / store instructions

* Modify the implementation of SEW, LMUL, VLEN and avoid real numbers in the code

* Update vstart setting in vector load / store instructions

* Remove unnecessary assert statements in vector instructions

* Fix bugs in vleff instructions and revise coding styles

* Add guards for vector encdec clauses, Avoid redundant memory access after vector load/store failure
* Add vector arithmetic & mask instructions

* Update vector EEW and EMUL checking function

* Add vector instruction illegal check functions

* Adjust code formatting for vector instruction illegal check functions

Merge approved by team at tech-golden-model meeting on 2023-03-14.
@charmitro
Copy link
Contributor Author

Updated the PR:

  • Correction on iterating based on the specification
  • Correctly Load & Store from/to vector registers

This update is adjusting the implementation to match the Spike implenentation and as a follow-up, ACT Signatures matching.

* Add vector floating-point instructions

* Update vector floating-point conversion instructions

* Update copyright headers for vector extension code

---------

Co-authored-by: xwan <xinlai.wan@rivai.ai>
@charmitro
Copy link
Contributor Author

Rebased from vector-dev branch.

@github-actions
Copy link

github-actions bot commented May 29, 2023

Unit Test Results

712 tests  ±0   712 ✔️ ±0   0s ⏱️ ±0s
    6 suites ±0       0 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit f4d9b88. ± Comparison against base commit 5872908.

♻️ This comment has been updated with latest results.

Copy link

@nibrunieAtSi5 nibrunieAtSi5 left a comment

Choose a reason for hiding this comment

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

LGTM

XinlaiWan and others added 7 commits June 12, 2023 14:28
* Add vector mask and reduction instructions

* Fix register overlap check in vector mask instructions

---------

Co-authored-by: xwan <xinlai.wan@rivai.ai>
To support the implementation of the Zvksed extension in SAIL, this
creates the necessary infrastructure (i.e., a file to hold it, and the
existence macro), preparing the tree for the Zvksed implementation.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Vector SM4 KeyExpansion, four rounds of the SM4 Key expansion
are performed.

Note: zvksed_box_lookup & zvksed_sm4_sbox are created to work with
32bit values since sbox_lookup & sm4_sbox are used for 8bit values.

The bits in uimm[4..3] are ignored. Round group numbers range from 0
to 7 and indicate which group of four round keys are being generated.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Vector SM4 Rounds, four rounds of SM4 Encryption/Decryption are
performed.

The four words of current state are read in as a 4-element group from
'vd' and the round keys are read in from the corresponding 4-element
group in vs2 (vector-vector form) or the scalar element group in
vs2 (vector-scalar form). The next four words of state are generated
by iteratively XORing the last three words of the state with the
corresponding round key, performing a byte-wise substitution, and then
performing XORs between rotated versions of this value and the
corresponding current state.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
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.

3 participants