def __init__(self,name,parent,dut): Infrastructure.__init__(self,name,parent) self.txCmdScordboard = ScorboardInOrder("txCmdScordboard",self) self.txDataScordboard = ScorboardInOrder("txDataScordboard",self) StreamMonitor(Stream(dut,"io_tx_cmd"), self.txCmdScordboard.uutPush, dut.clk, dut.reset) StreamMonitor(Stream(dut, "io_tx_data"), self.txDataScordboard.uutPush, dut.clk, dut.reset) cmd = Transaction() cmd.ip = 0x33445566 cmd.dstPort = 0x3456 cmd.srcPort = 37984 cmd.length = 1+8 self.txCmdScordboard.refPush(cmd) cmd = Transaction() cmd.ip = 0x44556677 cmd.dstPort = 0x4567 cmd.srcPort = 37984 cmd.length = 1+8 self.txCmdScordboard.refPush(cmd) for i in range(2): data = Transaction() data.fragment = 0x22 data.last = 0 self.txDataScordboard.refPush(data) message = "test1234" for f in range(len(message)): data = Transaction() data.fragment = ord(message[f]) data.last = (f == len(message)-1) self.txDataScordboard.refPush(data)
class SdramTester(Infrastructure): def __init__(self,name,parent,cmd,rsp,clk,reset): Infrastructure.__init__(self, name, parent) StreamDriverMaster(cmd, self.genCmd, clk, reset) self.nonZeroRspCounter = 0 self.cmdRandomizer = BoolRandomizer() self.writeRandomizer = BoolRandomizer() self.burstRandomizer = BoolRandomizer() self.lastAddr = 0 self.closeIt = False self.ram = bytearray(b'\x00' * (1 << (9+2+2+1))) self.scorboard = ScorboardInOrder("scoreboard", self) StreamDriverSlave(rsp, clk, reset) # rsp.ready <= 1 StreamMonitor(rsp, self.scorboard.uutPush, clk, reset) def canPhaseProgress(self, phase): return self.nonZeroRspCounter > 4000 def startPhase(self, phase): Infrastructure.startPhase(self, phase) if phase == PHASE_WAIT_TASKS_END: self.closeIt = True def genCmd(self): if self.closeIt or not self.cmdRandomizer.get(): return None trans = Transaction() if not self.burstRandomizer.get(): trans.address = randBits(9+2+2) else: trans.address = self.lastAddr + 1 trans.address = trans.address & ((1 << 13)-1) trans.write = self.writeRandomizer.get() and self.writeRandomizer.get() trans.mask = randBits(2) trans.data = randBits(16) trans.context = randBits(8) self.lastAddr = trans.address if trans.write == 0: rsp = Transaction() rsp.data = self.ram[trans.address*2] + (self.ram[trans.address*2+1] << 8) rsp.context = trans.context self.scorboard.refPush(rsp) if rsp.data != 0: self.nonZeroRspCounter += 1 if self.nonZeroRspCounter % 50 == 0: print("self.nonZeroRspCounter=" + str(self.nonZeroRspCounter)) else: for i in xrange(2): if (trans.mask >> i) & 1 == 1: self.ram[trans.address * 2 + i] = (trans.data >> (i*8)) & 0xFF return trans
def __init__(self,name,parent,dut): Infrastructure.__init__(self,name,parent) self.dut = dut self.mem = [0 for i in xrange(1<<8)] self.cmdA = Queue() self.cmdB = Queue() self.scoreboard = ScorboardInOrder("rspScordboard",self) StreamMonitor(Stream(dut,"io_cmdA"), self.onCmdA, dut.clk, dut.reset) StreamMonitor(Stream(dut, "io_cmdB"), self.onCmdB, dut.clk, dut.reset) StreamMonitor(Stream(dut, "io_rsp"), self.scoreboard.uutPush, dut.clk, dut.reset) cocotb.fork(self.onMemWrite())
def __init__(self,name,parent,pushStream,popStream,transactionGenerator,dutCounterTarget,clk,reset): Infrastructure.__init__(self,name,parent) self.pushStream = pushStream self.popStream = popStream self.clk = clk self.reset = reset self.dutCounter = 0 self.closeIt = False self.transactionGenerator = transactionGenerator self.dutCounterTarget = dutCounterTarget self.pushRandomizer = BoolRandomizer() self.scoreboard = ScorboardInOrder("scoreboard", self)
def __init__(self, name, parent, cmd, rsp, clk, reset): Infrastructure.__init__(self, name, parent) StreamDriverMaster(cmd, self.genCmd, clk, reset) self.nonZeroRspCounter = 0 self.cmdRandomizer = BoolRandomizer() self.writeRandomizer = BoolRandomizer() self.burstRandomizer = BoolRandomizer() self.lastAddr = 0 self.closeIt = False self.ram = bytearray(b'\x00' * (1 << (9 + 2 + 2 + 1))) self.scorboard = ScorboardInOrder("scoreboard", self) StreamDriverSlave(rsp, clk, reset) # rsp.ready <= 1 StreamMonitor(rsp, self.scorboard.uutPush, clk, reset)
class MonitorAgent(Infrastructure): def __init__(self, name, parent, dut): Infrastructure.__init__(self, name, parent) self.dut = dut self.mem = [0 for i in range(1 << 8)] self.cmdA = Queue() self.cmdB = Queue() self.scoreboard = ScorboardInOrder("rspScordboard", self) StreamMonitor(Stream(dut, "io_cmdA"), self.onCmdA, dut.clk, dut.reset) StreamMonitor(Stream(dut, "io_cmdB"), self.onCmdB, dut.clk, dut.reset) StreamMonitor(Stream(dut, "io_rsp"), self.scoreboard.uutPush, dut.clk, dut.reset) cocotb.fork(self.onMemWrite()) @cocotb.coroutine def onMemWrite(self): while True: yield RisingEdge(self.dut.clk) if int(self.dut.io_memWrite_valid) == 1: self.mem[int(self.dut.io_memWrite_payload_address)] = int( self.dut.io_memWrite_payload_data) def onCmdA(self, trans): self.cmdA.put(trans) self.genRsp() def onCmdB(self, trans): self.cmdB.put(trans) self.genRsp() def genRsp(self): if not self.cmdA.empty() and not self.cmdB.empty(): cmdA = self.cmdA.get() cmdB = self.cmdB.get() rsp = Transaction() rsp.itself = self.mem[cmdA.itself] ^ cmdB.itself self.scoreboard.refPush(rsp) def hasEnoughSim(self): return self.scoreboard.refsCounter > 100
class WriteDataMonitor(Infrastructure): def __init__(self,name,parent,axi,dut): Infrastructure.__init__(self,name,parent) self.axi = axi self.dut = dut self.dataScoreboard = ScorboardInOrder("scoreboard", self) def createInfrastructure(self): StreamMonitor(self.axi.aw, self.onWriteCmd, self.dut.clk, self.dut.reset) StreamMonitor(self.axi.w, self.onWriteData, self.dut.clk, self.dut.reset) def onWriteCmd(self,cmd): for i in range(cmd.len + 1): writeData = Transaction() writeData.data = cmd.addr + i writeData.strb = (cmd.addr + i) & 0xF writeData.last = 1 if i == cmd.len else 0 self.dataScoreboard.refPush(writeData) def onWriteData(self,trans): self.dataScoreboard.uutPush(trans)
class WriteDataMonitor(Infrastructure): def __init__(self,name,parent,axi,dut): Infrastructure.__init__(self,name,parent) self.axi = axi self.dut = dut self.dataScoreboard = ScorboardInOrder("scoreboard", self) def createInfrastructure(self): StreamMonitor(self.axi.aw, self.onWriteCmd, self.dut.clk, self.dut.reset) StreamMonitor(self.axi.w, self.onWriteData, self.dut.clk, self.dut.reset) def onWriteCmd(self,cmd): for i in xrange(cmd.len + 1): writeData = Transaction() writeData.data = cmd.addr + i writeData.strb = (cmd.addr + i) & 0xF writeData.last = 1 if i == cmd.len else 0 self.dataScoreboard.refPush(writeData) def onWriteData(self,trans): self.dataScoreboard.uutPush(trans)
class StreamFifoTester(Infrastructure): def __init__(self, name, parent, pushStream, popStream, transactionGenerator, dutCounterTarget, clk, reset): Infrastructure.__init__(self, name, parent) self.pushStream = pushStream self.popStream = popStream self.clk = clk self.reset = reset self.dutCounter = 0 self.closeIt = False self.transactionGenerator = transactionGenerator self.dutCounterTarget = dutCounterTarget self.pushRandomizer = BoolRandomizer() self.scoreboard = ScorboardInOrder("scoreboard", self) def createInfrastructure(self): StreamDriverMaster(self.pushStream, self.genPush, self.clk, self.reset) StreamDriverSlave(self.popStream, self.clk, self.reset) StreamMonitor(self.popStream, self.onUut, self.clk, self.reset) StreamMonitor(self.pushStream, self.onRef, self.clk, self.reset) def startPhase(self, phase): Infrastructure.startPhase(self, phase) if phase == PHASE_WAIT_TASKS_END: self.closeIt = True def genPush(self): if not self.closeIt and self.pushRandomizer.get(): return self.transactionGenerator() def onUut(self, uut): self.dutCounter += 1 self.scoreboard.uutPush(uut) def onRef(self, uut): self.scoreboard.refPush(uut) def canPhaseProgress(self, phase): return self.dutCounter > self.dutCounterTarget
def __init__(self,name,parent,cmd,rsp,clk,reset): Infrastructure.__init__(self, name, parent) StreamDriverMaster(cmd, self.genCmd, clk, reset) self.nonZeroRspCounter = 0 self.cmdRandomizer = BoolRandomizer() self.writeRandomizer = BoolRandomizer() self.burstRandomizer = BoolRandomizer() self.lastAddr = 0 self.closeIt = False self.ram = bytearray(b'\x00' * (1 << (9+2+2+1))) self.scorboard = ScorboardInOrder("scoreboard", self) StreamDriverSlave(rsp, clk, reset) # rsp.ready <= 1 StreamMonitor(rsp, self.scorboard.uutPush, clk, reset)
def __init__(self,name,parent,axi,dut): Infrastructure.__init__(self,name,parent) self.axi = axi self.dut = dut self.dataScoreboard = ScorboardInOrder("scoreboard", self)
def __init__(self,name,parent,axi,dut): Infrastructure.__init__(self,name,parent) self.axi = axi self.dut = dut self.dataScoreboard = ScorboardInOrder("scoreboard", self)
class SdramTester(Infrastructure): def __init__(self, name, parent, cmd, rsp, clk, reset): Infrastructure.__init__(self, name, parent) StreamDriverMaster(cmd, self.genCmd, clk, reset) self.nonZeroRspCounter = 0 self.cmdRandomizer = BoolRandomizer() self.writeRandomizer = BoolRandomizer() self.burstRandomizer = BoolRandomizer() self.lastAddr = 0 self.closeIt = False self.ram = bytearray(b'\x00' * (1 << (9 + 2 + 2 + 1))) self.scorboard = ScorboardInOrder("scoreboard", self) StreamDriverSlave(rsp, clk, reset) # rsp.ready <= 1 StreamMonitor(rsp, self.scorboard.uutPush, clk, reset) def canPhaseProgress(self, phase): return self.nonZeroRspCounter > 4000 def startPhase(self, phase): Infrastructure.startPhase(self, phase) if phase == PHASE_WAIT_TASKS_END: self.closeIt = True def genCmd(self): if self.closeIt or not self.cmdRandomizer.get(): return None trans = Transaction() if not self.burstRandomizer.get(): trans.address = randBits(9 + 2 + 2) else: trans.address = self.lastAddr + 1 trans.address = trans.address & ((1 << 13) - 1) trans.write = self.writeRandomizer.get() and self.writeRandomizer.get() trans.mask = randBits(2) trans.data = randBits(16) trans.context = randBits(8) self.lastAddr = trans.address if trans.write == 0: rsp = Transaction() rsp.data = self.ram[trans.address * 2] + (self.ram[trans.address * 2 + 1] << 8) rsp.context = trans.context self.scorboard.refPush(rsp) if rsp.data != 0: self.nonZeroRspCounter += 1 if self.nonZeroRspCounter % 50 == 0: print(("self.nonZeroRspCounter=" + str(self.nonZeroRspCounter))) else: for i in range(2): if (trans.mask >> i) & 1 == 1: self.ram[trans.address * 2 + i] = (trans.data >> (i * 8)) & 0xFF return trans