def incReadReg (tc, msg, rspId=['rsp0'], prtad=0, devad=5): """Read word from current register in PHY chip and post increment register address Input: - tc = Testcase - msg = MepMessage - rspId = RSP ID: 'rsp#' - only one - prtad = Port address - devad = Device address Return: - dat = Read word """ st = 0 op = {'ad' : 0, 'wr' : 1, 'rd' : 3, 'ird': 2} ta = {'rd' : 0} # Data. msg.packAddr(['rsp'], 'serdes', 'hdr') hdr = round(st*pow(2,14) + op['ird']*pow(2,12) + prtad*pow(2,7) + devad*pow(2,2) + ta['rd']) msg.packPayload([hdr],2) rsp.rspctl(tc, '--writeblock=%s,%s,0,%s' % (rspId[0][3:], msg.hexAddr, msg.hexPayload)) rsp.rspctl_write_sleep() msg.packAddr(['rsp'], 'serdes', 'data') readData = rsp.rspctl(tc, '--readblock=%s,%s,0,2' % (rspId[0][3:], msg.hexAddr)) msg.extractPayload(readData) dat = msg.unpackPayload(2, '+') return dat[0]
def writeReg (tc, msg, reg, dat, rspId=['rsp0'], prtad=0, devad=5): """Write word to register in SERDES PHY chip Input: - tc = Testcase - msg = MepMessage - reg = Register address - dat = Data word to write - rspId = RSP ID: 'rsp#' - prtad = Port address - devad = Device address Return: void """ st = 0 op = {'ad' : 0, 'wr' : 1, 'rd' : 3} ta = {'wr' : 2} # Register address. for ri in rspId: msg.packAddr(['rsp'], 'serdes', 'hdr') hdr = round(st*pow(2,14) + op['ad']*pow(2,12) + prtad*pow(2,7) + devad*pow(2,2) + ta['wr']) msg.packPayload([hdr],2) rsp.rspctl(tc, '--writeblock=%s,%s,0,%s' % (ri[3:], msg.hexAddr, msg.hexPayload)) rsp.rspctl_write_sleep() for ri in rspId: msg.packAddr(['rsp'], 'serdes', 'data') msg.packPayload([reg],2) rsp.rspctl(tc, '--writeblock=%s,%s,0,%s' % (ri[3:], msg.hexAddr, msg.hexPayload)) rsp.rspctl_write_sleep() # Data. for ri in rspId: msg.packAddr(['rsp'], 'serdes', 'hdr') hdr = round(st*pow(2,14) + op['wr']*pow(2,12) + prtad*pow(2,7) + devad*pow(2,2) + ta['wr']) msg.packPayload([hdr],2) rsp.rspctl(tc, '--writeblock=%s,%s,0,%s' % (ri[3:], msg.hexAddr, msg.hexPayload)) rsp.rspctl_write_sleep() for ri in rspId: msg.packAddr(['rsp'], 'serdes', 'data') msg.packPayload([dat],2) rsp.rspctl(tc, '--writeblock=%s,%s,0,%s' % (ri[3:], msg.hexAddr, msg.hexPayload)) rsp.rspctl_write_sleep()