mirror of https://github.com/XS-MLVP/picker.git
100 lines
2.5 KiB
Python
100 lines
2.5 KiB
Python
#coding=utf8
|
|
|
|
try:
|
|
from . import xspcomm as xsp
|
|
except Exception as e:
|
|
import xspcomm as xsp
|
|
|
|
if __package__ or "." in __name__:
|
|
from .libUT_{{__TOP_MODULE_NAME__}} import *
|
|
else:
|
|
from libUT_{{__TOP_MODULE_NAME__}} import *
|
|
|
|
|
|
class DUT{{__TOP_MODULE_NAME__}}(object):
|
|
|
|
# initialize
|
|
def __init__(self, *args, **kwargs):
|
|
self.dut = DutUnifiedBase(*args)
|
|
self.xclock = xsp.XClock(self.dut.simStep)
|
|
self.xport = xsp.XPort()
|
|
self.xclock.Add(self.xport)
|
|
self.event = self.xclock.getEvent()
|
|
|
|
self.__xpins_to_clear_tag__ = []
|
|
|
|
# set output files
|
|
if kwargs.get("waveform_filename"):
|
|
self.dut.SetWaveform(kwargs.get("waveform_filename"))
|
|
if kwargs.get("coverage_filename"):
|
|
self.dut.SetCoverage(kwargs.get("coverage_filename"))
|
|
|
|
# all Pins
|
|
{{__XDATA_INIT__}}
|
|
|
|
# BindDPI
|
|
{{__XDATA_BIND__}}
|
|
|
|
# Add2Port
|
|
{{__XPORT_ADD__}}
|
|
|
|
# Cascaded ports
|
|
{{__XPORT_CASCADED__}}
|
|
|
|
def __del__(self):
|
|
self.Finish()
|
|
|
|
def __clear_tags__(self):
|
|
for xpin in self.__xpins_to_clear_tag__:
|
|
xpin.__original_value__ = None
|
|
self.__xpins_to_clear_tag__ = []
|
|
|
|
################################
|
|
# User APIs #
|
|
################################
|
|
def InitClock(self, name: str):
|
|
self.xclock.Add(self.xport[name])
|
|
|
|
def Step(self, i:int = 1):
|
|
self.__clear_tags__()
|
|
self.xclock.Step(i)
|
|
|
|
def StepRis(self, callback, args=(), kwargs={}):
|
|
self.xclock.StepRis(callback, args, kwargs)
|
|
|
|
def StepFal(self, callback, args=(), kwargs={}):
|
|
self.xclock.StepFal(callback, args, kwargs)
|
|
|
|
def SetWaveform(self, filename: str):
|
|
self.dut.SetWaveform(filename)
|
|
|
|
def SetCoverage(self, filename: str):
|
|
self.dut.SetCoverage(filename)
|
|
|
|
def Finish(self):
|
|
self.dut.Finish()
|
|
|
|
def RefreshComb(self):
|
|
self.dut.RefreshComb()
|
|
|
|
################################
|
|
# End of User APIs #
|
|
################################
|
|
|
|
def __getitem__(self, key):
|
|
return xsp.XPin(self.port[key], self.event)
|
|
|
|
# Async APIs wrapped from XClock
|
|
async def AStep(self,i: int):
|
|
return await self.xclock.AStep(i)
|
|
|
|
async def Acondition(self,fc_cheker):
|
|
return await self.xclock.ACondition(fc_cheker)
|
|
|
|
def RunStep(self,i: int):
|
|
return self.xclock.RunStep(i)
|
|
|
|
if __name__=="__main__":
|
|
dut=DUT{{__TOP_MODULE_NAME__}}()
|
|
dut.Step(100)
|