Add gpio_all_i_pd

This commit is contained in:
M0stafaRady 2022-10-07 06:41:21 -07:00
parent 6f832589c0
commit f072e9cb2d
5 changed files with 186 additions and 66 deletions

View File

@ -122,8 +122,8 @@ class Caravel_env:
"""set the spi vsb signal high impedance """
async def release_csb(self ):
cocotb.log.info(f' [caravel] release housekeeping spi transmission')
self.drive_gpio_in((3,3),'z')
self.drive_gpio_in((2,2),'z')
self.release_gpio(3)
self.release_gpio(2)
await ClockCycles(self.clk, 1)
"""set the spi vsb signal low to enable housekeeping spi transmission bin E8 mprj[3]"""

View File

@ -33,6 +33,12 @@
"GL":["r_gl","push_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_pd" :{"level":0,
"SW":true,
"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":"configure all gpios as mgmt input pull down using automatic approach firmware and check them"}
,"bitbang_cpu_all_10" :{"level":0,
"SW":true,
"RTL":["r_rtl","setup","push","push_gl","nightly","weekly","tape_out"],

View File

@ -109,21 +109,14 @@ async def gpio_all_i_pu(dut):
cpu.cpu_force_reset()
cpu.cpu_release_reset()
uut = dut.uut
# await ClockCycles(caravelEnv.clk,1000000000)
# for i in range(200):
# caravelEnv.drive_gpio_in((31,0),0x0)
# await ClockCycles(caravelEnv.clk,10000)
# caravelEnv.drive_gpio_in((31,0),0xFFFFFFFF)
# await ClockCycles(caravelEnv.clk,10000)
# return
await wait_reg1(cpu,caravelEnv,0xAA)
# monitor the output of padframe module it suppose to be all ones when no input is applied
await ClockCycles(caravelEnv.clk,100)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and float")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and float")
await ClockCycles(caravelEnv.clk,1000)
# drive gpios with zero
data_in = 0x0
@ -132,7 +125,7 @@ async def gpio_all_i_pu(dut):
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as pullup and drived with 0")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pullup and drived with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive gpios with ones
data_in = 0x3FFFFFFFFF
@ -141,7 +134,7 @@ async def gpio_all_i_pu(dut):
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and drived with 1")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and drived with 1")
await ClockCycles(caravelEnv.clk,1000)
# drive odd half gpios with zeros and float other half
data_in = 0x0
@ -153,10 +146,10 @@ async def gpio_all_i_pu(dut):
for i in range(38):
if i%2 ==1: #odd
if gpio[i]!="1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and drived with odd half with 0")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and drived with odd half with 0")
else:
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as pullup and drived with odd half with 0")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pullup and drived with odd half with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive even half gpios with zeros and float other half
caravelEnv.drive_gpio_in((37,0),data_in)
@ -167,10 +160,10 @@ async def gpio_all_i_pu(dut):
for i in range(38):
if i%2 ==1: #odd
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as pullup and drived with even half with 0")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pullup and drived with even half with 0")
else:
if gpio[i]!="1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and drived with even half with 0")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and drived with even half with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive odd half gpios with ones and float other half
data_in = 0x3FFFFFFFFF
@ -181,7 +174,7 @@ async def gpio_all_i_pu(dut):
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i]!="1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and drived with odd half with 1")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and drived with odd half with 1")
await ClockCycles(caravelEnv.clk,1000)
# drive even half gpios with zeros and float other half
@ -192,33 +185,121 @@ async def gpio_all_i_pu(dut):
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as pullup and drived with even half with 1")
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and drived with even half with 1")
await ClockCycles(caravelEnv.clk,1000)
# cocotb.log.info(f"[TEST] configuration finished")
# await wait_reg1(cpu,caravelEnv,0xB1)
# data_in = 0x0
# cocotb.log.info(f"[TEST] send {hex(data_in)} to gpio[31:0]")
# caravelEnv.drive_gpio_in((31,0),data_in)
# await wait_reg1(cpu,caravelEnv,0xB2)
# cocotb.log.info(f"[TEST] data {hex(data_in)} sent successfully to gpio[31:0]")
# size = 32
# data_in = int(size) * 'z'
# data_in = 0xFFFFFFFF
# cocotb.log.info(f"[TEST] send {data_in} to gpio[31:0]")
# caravelEnv.release_gpio((31,0))
# await wait_reg1(cpu,caravelEnv,0xB3)
# cocotb.log.info(f"[TEST] data {data_in} sent successfully to gpio[31:0]")
# data_in = 0x0
# cocotb.log.info(f"[TEST] send {hex(data_in)} to gpio[0:16]")
# caravelEnv.drive_gpio_in((15,0),data_in)
# # await wait_reg2(cpu,caravelEnv,0xFF)
# cocotb.log.info(f"[TEST] finish")
# drive with zeros then release all gpio
data_in = 0x0
caravelEnv.drive_gpio_in((37,0),data_in)
await ClockCycles(caravelEnv.clk,1000)
caravelEnv.release_gpio((37,0))
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pullup and all released")
await ClockCycles(caravelEnv.clk,1000)
# await wait_reg1(cpu,caravelEnv,0xFF)
@cocotb.test()
@repot_test
async def gpio_all_i_pd(dut):
caravelEnv,clock = await test_configure(dut,timeout_cycles=1245464,num_error=2000)
await caravelEnv.release_csb()
cpu = RiskV(dut)
cpu.cpu_force_reset()
cpu.cpu_release_reset()
uut = dut.uut
await wait_reg1(cpu,caravelEnv,0xAA)
# monitor the output of padframe module it suppose to be all ones when no input is applied
await ClockCycles(caravelEnv.clk,100)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and float")
await ClockCycles(caravelEnv.clk,1000)
# drive gpios with zero
data_in = 0x0
caravelEnv.drive_gpio_in((37,0),data_in)
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and drived with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive gpios with ones
data_in = 0x3FFFFFFFFF
caravelEnv.drive_gpio_in((37,0),data_in)
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pulldown and drived with 1")
await ClockCycles(caravelEnv.clk,1000)
# drive odd half gpios with zeros and float other half
data_in = 0x0
caravelEnv.drive_gpio_in((37,0),data_in)
for i in range(0,38,2):
caravelEnv.release_gpio(i) # release even gpios
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i]!="0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and drived with odd half with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive even half gpios with zeros and float other half
caravelEnv.drive_gpio_in((37,0),data_in)
for i in range(1,38,2):
caravelEnv.release_gpio(i) # release odd gpios
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i]!="0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and drived with even half with 0")
await ClockCycles(caravelEnv.clk,1000)
# drive odd half gpios with ones and float other half
data_in = 0x3FFFFFFFFF
caravelEnv.drive_gpio_in((37,0),data_in)
for i in range(0,38,2):
caravelEnv.release_gpio(i) # release even gpios
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if i%2 ==0: #even
if gpio[i]!="1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pulldown and drived with odd half with 1")
else:
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and drived with odd half with 1")
await ClockCycles(caravelEnv.clk,1000)
# drive even half gpios with zeros and float other half
caravelEnv.drive_gpio_in((37,0),data_in)
for i in range(1,38,2):
caravelEnv.release_gpio(i) # release odd gpios
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if i%2 ==1: #odd
if gpio[i]!="1":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 1 while configured as input pulldown and drived with odd half with 1")
else:
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and drived with odd half with 1")
await ClockCycles(caravelEnv.clk,1000)
# drive with ones then release all gpio
data_in = 0x3FFFFFFFFF
caravelEnv.drive_gpio_in((37,0),data_in)
await ClockCycles(caravelEnv.clk,1000)
caravelEnv.release_gpio((37,0))
await ClockCycles(caravelEnv.clk,1000)
gpio = dut.uut.padframe.mprj_io_in.value.binstr
for i in range(38):
if gpio[i] != "0":
cocotb.log.error(f"[TEST] gpio[{i}] is having wrong value {gpio[i]} instead of 0 while configured as input pulldown and all released")
await ClockCycles(caravelEnv.clk,1000)

