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 atomic to rvfi_instr_if, expand/divide the support pkg #2093

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/support/isa_constants.sv
silabs-robin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, 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
//
// https://solderpad.org/licenses/
//
// 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.

// -------------------------------------------------------------------
// This file holds constants related to the ISA
// -------------------------------------------------------------------
17 changes: 17 additions & 0 deletions lib/support/isa_constants_csr.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, 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
//
// https://solderpad.org/licenses/
//
// 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.

// -------------------------------------------------------------------
// This file holds constants related to the CSRs in the ISA.
// -------------------------------------------------------------------
26 changes: 26 additions & 0 deletions lib/support/isa_functions.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, 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
//
// https://solderpad.org/licenses/
//
// 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.

// -------------------------------------------------------------------
// This file holds functions related to the ISA
// -------------------------------------------------------------------

`include "isa_constants.sv"
`include "isa_constants_csr.sv"
`include "isa_tdefs.sv"
`include "isa_tdefs_csr.sv"
`include "isa_support.sv" //TODO: krdosvik, change name to isa_disassembler when no outstanding PR


//TODO: krdosvik, add function when A disassembler PR is in.
17 changes: 17 additions & 0 deletions lib/support/isa_tdefs.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, 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
//
// https://solderpad.org/licenses/
//
// 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.

// -------------------------------------------------------------------
// This file holds typedefs related to the ISA
// -------------------------------------------------------------------
17 changes: 17 additions & 0 deletions lib/support/isa_tdefs_csr.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, 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
//
// https://solderpad.org/licenses/
//
// 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.

// -------------------------------------------------------------------
// This file holds typedefs related to the CSRs in the ISA.
// -------------------------------------------------------------------
7 changes: 6 additions & 1 deletion lib/support/support_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@


package support_pkg;
`include "isa_support.sv"
`include "isa_constants.sv"
`include "isa_constants_csr.sv"
`include "isa_tdefs.sv"
`include "isa_tdefs_csr.sv"
`include "isa_support.sv" //TODO: krdosvik, change name to isa_disassembler when no outstanding PR
`include "isa_functions.sv"
Copy link
Contributor

Choose a reason for hiding this comment

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

The includes in isa_functions.sv are also already included above this line.

Copy link
Author

Choose a reason for hiding this comment

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

You mean isa_function is indirectly included by including the isa_support.sv? If that is what you mean: I didnt think about that, is that a problem? If not I think it is more readable to explicitly define what is meant to be included in the package, even though files might already include them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regardless of the above, all these files needs compile-guards, otherwise there will be issues down the line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Beware of dangers like this:
If 1) an include file has guards, and 2) compilation of all source files is done as one "compilation unit", and 3) two other files include that include file, then C) only one of those other files will get any actual content from the include file.

endpackage

