Add hk_regs_wr_wb_cpu test

This commit is contained in:
M0stafaRady 2022-10-04 03:24:15 -07:00
parent ef9c2e408b
commit 11330823b7
4 changed files with 276 additions and 2 deletions

View File

@ -77,7 +77,12 @@
"GL_SDF":["r_sdf","weekly","tape_out"], "GL_SDF":["r_sdf","weekly","tape_out"],
"SW":true, "SW":true,
"description":"Same as bitbang_cpu_all_i but configure the gpio using the SPI not the firmware"} "description":"Same as bitbang_cpu_all_i but configure the gpio using the SPI not the firmware"}
,"hk_regs_wr_wb_cpu" :{"level":0,
"SW":false,
"RTL":["r_rtl","setup","push","push_gl","nightly","weekly","tape_out"],
"GL":["r_gl","push_gl","nightly","weekly","tape_out"],
"GL_SDF":["r_sdf","weekly","tape_out"],
"description":"bit bash test for housekeeping registers"}
,"hk_regs_wr_wb" :{"level":0, ,"hk_regs_wr_wb" :{"level":0,
"SW":false, "SW":false,
"RTL":["r_rtl","setup","push","push_gl","nightly","weekly","tape_out"], "RTL":["r_rtl","setup","push","push_gl","nightly","weekly","tape_out"],

View File

@ -0,0 +1,249 @@
#include <defs.h>
#include <stub.c>
// access all housekeeping registers that can be access through firmware and change it's value
void main(){
reg_wb_enable =1; // for enable writing to reg_debug_1 and reg_debug_2
reg_debug_1 = 0x0;
reg_debug_2 = 0x0;
// write 1 ones to all registers
reg_mprj_io_0 = 0x1FFF;
reg_mprj_io_1 = 0x1FFF;
reg_mprj_io_2 = 0x1FFF;
reg_mprj_io_3 = 0x1FFF;
reg_mprj_io_4 = 0x1FFF;
reg_mprj_io_5 = 0x1FFF;
reg_mprj_io_6 = 0x1FFF;
reg_mprj_io_7 = 0x1FFF;
reg_mprj_io_8 = 0x1FFF;
reg_mprj_io_9 = 0x1FFF;
reg_mprj_io_10 = 0x1FFF;
reg_mprj_io_11 = 0x1FFF;
reg_mprj_io_12 = 0x1FFF;
reg_mprj_io_13 = 0x1FFF;
reg_mprj_io_14 = 0x1FFF;
reg_mprj_io_15 = 0x1FFF;
reg_mprj_io_16 = 0x1FFF;
reg_mprj_io_17 = 0x1FFF;
reg_mprj_io_18 = 0x1FFF;
reg_mprj_io_19 = 0x1FFF;
reg_mprj_io_20 = 0x1FFF;
reg_mprj_io_21 = 0x1FFF;
reg_mprj_io_22 = 0x1FFF;
reg_mprj_io_23 = 0x1FFF;
reg_mprj_io_24 = 0x1FFF;
reg_mprj_io_25 = 0x1FFF;
reg_mprj_io_26 = 0x1FFF;
reg_mprj_io_27 = 0x1FFF;
reg_mprj_io_28 = 0x1FFF;
reg_mprj_io_29 = 0x1FFF;
reg_mprj_io_30 = 0x1FFF;
reg_mprj_io_31 = 0x1FFF;
reg_mprj_io_32 = 0x1FFF;
reg_mprj_io_33 = 0x1FFF;
reg_mprj_io_34 = 0x1FFF;
reg_mprj_io_35 = 0x1FFF;
reg_mprj_io_36 = 0x1FFF;
reg_mprj_io_37 = 0x1FFF;
// read ones that has been written
if (reg_mprj_io_0 != 0x1FFF)
reg_debug_1 =0x1;
if (reg_mprj_io_1 != 0x1FFF)
reg_debug_1 =0x2;
if (reg_mprj_io_2 != 0x1FFF)
reg_debug_1 =0x3;
if (reg_mprj_io_3 != 0x1FFF)
reg_debug_1 =0x4;
if (reg_mprj_io_4 != 0x1FFF)
reg_debug_1 =0x5;
if (reg_mprj_io_5 != 0x1FFF)
reg_debug_1 =0x6;
if (reg_mprj_io_6 != 0x1FFF)
reg_debug_1 =0x7;
if (reg_mprj_io_7 != 0x1FFF)
reg_debug_1 =0x8;
if (reg_mprj_io_8 != 0x1FFF)
reg_debug_1 =0x9;
if (reg_mprj_io_9 != 0x1FFF)
reg_debug_1 =0xa;
if (reg_mprj_io_10 != 0x1FFF)
reg_debug_1 =0xb;
if (reg_mprj_io_11 != 0x1FFF)
reg_debug_1 =0xc;
if (reg_mprj_io_12 != 0x1FFF)
reg_debug_1 =0xd;
if (reg_mprj_io_13 != 0x1FFF)
reg_debug_1 =0xe;
if (reg_mprj_io_14 != 0x1FFF)
reg_debug_1 =0xf;
if (reg_mprj_io_15 != 0x1FFF)
reg_debug_1 =0x10;
if (reg_mprj_io_16 != 0x1FFF)
reg_debug_1 =0x11;
if (reg_mprj_io_17 != 0x1FFF)
reg_debug_1 =0x12;
if (reg_mprj_io_18 != 0x1FFF)
reg_debug_1 =0x13;
if (reg_mprj_io_19 != 0x1FFF)
reg_debug_1 =0x14;
if (reg_mprj_io_20 != 0x1FFF)
reg_debug_1 =0x15;
if (reg_mprj_io_21 != 0x1FFF)
reg_debug_1 =0x16;
if (reg_mprj_io_22 != 0x1FFF)
reg_debug_1 =0x17;
if (reg_mprj_io_23 != 0x1FFF)
reg_debug_1 =0x18;
if (reg_mprj_io_24 != 0x1FFF)
reg_debug_1 =0x19;
if (reg_mprj_io_25 != 0x1FFF)
reg_debug_1 =0x1a;
if (reg_mprj_io_26 != 0x1FFF)
reg_debug_1 =0x1b;
if (reg_mprj_io_27 != 0x1FFF)
reg_debug_1 =0x1c;
if (reg_mprj_io_28 != 0x1FFF)
reg_debug_1 =0x1d;
if (reg_mprj_io_29 != 0x1FFF)
reg_debug_1 =0x1e;
if (reg_mprj_io_30 != 0x1FFF)
reg_debug_1 =0x1f;
if (reg_mprj_io_31 != 0x1FFF)
reg_debug_1 =0x20;
if (reg_mprj_io_32 != 0x1FFF)
reg_debug_1 =0x21;
if (reg_mprj_io_33 != 0x1FFF)
reg_debug_1 =0x22;
if (reg_mprj_io_34 != 0x1FFF)
reg_debug_1 =0x23;
if (reg_mprj_io_35 != 0x1FFF)
reg_debug_1 =0x24;
if (reg_mprj_io_36 != 0x1FFF)
reg_debug_1 =0x25;
if (reg_mprj_io_37 != 0x1FFF)
reg_debug_1 =0x26;
// // write zeros to all registers
reg_mprj_io_0 = 0x0;
reg_mprj_io_1 = 0x0;
reg_mprj_io_2 = 0x0;
reg_mprj_io_3 = 0x0;
reg_mprj_io_4 = 0x0;
reg_mprj_io_5 = 0x0;
reg_mprj_io_6 = 0x0;
reg_mprj_io_7 = 0x0;
reg_mprj_io_8 = 0x0;
reg_mprj_io_9 = 0x0;
reg_mprj_io_10 = 0x0;
reg_mprj_io_11 = 0x0;
reg_mprj_io_12 = 0x0;
reg_mprj_io_13 = 0x0;
reg_mprj_io_14 = 0x0;
reg_mprj_io_15 = 0x0;
reg_mprj_io_16 = 0x0;
reg_mprj_io_17 = 0x0;
reg_mprj_io_18 = 0x0;
reg_mprj_io_19 = 0x0;
reg_mprj_io_20 = 0x0;
reg_mprj_io_21 = 0x0;
reg_mprj_io_22 = 0x0;
reg_mprj_io_23 = 0x0;
reg_mprj_io_24 = 0x0;
reg_mprj_io_25 = 0x0;
reg_mprj_io_26 = 0x0;
reg_mprj_io_27 = 0x0;
reg_mprj_io_28 = 0x0;
reg_mprj_io_29 = 0x0;
reg_mprj_io_30 = 0x0;
reg_mprj_io_31 = 0x0;
reg_mprj_io_32 = 0x0;
reg_mprj_io_33 = 0x0;
reg_mprj_io_34 = 0x0;
reg_mprj_io_35 = 0x0;
reg_mprj_io_36 = 0x0;
reg_mprj_io_37 = 0x0;
// // read zeros that has been written
if (reg_mprj_io_0 != 0x0)
reg_debug_2 =0x1;
if (reg_mprj_io_1 != 0x0)
reg_debug_2 =0x2;
if (reg_mprj_io_2 != 0x0)
reg_debug_2 =0x3;
if (reg_mprj_io_3 != 0x0)
reg_debug_2 =0x4;
if (reg_mprj_io_4 != 0x0)
reg_debug_2 =0x5;
if (reg_mprj_io_5 != 0x0)
reg_debug_2 =0x6;
if (reg_mprj_io_6 != 0x0)
reg_debug_2 =0x7;
if (reg_mprj_io_7 != 0x0)
reg_debug_2 =0x8;
if (reg_mprj_io_8 != 0x0)
reg_debug_2 =0x9;
if (reg_mprj_io_9 != 0x0)
reg_debug_2 =0xa;
if (reg_mprj_io_10 != 0x0)
reg_debug_2 =0xb;
if (reg_mprj_io_11 != 0x0)
reg_debug_2 =0xc;
if (reg_mprj_io_12 != 0x0)
reg_debug_2 =0xd;
if (reg_mprj_io_13 != 0x0)
reg_debug_2 =0xe;
if (reg_mprj_io_14 != 0x0)
reg_debug_2 =0xf;
if (reg_mprj_io_15 != 0x0)
reg_debug_2 =0x10;
if (reg_mprj_io_16 != 0x0)
reg_debug_2 =0x11;
if (reg_mprj_io_17 != 0x0)
reg_debug_2 =0x12;
if (reg_mprj_io_18 != 0x0)
reg_debug_2 =0x13;
if (reg_mprj_io_19 != 0x0)
reg_debug_2 =0x14;
if (reg_mprj_io_20 != 0x0)
reg_debug_2 =0x15;
if (reg_mprj_io_21 != 0x0)
reg_debug_2 =0x16;
if (reg_mprj_io_22 != 0x0)
reg_debug_2 =0x17;
if (reg_mprj_io_23 != 0x0)
reg_debug_2 =0x18;
if (reg_mprj_io_24 != 0x0)
reg_debug_2 =0x19;
if (reg_mprj_io_25 != 0x0)
reg_debug_2 =0x1a;
if (reg_mprj_io_26 != 0x0)
reg_debug_2 =0x1b;
if (reg_mprj_io_27 != 0x0)
reg_debug_2 =0x1c;
if (reg_mprj_io_28 != 0x0)
reg_debug_2 =0x1d;
if (reg_mprj_io_29 != 0x0)
reg_debug_2 =0x1e;
if (reg_mprj_io_30 != 0x0)
reg_debug_2 =0x1f;
if (reg_mprj_io_31 != 0x0)
reg_debug_2 =0x20;
if (reg_mprj_io_32 != 0x0)
reg_debug_2 =0x21;
if (reg_mprj_io_33 != 0x0)
reg_debug_2 =0x22;
if (reg_mprj_io_34 != 0x0)
reg_debug_2 =0x23;
if (reg_mprj_io_35 != 0x0)
reg_debug_2 =0x24;
if (reg_mprj_io_36 != 0x0)
reg_debug_2 =0x25;
if (reg_mprj_io_37 != 0x0)
reg_debug_2 =0x26;
reg_debug_2 = 0xFF;
}

View File

@ -66,6 +66,27 @@ async def hk_regs_wr_wb(dut):
if data_out != int(data_exp,2): cocotb.log.error(f"[TEST] wrong read from {regs[mem][key][0][0]} address {hex(address)} retuned val= {bin(data_out)[2:].zfill(bits_num)} expected = {data_exp}") if data_out != int(data_exp,2): cocotb.log.error(f"[TEST] wrong read from {regs[mem][key][0][0]} address {hex(address)} retuned val= {bin(data_out)[2:].zfill(bits_num)} expected = {data_exp}")
else: cocotb.log.info(f"[TEST] read the right value {hex(data_out)} from {regs[mem][key][0][0]} address {hex(address)} ") else: cocotb.log.info(f"[TEST] read the right value {hex(data_out)} from {regs[mem][key][0][0]} address {hex(address)} ")
'''randomly write then read housekeeping regs through wishbone'''
@cocotb.test()
@repot_test
async def hk_regs_wr_wb_cpu(dut):
caravelEnv,clock = await test_configure(dut,timeout_cycles=157521,num_error=INFINITY)
cpu = RiskV(dut)
cpu.cpu_force_reset()
cpu.cpu_release_reset()
reg1 =0 # buffer
reg2 =0
while True:
if cpu.read_debug_reg2() == 0xFF: # test finish
break
if reg1 != cpu.read_debug_reg1():
reg1 = cpu.read_debug_reg1()
cocotb.log.error(f"[TEST] error while writing 0x1FFF to reg_mprj_io_{reg1-1}")
if reg2 != cpu.read_debug_reg2():
reg2 = cpu.read_debug_reg2()
cocotb.log.error(f"[TEST] error while writing 0x0 to reg_mprj_io_{reg2-1}")
await ClockCycles(caravelEnv.clk,10)
'''randomly write then read housekeeping regs through SPI''' '''randomly write then read housekeeping regs through SPI'''
@cocotb.test() @cocotb.test()
@repot_test @repot_test

View File

@ -22,7 +22,6 @@ async def SPI_VIP(csb,clk,SDI,SDO,mem):
await csb_watcher(csb,op) await csb_watcher(csb,op)
cocotb.log.info (f"[SPI_VIP] CSB is deasserted operation has been killed") cocotb.log.info (f"[SPI_VIP] CSB is deasserted operation has been killed")
# cocotb.scheduler.add
# watch the csb and when it's diable kill the SPI_op thread # watch the csb and when it's diable kill the SPI_op thread
async def csb_watcher(csb,thread): async def csb_watcher(csb,thread):
cocotb.log.info (f"[csb_watcher] start CSB watching") cocotb.log.info (f"[csb_watcher] start CSB watching")