View File

@ -0,0 +1,57 @@
#include <defs.h>
#include <stub.c>
#include "../bitbang/bitbang_functions.c"
void main(){
unsigned int i, j, k;
reg_wb_enable =1; // for enable writing to reg_debug_1 and reg_debug_2
reg_debug_1 = 0x0;
reg_debug_2 = 0x0;
reg_hkspi_disable = 1;
reg_mprj_io_37 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_36 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_35 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_34 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_33 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_32 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_31 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_30 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_29 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_28 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_27 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_26 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_25 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_24 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_23 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_22 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_21 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_20 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_19 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_18 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_17 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_16 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_15 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_14 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_13 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_12 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_11 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_10 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_9 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_8 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_7 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_6 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_5 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_4 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_3 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_2 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_1 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_0 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_io_0 = GPIO_MODE_MGMT_STD_INPUT_PULLDOWN;
reg_mprj_xfer = 1;
while (reg_mprj_xfer == 1);
reg_debug_1 = 0XAA; // configuration done
while (true);
}

View File

@ -53,29 +53,5 @@ void main(){
reg_debug_1 = 0XAA; // configuration done
// while (true){
// reg_debug_2 = reg_mprj_datal;
// }
// reg_debug_1 = 0XB1; // wait environment to send 0x0 to reg_mprj_datal
// while (reg_mprj_datal != 0x0);
// reg_debug_2 = reg_mprj_datal;
// reg_debug_1 = 0XB2; // wait environment to send 0xzzzzzzzz to reg_mprj_datal
// while (reg_mprj_datal != 0xFFFFFFFF);
// reg_debug_2 = reg_mprj_datal;
// reg_debug_1 = 0XB3; // wait environment to send 0xzzzz0000 to reg_mprj_datal
// while (reg_mprj_datal != 0xFFFF0000);
// reg_debug_2 = reg_mprj_datal;
// reg_debug_1 = 0XB5; // wait environment to send 0x0 to reg_mprj_datah
// while (reg_mprj_datah != 0x0);
// reg_debug_2 = reg_mprj_datah;
// reg_debug_1 = 0XB6; // wait environment to send 0xzz to reg_mprj_datah
// while (reg_mprj_datah != 0x3F);
// reg_debug_2 = reg_mprj_datah;
// reg_debug_1 = 0XB7; // wait environment to send 0xz0 to reg_mprj_datah
// while (reg_mprj_datah != 0x30);
// reg_debug_2 = reg_mprj_datah;
reg_debug_1 = 0xFF;
while (true);
}