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

Parameter and pinout cleanup #277 #278

Merged

Conversation

Silabs-ArjanB
Copy link
Contributor

Signed-off-by: Arjan Bink [email protected]

@Silabs-ArjanB
Copy link
Contributor Author

Needs to be done at the same time as openhwgroup/core-v-verif#85

@Silabs-ArjanB
Copy link
Contributor Author

Added back in the APU interface.

@davideschiavone
Copy link
Contributor

Thanks a lot @Silabs-ArjanB ,

few comments here:

  1. The tb/dm testbench hasn't been updated with the new interface and parameters

  2. Fixing PULP_SECURE to 0 makes the MTVEC(and MTVECx) tight to Boot Address, this makes the tests failing. It's a good example for issue mtvec is tied to boot_addr_i when PULP_SECURE=0 #254
    We need to fix mtvec is tied to boot_addr_i when PULP_SECURE=0 #254 before having this PR merged. So I opened in parallel a PR for mtvec is tied to boot_addr_i when PULP_SECURE=0 #254 , then you can merge it into your branch to have this point solved.

@Silabs-ArjanB
Copy link
Contributor Author

The status of the tb/dm is unclear to me. They already seemed out of date to begin with. Can you let me know which ones are actually in use and I will update them (some of them seem to have been copied into the core-v-verif repos instead).

Do you want me to work on #254?

@davideschiavone
Copy link
Contributor

PR for #254 is already here: #285
You just need to review.

tb/dm should just compile and work as before. The purpose is to provide an example to use GDB.
The tb folder will be replaced with the example name as its content is not for verification but just to provide quick examples. One with GDB/Debug and one with hello world.

@davideschiavone
Copy link
Contributor

@Silabs-ArjanB , as the PR #285 has been merged to master, the point 2. should be solved.

2. Fixing PULP_SECURE to 0 makes the MTVEC(and MTVECx) tight to Boot Address, this makes the tests failing. It's a good example for issue #254
   We need to fix #254 before having this PR merged. So I opened in parallel a PR for #254 , then you can merge it into your branch to have this point solved.

You should now merge the master to your branch and see if it solves the issue and address the point 1 here:

1. The tb/dm testbench hasn't been updated with the new interface and parameters

Thanks @Silabs-ArjanB

@Silabs-ArjanB
Copy link
Contributor Author

Cleaned up parameters and pinout in various testbenches.

  • make vsim-run in 'cv32e40p/tb/dm' now compiles without errors and warnings. C code comilation however fails (I expect it was already like this)

  • make custom-vsim-run in cv32e40p/tb/core now compiles without errors and warnings and executes okay as well.

  • I don't have verilator so I couldn't check those compile targets (but updated all testbenches)

  • make firmware-vsim-run-gui in cv32e40p/tb/core has gcc compilation issues (maybe a Makefile issue as 64-bit code is getting compiled it seems).

Could we open another ticket to get rid of the high amount of testbenches and duplication in cv32e40p. For example riscv_core is currently being instantiated in all of the following:

cv32e40p/tb/core/riscv_wrapper.sv
cv32e40p/tb/dm/tb_test_env.sv
cv32e40p/tb/dm/tb_top_verilator.sv
cv32e40p/tb/verilator-model/top.sv
cv32e40p/tb/tb_riscv/tb_riscv_core.sv

and riscv_wrapper for example is then being instantiated in

tb/core/tb_top.sv
tb/core/tb_top_verilator.sv

I updated all of the above but we should try to get rid of obsolete testbenches.

@davideschiavone
Copy link
Contributor

davideschiavone commented Apr 3, 2020

Hi @Silabs-ArjanB , my answers inline

Cleaned up parameters and pinout in various testbenches.

