2022-09-30 03:42:36 -05:00
|
|
|
import random
|
|
|
|
import cocotb
|
|
|
|
from cocotb.triggers import FallingEdge,RisingEdge,ClockCycles
|
|
|
|
import cocotb.log
|
2022-10-10 06:50:45 -05:00
|
|
|
from interfaces.cpu import RiskV
|
|
|
|
from interfaces.defsParser import Regs
|
2022-09-30 03:42:36 -05:00
|
|
|
from cocotb.result import TestSuccess
|
|
|
|
from tests.common_functions.test_functions import *
|
|
|
|
from tests.bitbang.bitbang_functions import *
|
2022-10-10 06:50:45 -05:00
|
|
|
from interfaces.caravel import GPIO_MODE
|
2022-09-30 03:42:36 -05:00
|
|
|
|
|
|
|
reg = Regs()
|
|
|
|
@cocotb.test()
|
|
|
|
@repot_test
|
2022-10-13 10:18:08 -05:00
|
|
|
async def mem_dff2(dut):
|
2022-10-14 19:12:45 -05:00
|
|
|
caravelEnv,clock = await test_configure(dut,timeout_cycles=1426536)
|
2022-09-30 03:42:36 -05:00
|
|
|
cpu = RiskV(dut)
|
|
|
|
cpu.cpu_force_reset()
|
|
|
|
cpu.cpu_release_reset()
|
|
|
|
cocotb.log.info(f"[TEST] Start mem stress test")
|
2022-10-14 19:12:45 -05:00
|
|
|
pass_list = [0x1B]
|
|
|
|
fail_list = [0x1E]
|
2022-09-30 03:42:36 -05:00
|
|
|
reg1 =0 # buffer
|
|
|
|
while True:
|
2022-10-13 10:18:08 -05:00
|
|
|
if cpu.read_debug_reg1() == 0xFF: # test finish
|
2022-09-30 03:42:36 -05:00
|
|
|
break
|
|
|
|
if reg1 != cpu.read_debug_reg1():
|
|
|
|
reg1 = cpu.read_debug_reg1()
|
|
|
|
if reg1 in pass_list: # pass phase
|
2022-10-13 10:18:08 -05:00
|
|
|
cocotb.log.info(f"[TEST] pass writing and reading all dff2 memory ")
|
2022-10-14 19:12:45 -05:00
|
|
|
break
|
2022-09-30 03:42:36 -05:00
|
|
|
elif reg1 in fail_list: # pass phase
|
2022-10-13 10:18:08 -05:00
|
|
|
cocotb.log.error(f"[TEST] failed access address {hex(0x00000400 + cpu.read_debug_reg2())}")
|
2022-10-14 19:12:45 -05:00
|
|
|
break
|
2022-10-13 10:18:08 -05:00
|
|
|
await ClockCycles(caravelEnv.clk,100)
|
2022-10-14 19:12:45 -05:00
|
|
|
|
2022-09-30 03:42:36 -05:00
|
|
|
|
2022-10-13 10:18:08 -05:00
|
|
|
@cocotb.test()
|
|
|
|
@repot_test
|
|
|
|
async def mem_dff(dut):
|
2022-10-14 19:12:45 -05:00
|
|
|
caravelEnv,clock = await test_configure(dut,timeout_cycles=2378120)
|
2022-10-13 10:18:08 -05:00
|
|
|
cpu = RiskV(dut)
|
|
|
|
cpu.cpu_force_reset()
|
|
|
|
cpu.cpu_release_reset()
|
|
|
|
cocotb.log.info(f"[TEST] Start mem stress test")
|
2022-10-14 19:12:45 -05:00
|
|
|
pass_list = [0x1B]
|
|
|
|
fail_list = [0x1E]
|
2022-10-13 10:18:08 -05:00
|
|
|
reg1 =0 # buffer
|
|
|
|
while True:
|
|
|
|
if reg1 != cpu.read_debug_reg1():
|
|
|
|
reg1 = cpu.read_debug_reg1()
|
|
|
|
if reg1 in pass_list: # pass phase
|
2022-10-14 19:12:45 -05:00
|
|
|
cocotb.log.info(f"[TEST] pass writing and reading all dff memory ")
|
|
|
|
break
|
2022-10-13 10:18:08 -05:00
|
|
|
elif reg1 in fail_list: # pass phase
|
|
|
|
cocotb.log.error(f"[TEST] failed access address {hex(0x00000400 + cpu.read_debug_reg2())}")
|
2022-10-14 19:12:45 -05:00
|
|
|
break
|
2022-10-13 10:18:08 -05:00
|
|
|
await ClockCycles(caravelEnv.clk,100)
|
|
|
|
|
2022-10-14 19:12:45 -05:00
|
|
|
|