From 900e66a80454fd7c112c8408a3c052fb4168da4b Mon Sep 17 00:00:00 2001 From: M0stafaRady Date: Sat, 22 Oct 2022 11:04:04 -0700 Subject: [PATCH] update gpio tests for caravan --- verilog/dv/cocotb/caravel_tests.py | 1 + verilog/dv/cocotb/caravel_top.sv | 2 + verilog/dv/cocotb/interfaces/common.py | 1 + verilog/dv/cocotb/interfaces/cpu.py | 5 ++ verilog/dv/cocotb/tests.json | 77 +++++++++++++++++--------- verilog/dv/cocotb/verify_cocotb.py | 9 ++- 6 files changed, 68 insertions(+), 27 deletions(-) diff --git a/verilog/dv/cocotb/caravel_tests.py b/verilog/dv/cocotb/caravel_tests.py index f1aabcc4..98169871 100644 --- a/verilog/dv/cocotb/caravel_tests.py +++ b/verilog/dv/cocotb/caravel_tests.py @@ -37,6 +37,7 @@ from tests.irq.IRQ_external import * from tests.irq.IRQ_timer import * from tests.irq.IRQ_uart import * from tests.gpio.gpio import * +from tests.gpio_caravan.gpio_caravan import * from tests.gpio.gpio_user import * from tests.mgmt_gpio.mgmt_gpio import * from tests.timer.timer import * diff --git a/verilog/dv/cocotb/caravel_top.sv b/verilog/dv/cocotb/caravel_top.sv index 1772ab64..30b73b60 100644 --- a/verilog/dv/cocotb/caravel_top.sv +++ b/verilog/dv/cocotb/caravel_top.sv @@ -371,4 +371,6 @@ reg [7:0] DM_INIT = `ifdef DM_INIT `DM_INIT `else 0 `endif; reg GL = `ifdef GL 1 `else 0 `endif; +reg CARAVAN = `ifdef CARAVAN 1 `else 0 `endif; + endmodule \ No newline at end of file diff --git a/verilog/dv/cocotb/interfaces/common.py b/verilog/dv/cocotb/interfaces/common.py index 76240f7e..b5d98414 100644 --- a/verilog/dv/cocotb/interfaces/common.py +++ b/verilog/dv/cocotb/interfaces/common.py @@ -74,6 +74,7 @@ def fill_macros(macros_hdl): Macros['MPRJ_IO_PADS_2'] = macros_hdl.MPRJ_IO_PADS_2.value.integer Macros['MPRJ_IO_PADS'] = macros_hdl.MPRJ_IO_PADS.value.integer Macros['GL'] = macros_hdl.GL.value.integer + Macros['CARAVAN'] = macros_hdl.CARAVAN.value.integer diff --git a/verilog/dv/cocotb/interfaces/cpu.py b/verilog/dv/cocotb/interfaces/cpu.py index b2bd6885..1f925370 100644 --- a/verilog/dv/cocotb/interfaces/cpu.py +++ b/verilog/dv/cocotb/interfaces/cpu.py @@ -193,6 +193,11 @@ class RiskV: def read_debug_reg2(self): return self.debug_hdl.debug_reg_2.value.integer + def read_debug_reg1_str(self): + return self.debug_hdl.debug_reg_1.value.binstr + def read_debug_reg2_str(self): + return self.debug_hdl.debug_reg_2.value.binstr + # writing debug registers using backdoor because in GL cpu can't be disabled for now because of different netlist names def write_debug_reg1_backdoor(self,data): self.debug_hdl.debug_reg_1.value = data diff --git a/verilog/dv/cocotb/tests.json b/verilog/dv/cocotb/tests.json index 411d1821..98150f1d 100644 --- a/verilog/dv/cocotb/tests.json +++ b/verilog/dv/cocotb/tests.json @@ -4,10 +4,16 @@ "_comment1" :"GL regressions run this test in gatelevel, GL_SDF regression run this test with SDF included" ,"gpio_all_i" :{"level":0, "SW":true, - "RTL":["r_rtl","r_caravan_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as mgmt input using automatic approach firmware and check them"} + ,"gpio_all_i_caravan" :{"level":0, + "SW":true, + "RTL":["r_caravan_rtl"], + "GL":["r_caravan_gl"], + "GL_SDF":[], + "description":"configure all gpios as mgmt input using automatic approach firmware and check them for caravan"} ,"hk_disable" :{"level":0, "SW":true, @@ -23,25 +29,33 @@ "description":"test uart reception"} ,"hk_regs_rst_spi" :{"level":0, "SW":false, - "RTL":["r_rtl","setup","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","push_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","push_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"check reset value of house keeping registers by reading them trough the spi housekeeping"} ,"gpio_all_i_user" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","r_caravan_rtl","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as user input using automatic approach firmware and check them"} ,"gpio_all_i_pu" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","r_caravan_rtl","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as mgmt input pull up using automatic approach firmware and check them"} + + ,"gpio_all_i_pu_caravan" :{"level":0, + "SW":true, + "RTL":["r_caravan_rtl"], + "GL":["r_caravan_gl"], + "GL_SDF":[], + "description":"configure all gpios as mgmt input pull up using automatic approach firmware and check them for caravan"} + ,"gpio_all_i_pu_user" :{"level":0, "SW":true, "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], @@ -51,15 +65,21 @@ ,"gpio_all_i_pd" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","r_caravan_rtl","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as mgmt input pull down using automatic approach firmware and check them"} + ,"gpio_all_i_pd_caravan" :{"level":0, + "SW":true, + "RTL":["r_caravan_rtl"], + "GL":["r_caravan_gl"], + "GL_SDF":[], + "description":"configure all gpios as mgmt input pull down using automatic approach firmware and check them for caravan"} ,"gpio_all_i_pd_user" :{"level":0, "SW":true, "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as user input pull down using automatic approach firmware and check them"} @@ -72,11 +92,18 @@ ,"gpio_all_o" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","r_caravan_rtl","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], - "GL":["r_gl","r_caravan_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], + "GL":["r_gl","push_gl","gpio_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"configure all gpios as mgmt output using automatic approach firmware and check them"} + ,"gpio_all_o_caravan" :{"level":0, + "SW":true, + "RTL":["r_caravan_rtl"], + "GL":["r_caravan_gl"], + "GL_SDF":[], + "description":"configure all gpios as mgmt output using automatic approach firmware and check them for caravan"} + ,"gpio_all_o_user" :{"level":0, "SW":true, "RTL":["r_rtl","setup","gpio_rtl","push","push_gl","nightly","weekly","tape_out"], @@ -153,8 +180,8 @@ ,"timer0_oneshot" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"check timer0 oneshot mode"} @@ -174,27 +201,27 @@ ,"uart_tx" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"test uart transmit"} ,"debug" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"use caravel in debug mode and check reading and writing from dff2 RAM"} ,"spi_master_rd" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"using SPI master for reading from external memory"} ,"user_pass_thru_rd" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"use the housekeeping spi in user pass thru mode to read from external mem"} @@ -214,8 +241,8 @@ ,"la" :{"level":0, "SW":true, - "RTL":["r_rtl","setup","nightly","weekly","tape_out"], - "GL":["r_gl","nightly","weekly","tape_out"], + "RTL":["r_rtl","r_caravan_rtl","setup","nightly","weekly","tape_out"], + "GL":["r_gl","r_caravan_gl","nightly","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"], "description":"check logic analyzer input and output enable"} diff --git a/verilog/dv/cocotb/verify_cocotb.py b/verilog/dv/cocotb/verify_cocotb.py index 346fd7fb..78282605 100755 --- a/verilog/dv/cocotb/verify_cocotb.py +++ b/verilog/dv/cocotb/verify_cocotb.py @@ -134,6 +134,7 @@ class RunTest: # vcs function def runTest_vcs(self): print(f"Start running test: {self.sim_type}-{self.test_name}") + CARAVEL_PATH = os.getenv('CARAVEL_PATH') PDK_ROOT = os.getenv('PDK_ROOT') PDK = os.getenv('PDK') VERILOG_PATH = os.getenv('VERILOG_PATH') @@ -168,8 +169,12 @@ class RunTest: os.environ["TESTCASE"] = f"{self.test_name}" os.environ["MODULE"] = f"caravel_tests" os.environ["SIM"] = self.sim_type - - os.system(f"vlogan -full64 -sverilog +error+30 caravel_top.sv {dirs} {macros} +define+TESTNAME=\\\"{self.test_name}\\\" +define+FTESTNAME=\\\"{self.full_test_name}\\\" +define+TAG=\\\"{os.getenv('RUNTAG')}\\\" -l {self.sim_path}/analysis.log -o {self.sim_path} ") + # user_project = f"-v {CARAVEL_PATH}/rtl/__user_project_wrapper.v" + # if caravan: + # print ("Use caravan") + # macros = f'+define+CARAVAN {macros} ' + # user_project = f"-v {CARAVEL_PATH}/rtl/__user_analog_project_wrapper.v" + os.system(f"vlogan -full64 -sverilog +error+30 caravel_top.sv {dirs} {macros} +define+TESTNAME=\\\"{self.test_name}\\\" +define+FTESTNAME=\\\"{self.full_test_name}\\\" +define+TAG=\\\"{os.getenv('RUNTAG')}\\\" -l {self.sim_path}/analysis.log -o {self.sim_path} ") os.system(f"vcs +lint=TFIPC-L {coverage_command} +error+30 -R -diag=sdf:verbose +sdfverbose +neg_tchk -debug_access -full64 -l {self.sim_path}/test.log caravel_top -Mdir={self.sim_path}/csrc -o {self.sim_path}/simv +vpi -P pli.tab -load $(cocotb-config --lib-name-path vpi vcs)") self.passed = search_str(self.test_log.name,"Test passed with (0)criticals (0)errors") Path(f'{self.sim_path}/{self.passed}').touch()