* make vsim-run in 'cv32e40p/tb/dm' now compiles without errors and warnings. C code comilation however fails (I expect it was already like this

It works for me

* make custom-vsim-run in cv32e40p/tb/core now compiles without errors and warnings and executes okay as well.

👍

* I don't have verilator so I couldn't check those compile targets (but updated all testbenches)

* make firmware-vsim-run-gui in cv32e40p/tb/core has gcc compilation issues (maybe a Makefile issue as 64-bit code is getting compiled it seems).

The problem is the RVA instructions emitted. As you tight to 0 the RVA parameter, you should also disable those instructions.
To do so, please remove them from firmware/start.S and from the Makefile variables
RISCV_TEST_INCLUDES and FIRMWARE_TEST_OBJS

Could we open another ticket to get rid of the high amount of testbenches and duplication in cv32e40p. For example riscv_core is currently being instantiated in all of the following:

cv32e40p/tb/core/riscv_wrapper.sv
cv32e40p/tb/dm/tb_test_env.sv
cv32e40p/tb/dm/tb_top_verilator.sv
cv32e40p/tb/verilator-model/top.sv
cv32e40p/tb/tb_riscv/tb_riscv_core.sv

and riscv_wrapper for example is then being instantiated in

tb/core/tb_top.sv
tb/core/tb_top_verilator.sv

I updated all of the above but we should try to get rid of obsolete testbenches.

Yes please go ahead. We already have a ticket to change name to the folder and clean it up. @MikeOpenHWGroup is porting the interrupt test. Then, we should only have an example of application and the debug connected.

@Silabs-ArjanB
Copy link
Contributor Author

Hi @davideschiavone , thank you for your feedback.

I will fix the RVA instruction issue as you described.

Can you be more specific about which parts I can remove please? For example, can I remove all of the following?

Files:

cv32e40p/tb/dm/tb_top_verilator.sv
tb/core/tb_top_verilator.sv

Directories:

cv32e40p/tb/verilator-model
cv32e40p/tb/serDiv
cv32e40p/tb/tb_MPU
cv32e40p/tb/tb_riscv

@davideschiavone
Copy link
Contributor

Hi @Silabs-ArjanB ,

Can we have that discussion in another thread/issue ?

Comment on lines +64 to +65
output logic [31:0] instr_addr_o,
input logic [31:0] instr_rdata_i,
Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing parameters here? Even if these widths must be fixed, there are a lot of magic numbers in the code and it would be a good idea to slowly replace them all. How about:

output logic                          instr_req_o,
input  logic                          instr_gnt_i,
input  logic                          instr_rvalid_i,
output logic [INSTR_ADDR_WIDTH -1:0]  instr_addr_o,
input  logic [INSTR_RDATA_WIDTH-1:0]  instr_rdata_i,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only instr_rdata_i had a parameter. There is no need to use a parameter for instr_addr_o. This will always be 32 bits wide. The use of INSTR_ADDR_WIDTH is debatable; I would not be against it but at the same time both cv32e40p and cv32e40 will have it set to 32.

@@ -91,8 +74,6 @@ module riscv_core
output logic [31:0] data_wdata_o,
Copy link
Member

Choose a reason for hiding this comment

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

More magic numbers. Consider replacing with parameter, even if these are intended to be fixed values for cv32e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a 32-bit core. Let's not go adding even more parameters

@@ -476,7 +476,7 @@ module riscv_core
.N_HWLP ( N_HWLP ),
.RDATA_WIDTH ( INSTR_RDATA_WIDTH ),
.FPU ( FPU ),
.DM_HaltAddress ( DM_HaltAddress )
.DM_HALTADDRESS ( DM_HALTADDRESS )
Copy link
Member

Choose a reason for hiding this comment

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

Nice. All caps for parameters is a good coding style.

@@ -561,7 +561,7 @@ module riscv_core
.A_EXTENSION ( A_EXTENSION ),
.APU ( APU ),
.FPU ( FPU ),
.Zfinx ( Zfinx ),
.PULP_ZFINX ( PULP_ZFINX ),
Copy link
Member

Choose a reason for hiding this comment

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

Dito.

@Silabs-ArjanB
Copy link
Contributor Author

Hi @Silabs-ArjanB ,

Can we have that discussion in another thread/issue ?

Sure

@Silabs-ArjanB
Copy link
Contributor Author

Fixed Makefile and firmware/start.S to no longer use non-supported instructions (i.e. atomics). Note that riscv_tests/rv32uc/rvc.S needed to be changed (as was done before) as it led to an internal compiler error.

@davideschiavone
Copy link
Contributor

For me it's ok to MERGE, just hitting @bluewww to ask him about the last change you have done in the RVC (he is the expert :) )

TEST(amoswap_w)
TEST(amoxor_w)
TEST(lrsc)

Copy link
Contributor

@bluewww bluewww Apr 7, 2020

Choose a reason for hiding this comment

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

Why is this removed? These test should work. Also I don't think a PR that is called cleanup should regress on features.

Copy link
Contributor

Choose a reason for hiding this comment

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

The RVA parameter has been set to 0 by default, so they generate illegal instructions now

@@ -715,7 +716,7 @@ module mm_ram
.req_core_i ( instr_req_i ),
.req_mem_o ( rnd_stall_instr_req ),

.addr_core_i ( 32'(instr_addr_i) ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this will generate a port mismatch warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The connections to riscv_random_stall were actually generating port mismatch warnings and they have been fixed by above change. The key is that I also added an ADDR_WIDTH parameter to riscv_random_stall so that it can be used in different context with potentially different address with requirements (so that we can make this warning free in every context).


#include "../rv64uc/rvc.S"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a copy paste of the ../rv64uc/rvc.S file? Why would you do this for this file, but then you don't do it for the others?

There is a very good reason the structure of the test files is like this (i.e. with the #includes from rv64uc). They are a verbatim import from https://github.com/riscv/riscv-tests meaning that whenever there is an update to the upstream test repository, you can easily import the diff. Now that you change the structure you have to apply fixes everytime you do this. This is just an unnecessary increase in maintenance cost.

All in all its inconsistent and a bad idea. I would highly suggest to revert this change and apply the fix to ../rv64uc/rvc.S which I guess is removing the .option norelax, a fix I mistakenly did because I compiled with -march=rv32im instead of imc I suspect.

Copy link
Contributor Author

@Silabs-ArjanB Silabs-ArjanB Apr 8, 2020

Choose a reason for hiding this comment

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

I fully agree that it is important to be able to enable a verbatim import from https://github.com/riscv/riscv-tests. That being said, the tests (together with our Makefile/compiler) were not compiling correctly.

The ./rv64uc/rvc.S and ./rv32uc/rvc.S file are not the same. Even on the master branch this test case led to a gcc internal error, so the starting point was a repos in which test cases were not compiling correctly.

I looked at what this test looked like roughly half a year ago and I re-applied the same change to get it to work. (This might be related to this issue: riscv-collab/riscv-gnu-toolchain#445)

diff ./rv64uc/rvc.S ./rv32uc/rvc.S
10a11,12

#undef RVTEST_RV64U
#define RVTEST_RV64U RVTEST_RV32U
16,18d17
< // riscv-collab/riscv-gnu-toolchain#445
< // mixed modes should turn of relaxation (?)
< .option norelax

Originally I also thought it had to do with the missing imc switch so I fixed that first. However, if we keep the test as it was the entire test suite will not run because I would still get the following error:

/tool/pulp_riscv_gnu_toolchain/2019.12/rhel6-64/bin/riscv32-unknown-elf-gcc -c -march=rv32imc -g -o riscv_tests/rv32uc/rvc.o
-Iriscv_tests/ -Iriscv_tests/macros/scalar
-DTEST_FUNC_NAME=rvc
-DTEST_FUNC_TXT='"rvc"'
-DTEST_FUNC_RET=rvc_ret riscv_tests/rv32uc/rvc.S
riscv32-unknown-elf-gcc: internal compiler error: Floating point exception (program as)
Please submit a full bug report,
with preprocessed source if appropriate.
See https://gcc.gnu.org/bugs/ for instructions.
make: *** [riscv_tests/rv32uc/rvc.o] Error 4

I will file a separate issue on the compilation issue with the rvc.S test (and I acknowledge that I should already have done that). In the mean time I think it is important to have the repos in a state that actually runs with 0 errors and 0 warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

This might also be a pulp-riscv-gnu-toolchain bug. I believe that the test worked with riscv-gnu-toolchain but I would have to check again.

@@ -42,7 +43,7 @@ module riscv_wrapper
logic [3:0] data_be;
logic [31:0] data_rdata;
logic [31:0] data_wdata;
logic [5:0] data_atop;
logic [5:0] data_atop = 'b0;
Copy link
Contributor

@bluewww bluewww Apr 7, 2020

Choose a reason for hiding this comment

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

indicate bitwidth. Should stay consistent in this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, will do

@@ -371,7 +369,7 @@ riscv_tests/rv32um/%.o: riscv_tests/rv32um/%.S riscv_tests/riscv_test.h \

riscv_tests/rv32uc/%.o: riscv_tests/rv32uc/%.S riscv_tests/riscv_test.h \
riscv_tests/macros/scalar/test_macros.h
$(RISCV_EXE_PREFIX)gcc -c -march=rv32im -g -o $@ \
$(RISCV_EXE_PREFIX)gcc -c -march=rv32imc -g -o $@ \
Copy link
Contributor

Choose a reason for hiding this comment

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

good

tb/core/Makefile Outdated
@@ -83,15 +83,13 @@ RISCV_EXE_PREFIX = $(RISCV)/bin/riscv32-unknown-elf-

# firmware vars
FIRMWARE = firmware/
RISCV_TEST_INCLUDES = -Iriscv_tests/ -Iriscv_tests/macros/scalar \
-Iriscv_tests/rv64ui -Iriscv_tests/rv64um -Iriscv_tests/rv64ua
Copy link
Contributor

@bluewww bluewww Apr 7, 2020

Choose a reason for hiding this comment

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

Revert this too, see comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed this should be reverted (which has been done now). The rv64* includes are however not actually being used yet as I am still not using the originally intended rvc.S (see discussion above). Once we get the rvc.S issue solved, then at least RISCV_TEST_INCLUDES will be already have the correct value.

@@ -30,7 +30,7 @@ VLOG_FLAGS = -pedanticerrors -suppress 2577 -suppress 2583
VLOG_LOG = vloggy

VOPT = vopt-$(VVERSION)
VOPT_FLAGS = -debugdb -fsmdebug -pedanticerrors #=mnprft
VOPT_FLAGS = -debugdb -fsmdebug +acc -pedanticerrors #=mnprft
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok this makes sense otherwise the defaults would be really useless.

.apu_master_flags_i ( ),

.apu_master_valid_i ( 1'b0 ),
.apu_master_result_i ( 'b0 ),
Copy link
Contributor

Choose a reason for hiding this comment

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

indicate bitwidth. Should stay consistent in this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (and made similar fixes in other places)

.apu_master_flags_i ( ),

.apu_master_valid_i ( 1'b0 ),
.apu_master_result_i ( 'b0 ),
Copy link
Contributor

Choose a reason for hiding this comment

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

indicate bitwidth

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tb/tb_riscv/riscv_random_stall.sv Show resolved Hide resolved
.apu_master_flags_i ( ),

.apu_master_valid_i ( 1'b0 ),
.apu_master_result_i ( 'b0 ),
Copy link
Contributor

Choose a reason for hiding this comment

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

indicate bitwidth

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Silabs-ArjanB Silabs-ArjanB requested a review from bluewww April 8, 2020 06:53
@davideschiavone
Copy link
Contributor

Actually, these changes in the RISCV_TESTS suite should be done in the core-verif repository, the only purpose of this "testbench" should be make hello world pass. So it's not wasted work as can be ported to core-verif, but probably we can ignore the them here

@davideschiavone davideschiavone merged commit 8666456 into openhwgroup:master Apr 10, 2020
@Silabs-ArjanB Silabs-ArjanB deleted the ArjanB_parameter_cleanup branch April 11, 2020 06:41
@Silabs-ArjanB Silabs-ArjanB restored the ArjanB_parameter_cleanup branch April 11, 2020 07:22
@Silabs-ArjanB Silabs-ArjanB deleted the ArjanB_parameter_cleanup branch April 14, 2020 14:33
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.

4 participants