-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds support for the following extension:
Zcb (code reduction): since no gcc support is in the mainline assembler yet these instructions are injected as raw data. Coverage class has been extended with these instructions and the illegal instruction class should not be able to generate legal Zcb instruction if the extension is enabled. Zfh (half-precision floats): Similarly to single and double precission, RISC-V now support half-precission is now supported. Most things are identical to the F & D extension which is why the pre-existing floating_point class was extended rather than a separate class. Inital coverage support has also been added. If testing with OVPsim the Jan 2023 version has a bug for FMV_X_H. Zbkb (crypto): The complementary instruction not defined in Zbb has been added to the instruction generator. This required a few instructions which were previously defined in the non-ratified bitmanip instruction class to be moved to Zbkb. I believe this makes more sense since Zbkb is ratified. Inital coverage has also been added for these instructions. Zfa: Instructions has been defined for Zfa, more work will follow once OVPsim supports this extension. The illegal instruction class has seen the following bug fixes: 1) Not all legal op-codes were considered for compressed floating instructions leading to leagal instructions being injected in undesired locations (sometimes overwriting stack-pointer since no reserved gpr check was performed). 2) ldsp and lqsp are only reserved at some XLENs. ovpsim_log_to_trace: Fixed a bug where some CSRs were not considered CSRs but GPRs run.py: Fixed bug in the regex replace, not all C's in the march string should be replaced since that breaks all zc... extension substrings. load_store_instr_lib: Added the Zcb load and store instructions to this class. riscv_instr_pkg: Added new extensions and instructions. Fixed bug introduced in aee6c4d where "Push USP from gpr.SP onto the kernel stack" should be XLEN dependent and not hardcoded to +-4.
- Loading branch information
1 parent
b09bb67
commit 5e72708
Showing
28 changed files
with
1,439 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Copyright 2018 Google LLC | ||
* Copyright 2021 Silicon Labs, Inc. | ||
* Copyright 2023 Frontgrade Gaisler | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
class riscv_zbkb_instr extends riscv_instr; | ||
`uvm_object_utils(riscv_zbkb_instr) | ||
|
||
function new(string name = ""); | ||
super.new(name); | ||
endfunction : new | ||
|
||
virtual function void set_rand_mode(); | ||
super.set_rand_mode(); | ||
case (format) inside | ||
I_FORMAT: begin | ||
has_imm = 1'b0; | ||
end | ||
endcase | ||
endfunction : set_rand_mode | ||
|
||
function void pre_randomize(); | ||
super.pre_randomize(); | ||
endfunction | ||
|
||
virtual function string convert2asm(string prefix = ""); | ||
string asm_str_final; | ||
string asm_str; | ||
|
||
asm_str = format_string(get_instr_name(), MAX_INSTR_STR_LEN); | ||
|
||
case (format) | ||
I_FORMAT : begin // instr rd rs1 | ||
if (!has_imm) begin | ||
asm_str_final = $sformatf("%0s%0s, %0s", asm_str, rd.name(), rs1.name()); | ||
end | ||
end | ||
|
||
R_FORMAT : begin // instr rd rs1 | ||
if (!has_rs2) begin | ||
asm_str_final = $sformatf("%0s%0s, %0s", asm_str, rd.name(), rs1.name()); | ||
end | ||
end | ||
|
||
default: `uvm_info(`gfn, $sformatf("Unsupported format %0s", format.name()), UVM_LOW) | ||
endcase | ||
|
||
if (asm_str_final == "") begin | ||
return super.convert2asm(prefix); | ||
end | ||
|
||
if (comment != "") begin | ||
asm_str_final = { asm_str_final, " #", comment }; | ||
end | ||
|
||
return asm_str_final.tolower(); | ||
|
||
endfunction : convert2asm | ||
|
||
function bit[6:0] get_opcode(); | ||
case (instr_name) inside | ||
default : get_opcode = super.get_opcode(); | ||
PACK : get_opcode = 7'b0110011; | ||
PACKH : get_opcode = 7'b0110111; | ||
PACKW : get_opcode = 7'b0111011; | ||
BREV8 : get_opcode = 7'b0010011; | ||
ZIP : get_opcode = 7'b0010011; | ||
UNZIP : get_opcode = 7'b0010011; | ||
endcase | ||
endfunction : get_opcode | ||
|
||
virtual function bit [2:0] get_func3(); | ||
case (instr_name) inside | ||
PACK : get_func3 = 3'b100; | ||
PACKH : get_func3 = 3'b111; | ||
PACKW : get_func3 = 3'b100; | ||
BREV8 : get_func3 = 3'b101; | ||
ZIP : get_func3 = 3'b001; | ||
UNZIP : get_func3 = 3'b101; | ||
default : get_func3 = super.get_func3(); | ||
endcase | ||
endfunction : get_func3 | ||
|
||
virtual function bit [4:0] get_func5(); | ||
case (instr_name) inside | ||
BREV8 : get_func5 = 5'b00111; | ||
ZIP : get_func5 = 5'b01111; | ||
UNZIP : get_func5 = 5'b01111; | ||
endcase | ||
endfunction : get_func5 | ||
|
||
virtual function bit [6:0] get_func7(); | ||
case (instr_name) inside | ||
PACK : get_func7 = 7'b0000100; | ||
PACKH : get_func7 = 7'b0000100; | ||
PACKW : get_func7 = 7'b0000100; | ||
BREV8 : get_func7 = 7'b0110100; | ||
ZIP : get_func7 = 7'b0000100; | ||
UNZIP : get_func7 = 7'b0000100; | ||
default : get_func7 = super.get_func7(); | ||
endcase | ||
endfunction : get_func7 | ||
|
||
virtual function string convert2bin(string prefix = ""); | ||
string binary = ""; | ||
|
||
case (format) | ||
R_FORMAT: begin | ||
binary = $sformatf("%8h", {get_func7(), rs2, rs1, get_func3(), rd, get_opcode()}); | ||
end | ||
|
||
I_FORMAT: begin | ||
binary = $sformatf("%8h", {get_func7(), get_func5(), rs1, get_func3(), rd, get_opcode()}); | ||
end | ||
|
||
default: begin | ||
if (binary == "") begin | ||
binary = super.convert2bin(prefix); | ||
end | ||
end | ||
|
||
endcase // case (format) | ||
endfunction : convert2bin | ||
|
||
virtual function bit is_supported(riscv_instr_gen_config cfg); | ||
return (cfg.enable_zbkb_extension && | ||
(RV32ZBKB inside { supported_isa } || RV64ZBKB inside { supported_isa }) && | ||
instr_name inside { | ||
PACK, PACKH, PACKW, BREV8, ZIP, UNZIP | ||
}); | ||
endfunction : is_supported | ||
|
||
endclass : riscv_zbkb_instr |
Oops, something went wrong.