def genRxData(self): while self.getPhase() != PHASE_SIM: yield None for i in range(2): trans = Transaction() trans.last = 0 trans.fragment = 0x55 trans.nextDelay = 4 yield trans trans = Transaction() trans.last = 1 trans.fragment = 0x66 trans.nextDelay = 10 yield trans trans = Transaction() trans.last = 1 trans.fragment = 0x11 trans.nextDelay = 0 yield trans trans = Transaction() trans.last = 1 trans.fragment = 0x11 yield trans while True: yield None
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)
def rxThread(self): while True: data, addr = self.sock.recvfrom(2048) print "received message:", data, addr cmdTrans = Transaction() ipSplit = addr[0].split(".") cmdTrans.ip = 0 for i in range(4): cmdTrans.ip |= int(ipSplit[i]) << (i * 8) cmdTrans.srcPort = addr[1] cmdTrans.dstPort = SERVER_PORT cmdTrans.length = len(data) self.rxCmdQueue.put(cmdTrans) for i in range(len(data)): dataTrans = Transaction() dataTrans.last = (i == len(data) - 1) dataTrans.fragment = ord(data[i]) self.rxDataQueue.put(dataTrans) self.clkTocken[0] += 1000