`endif // __SUPPORT_PKG_SV__
Expand Down
65 changes: 60 additions & 5 deletions lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ interface uvma_rvfi_instr_if_t
localparam INSTR_MASK_DIV_REM = 32'h FE00_607F;
localparam INSTR_MASK_FULL = 32'h FFFF_FFFF;
localparam INSTR_MASK_R_TYPE = 32'h FE00_707F;
localparam INSTR_MASK_AMO_TYPE = 32'h F800_707F;
localparam INSTR_MASK_I_S_B_TYPE = 32'h 0000_707F;
localparam INSTR_MASK_U_J_TYPE = 32'h 0000_007F;
localparam INSTR_MASK_CSRADDR = 32'h FFF0_0000;
Expand Down Expand Up @@ -167,6 +168,18 @@ interface uvma_rvfi_instr_if_t
localparam INSTR_OPCODE_CMPOPRET = 32'b 00000000_00000000_101_11110_0000_00_10;
localparam INSTR_OPCODE_CMPOPRETZ = 32'b 00000000_00000000_101_11100_0000_00_10;

localparam INSTR_OPCODE_LRW = 32'b 00010_0_0_00000_00000_010_00000_0101111;
silabs-hfegran marked this conversation as resolved.
Show resolved Hide resolved
localparam INSTR_OPCODE_SCW = 32'b 00011_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOSWAPW = 32'b 00001_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOADDW = 32'b 00000_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOXORW = 32'b 00100_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOANDW = 32'b 01100_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOORW = 32'b 01000_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOMINW = 32'b 10000_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOMAXW = 32'b 10100_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOMINUW = 32'b 11000_0_0_00000_00000_010_00000_0101111;
localparam INSTR_OPCODE_AMOMAXUW = 32'b 11100_0_0_00000_00000_010_00000_0101111;

//positions
localparam int INSTR_CSRADDR_POS = 20;
localparam int INSTR_CSRUIMM_POS = 15;
Expand Down Expand Up @@ -237,6 +250,8 @@ interface uvma_rvfi_instr_if_t
logic is_nmi_triggered;
logic is_load_instr;
logic is_store_instr;
logic is_amo_instr;
logic is_atomic_instr;
logic is_loadstore_instr;
logic is_exception;
logic is_load_acc_fault;
Expand Down Expand Up @@ -346,6 +361,25 @@ interface uvma_rvfi_instr_if_t
is_store_instr = rvfi_valid && |rvfi_mem_wmask_intended;
end

always_comb begin
is_amo_instr = rvfi_valid && (
match_instr(INSTR_OPCODE_AMOSWAPW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOADDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOXORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOANDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINUW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXUW, INSTR_MASK_AMO_TYPE));
end

always_comb begin
is_atomic_instr = rvfi_valid && (is_amo_instr ||
match_instr(INSTR_OPCODE_SCW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_LRW, INSTR_MASK_AMO_TYPE));
end

always_comb begin
is_loadstore_instr = is_load_instr || is_store_instr;
end
Expand Down Expand Up @@ -840,7 +874,17 @@ function automatic logic [4*NMEM-1:0] rvfi_mem_rmask_intended_f();
match_instr(INSTR_OPCODE_CLWSP, INSTR_MASK_CMPR) ||
match_instr(INSTR_OPCODE_CMPOP, INSTR_MASK_ZC_PUSHPOP) ||
match_instr(INSTR_OPCODE_CMPOPRET, INSTR_MASK_ZC_PUSHPOP) ||
match_instr(INSTR_OPCODE_CMPOPRETZ, INSTR_MASK_ZC_PUSHPOP);
match_instr(INSTR_OPCODE_CMPOPRETZ, INSTR_MASK_ZC_PUSHPOP) ||
match_instr(INSTR_OPCODE_LRW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOSWAPW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOADDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOXORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOANDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINUW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXUW, INSTR_MASK_AMO_TYPE);

rmask[0][2] = rmask[0][3];

Expand Down Expand Up @@ -918,10 +962,21 @@ function automatic logic [4*NMEM-1:0] rvfi_mem_wmask_intended_f();
rlist = rvfi_insn[7:4];

wmask[0][3] =
match_instr(INSTR_OPCODE_SW, INSTR_MASK_I_S_B_TYPE) ||
match_instr(INSTR_OPCODE_CSW, INSTR_MASK_CMPR) ||
match_instr(INSTR_OPCODE_CSWSP, INSTR_MASK_CMPR) ||
match_instr(INSTR_OPCODE_PUSH, INSTR_MASK_ZC_PUSHPOP);
match_instr(INSTR_OPCODE_SW, INSTR_MASK_I_S_B_TYPE) ||
match_instr(INSTR_OPCODE_CSW, INSTR_MASK_CMPR) ||
match_instr(INSTR_OPCODE_CSWSP, INSTR_MASK_CMPR) ||
match_instr(INSTR_OPCODE_PUSH, INSTR_MASK_ZC_PUSHPOP) ||
match_instr(INSTR_OPCODE_SCW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOSWAPW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOADDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOXORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOANDW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOORW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMINUW, INSTR_MASK_AMO_TYPE) ||
match_instr(INSTR_OPCODE_AMOMAXUW, INSTR_MASK_AMO_TYPE);


wmask[0][2] = wmask[0][3];

Expand Down