测试用例分散到各个文件中去,避免一个文件过大
This commit is contained in:
@@ -1,726 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
#encoding=utf-8
|
||||
import random
|
||||
import time
|
||||
from pyutils import *
|
||||
from testcase import readregs, ebmmu
|
||||
from testcase import readregs, ebmmu, detect, errorPkt, watchdog, broadcast, sync, base
|
||||
|
||||
if __name__ == '__main__':
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>嗅探数据包1,正常的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(1)
|
||||
gen_file_def = "detect_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>嗅探数据包2,正常的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(1)
|
||||
gen_file_def = "detect_pkt2"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPkt(2, [0, 0, 0, 0])
|
||||
gen_file_def = "detect_err_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包1
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
data = data + [0x57, 0x17, 0xfd, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt1"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包2
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
|
||||
data = data + [0xb2, 0x4e, 0xd3, 0xe2, 0xa8, 0xd3, 0x86, 0x01, 0x44, 0x3f]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt2"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包3
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
for i in range(1024):
|
||||
data.append(random.randint(0, 255))
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt3"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包 sm1,2个读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x00, 0x0, 64, None)
|
||||
genPkt.addSubPkt(0x03, 0, 0xc0, 0x0, 64, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
gen_file_def = "sm1_pkt"
|
||||
sm_idx = 1
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包 sm2,广播读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x00, 0xd, 128, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
|
||||
gen_file_def = "sm2_pkt"
|
||||
sm_idx = 2
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>交换数据 SMx, 两个广播写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0" * 10)
|
||||
data[0] = 16
|
||||
data[1] = 0
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0302, 0xe, 2, data) #0x030a, 0xe, 2, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(100):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0800, 0xe, 16, data) #0x1800, 0xe, 16, data)
|
||||
|
||||
gen_file_def = "sm3_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包,一个读、一个写,增加5个随机包(需要在文件里确认)
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x0840, 0x1, 56, None)
|
||||
genPkt.addSubPkt(0x03, 0, 0x1040, 0x0, 56, None)
|
||||
for i in range(5):
|
||||
genPkt.addSubPkt(random.randint(100, 4000), 0,
|
||||
random.randint(0, 65536), 0x0,
|
||||
56, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
|
||||
gen_file_def = "seq_0_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包0,用来操作sync
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
data[0] = 0 #0x0300
|
||||
data[1] = 0 #0x0301
|
||||
data[2] = 64 #0x302 长度1
|
||||
data[3] = 0 #0x303 长度2
|
||||
data[4] = 0
|
||||
data[5] = 0
|
||||
data[6] = 64
|
||||
data[7] = 0
|
||||
data[8] = 0
|
||||
data[9] = 0
|
||||
data[10] = 64
|
||||
data[11] = 0
|
||||
data[12] = 0
|
||||
data[13] = 0
|
||||
data[14] = 64
|
||||
data[15] = 0
|
||||
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x02, 0, 0x0300, 0x1, 4, data) #sm0
|
||||
genPkt.addSubPkt(0x01, 0, 0x0308, 0x1, 4, data) #sm2
|
||||
genPkt.addSubPkt(0x03, 0, 0x0310, 0x1, 4, data) #sm4
|
||||
genPkt.addSubPkt(0x04, 0, 0x0318, 0x1, 4, data) #sm6
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[10] = ord('B')
|
||||
data[11] = ord('A')
|
||||
genPkt.addSubPkt(0x02, 0, 0x0800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[11] = ord('B')
|
||||
data[12] = ord('A')
|
||||
genPkt.addSubPkt(0x01, 0, 0x1800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[12] = ord('B')
|
||||
data[13] = ord('A')
|
||||
genPkt.addSubPkt(0x03, 0, 0x2800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[13] = ord('B')
|
||||
data[14] = ord('A')
|
||||
genPkt.addSubPkt(0x04, 0, 0x3800, 0x1, 64, data)
|
||||
|
||||
|
||||
gen_file_def = "seq_1_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包2
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
genPkt.addBeforeExc( genSlvSMWriteData(3, 1, 129)
|
||||
+ genSlvSMWriteData(4, 1, 140)
|
||||
+ genSlvSMWriteData(1, 1, 128)
|
||||
+ genSlvSMWriteData(2, 1, 152))
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(3, 0, 0x1000, 0x0, 129, b"\0"*129)
|
||||
genPkt.addSubPkt(4, 0, 0x1000, 0x0, 140, b"\0"*140)
|
||||
genPkt.addSubPkt(1, 0, 0x1000, 0x0, 128, b"\0"*128)
|
||||
genPkt.addSubPkt(2, 0, 0x1000, 0x0, 152, b"\0"*152)
|
||||
genPkt.addSubPkt(1, 0, 0x0306, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(2, 0, 0x030e, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(3, 0, 0x0316, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(4, 0, 0x031e, 0x0, 2, b"\0"*2)
|
||||
|
||||
gen_file_def = "seq_2_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包3
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(3, 0, 0x0100, 0x2, 32, b"\0"*129)
|
||||
genPkt.addSubPkt(4, 0, 0x0100, 0x2, 32, b"\0"*140)
|
||||
genPkt.addSubPkt(1, 0, 0x0100, 0x2, 32, b"\0"*128)
|
||||
genPkt.addSubPkt(2, 0, 0x0100, 0x2, 32, b"\0"*152)
|
||||
|
||||
genPkt.addSubPkt(2, 0, 0x0120, 0x2, 2, b"\x05"*32)
|
||||
|
||||
gen_file_def = "seq_3_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>同步数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, random.randint(0, 65535), 0xc, 12, b'\0'*12)
|
||||
|
||||
|
||||
genPkt.addBeforeExc(genEnableInsertTimeCode(0xa))
|
||||
|
||||
gen_file_def = "sync_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx)
|
||||
+genCheckInsertTimeCode()) #+genDisableInsertTimeCode())
|
||||
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包,在波形中确认定时的有效性
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h2000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0xff #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x10 #地址0x139
|
||||
|
||||
data[28] = 0x81 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x20#sync3偏移
|
||||
data[37] = 0x00
|
||||
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
gen_file_def = "sync_sig_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包2
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
gen_file_def = "sync_sig2_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h3000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x80 #地址0x138, sync周期 4B
|
||||
data[25] = 0x00 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0#sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(0, 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x01 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(3, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x02 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(4, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def,), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包3
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
gen_file_def = "sync_sig3_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h3000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x80 #地址0x138, sync周期 4B
|
||||
data[25] = 0x00 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0#sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(0, 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x01 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(3, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x02 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(4, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x04 #地址0x139genPkt.addBeforeExc(
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(2, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def,), 1)
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置顺序地址
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = bytearray(b"\0" * 2)
|
||||
data[0] = 0x3f
|
||||
data[1] = 0xff
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, random.randint(0, 65535), 0xb, 2, data)
|
||||
|
||||
|
||||
gen_file_def = "set_addr_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x1, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x2, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x3, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x4, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
|
||||
|
||||
gen_file_def = "bc_r_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0" * 2)
|
||||
data[0] = 32
|
||||
data[1] = 0
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0302, 0xe, 2, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(100):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0800, 0xe, 32, data)
|
||||
|
||||
gen_file_def = "bc_w_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播读写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(4):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x00c0, 0xf, 4, data)
|
||||
|
||||
gen_file_def = "bc_rw_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
detect.tc1()
|
||||
detect.tc2()
|
||||
|
||||
errorPkt.tc1()
|
||||
errorPkt.tc2()
|
||||
errorPkt.tc3()
|
||||
errorPkt.tc4()
|
||||
|
||||
base.tc1()
|
||||
base.tc2()
|
||||
base.tc3()
|
||||
base.tc4()
|
||||
base.tc5()
|
||||
base.tc6()
|
||||
base.tc7()
|
||||
base.tc8()
|
||||
|
||||
broadcast.tc1()
|
||||
broadcast.tc2()
|
||||
broadcast.tc3()
|
||||
|
||||
sync.tc1()
|
||||
sync.tc2()
|
||||
sync.tc3()
|
||||
sync.tc4()
|
||||
|
||||
ebmmu.tc1()
|
||||
ebmmu.tc2()
|
||||
@@ -737,62 +45,7 @@ if __name__ == '__main__':
|
||||
ebmmu.tc14()
|
||||
ebmmu.tc15()
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
#>>>>>> 测试用例1 看门狗测试
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = 1<<1 ##使能看门狗1
|
||||
data0 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
data = 0x0010 ##看门狗的超时值
|
||||
data1 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
data = 0xffffffff ##清除中断
|
||||
data2 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
genPkt.addBeforeExc( genIFRwDataCode(1, 0x404, True, 4, data0)
|
||||
+ genIFRwDataCode(1, 0x40C, True, 4, data1)
|
||||
+ genIFRwDataCode(1, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(2, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(3, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(4, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
||||
+ genIFRwDataCode(0, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(1, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(2, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(3, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(4, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(1, 0x400, False, 0x04))
|
||||
#genPkt.addBeforeExc( genIFRwDataCode(1, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff]))
|
||||
|
||||
data = [0,] * 2
|
||||
data[0] = 0x80
|
||||
data[1] = 0x00
|
||||
genPkt.addSubPkt(0x0, 0, 0x302, 0xe, 2, data)
|
||||
|
||||
data = [0,] * 0x50
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(1, 0, 0x800, 0x1, 0x50, data)
|
||||
|
||||
gen_file_def = "wd_tc1"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx)
|
||||
+genIFRwDataCode(1, 0x800, False, 0x80)
|
||||
+genIFRwDataCode(0, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(1, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(2, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(3, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(4, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(1, 0x400, False, 0x04))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
watchdog.tc1()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class GenPkt(object):
|
||||
self.pkt_buf.append(0)
|
||||
i = i + 1
|
||||
|
||||
print("pkt_len:%d, data_len:%d"%(pkt_len, pkt_len - 4))
|
||||
#print("pkt_len:%d, data_len:%d"%(pkt_len, pkt_len - 4))
|
||||
f = open(filename, "wt+")
|
||||
if filetype == 1:
|
||||
for md in self.sub_pkt:
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
# testcase/__init__.py
|
||||
from .readregs import *
|
||||
from .ebmmu import *
|
||||
from .detect import *
|
||||
from .errorPkt import *
|
||||
from .watchdog import *
|
||||
from .broadcast import *
|
||||
from .sync import *
|
||||
260
tb/shinTest/testcase/base.py
Normal file
260
tb/shinTest/testcase/base.py
Normal file
@@ -0,0 +1,260 @@
|
||||
from pyutils import *
|
||||
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包 sm1,2个读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x00, 0x0, 64, None)
|
||||
genPkt.addSubPkt(0x03, 0, 0xc0, 0x0, 64, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
gen_file_def = "sm1_pkt"
|
||||
sm_idx = 1
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc2():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包 sm2,广播读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x00, 0xd, 128, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
|
||||
gen_file_def = "sm2_pkt"
|
||||
sm_idx = 2
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc3():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>交换数据 SMx, 两个广播写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0" * 10)
|
||||
data[0] = 16
|
||||
data[1] = 0
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0302, 0xe, 2, data) #0x030a, 0xe, 2, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(100):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0800, 0xe, 16, data) #0x1800, 0xe, 16, data)
|
||||
|
||||
gen_file_def = "sm3_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc4():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包,一个读、一个写,增加5个随机包(需要在文件里确认)
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
#genPkt.addSubPkt(0x02, 0, 0x0830, 0x2, 56, None)
|
||||
genPkt.addSubPkt(0x01, 0, 0x0840, 0x1, 56, None)
|
||||
genPkt.addSubPkt(0x03, 0, 0x1040, 0x0, 56, None)
|
||||
for i in range(5):
|
||||
genPkt.addSubPkt(random.randint(100, 4000), 0,
|
||||
random.randint(0, 65536), 0x0,
|
||||
56, None)
|
||||
#genPkt.addSubPkt(10, 2, 0x300, 0x2, 4, None)
|
||||
#genPkt.addSubPkt(11, 1, 0x300, 0x2, 4, None)
|
||||
|
||||
|
||||
gen_file_def = "seq_0_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc5():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包0,用来操作sync
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
data[0] = 0 #0x0300
|
||||
data[1] = 0 #0x0301
|
||||
data[2] = 64 #0x302 长度1
|
||||
data[3] = 0 #0x303 长度2
|
||||
data[4] = 0
|
||||
data[5] = 0
|
||||
data[6] = 64
|
||||
data[7] = 0
|
||||
data[8] = 0
|
||||
data[9] = 0
|
||||
data[10] = 64
|
||||
data[11] = 0
|
||||
data[12] = 0
|
||||
data[13] = 0
|
||||
data[14] = 64
|
||||
data[15] = 0
|
||||
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x02, 0, 0x0300, 0x1, 4, data) #sm0
|
||||
genPkt.addSubPkt(0x01, 0, 0x0308, 0x1, 4, data) #sm2
|
||||
genPkt.addSubPkt(0x03, 0, 0x0310, 0x1, 4, data) #sm4
|
||||
genPkt.addSubPkt(0x04, 0, 0x0318, 0x1, 4, data) #sm6
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[10] = ord('B')
|
||||
data[11] = ord('A')
|
||||
genPkt.addSubPkt(0x02, 0, 0x0800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[11] = ord('B')
|
||||
data[12] = ord('A')
|
||||
genPkt.addSubPkt(0x01, 0, 0x1800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[12] = ord('B')
|
||||
data[13] = ord('A')
|
||||
genPkt.addSubPkt(0x03, 0, 0x2800, 0x1, 64, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(64):
|
||||
data[i] = i
|
||||
data[13] = ord('B')
|
||||
data[14] = ord('A')
|
||||
genPkt.addSubPkt(0x04, 0, 0x3800, 0x1, 64, data)
|
||||
|
||||
|
||||
gen_file_def = "seq_1_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc6():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包2
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
genPkt.addBeforeExc( genSlvSMWriteData(3, 1, 129)
|
||||
+ genSlvSMWriteData(4, 1, 140)
|
||||
+ genSlvSMWriteData(1, 1, 128)
|
||||
+ genSlvSMWriteData(2, 1, 152))
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(3, 0, 0x1000, 0x0, 129, b"\0"*129)
|
||||
genPkt.addSubPkt(4, 0, 0x1000, 0x0, 140, b"\0"*140)
|
||||
genPkt.addSubPkt(1, 0, 0x1000, 0x0, 128, b"\0"*128)
|
||||
genPkt.addSubPkt(2, 0, 0x1000, 0x0, 152, b"\0"*152)
|
||||
genPkt.addSubPkt(1, 0, 0x0306, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(2, 0, 0x030e, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(3, 0, 0x0316, 0x0, 2, b"\0"*2)
|
||||
genPkt.addSubPkt(4, 0, 0x031e, 0x0, 2, b"\0"*2)
|
||||
|
||||
gen_file_def = "seq_2_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc7():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>普通数据包3
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(3, 0, 0x0100, 0x2, 32, b"\0"*129)
|
||||
genPkt.addSubPkt(4, 0, 0x0100, 0x2, 32, b"\0"*140)
|
||||
genPkt.addSubPkt(1, 0, 0x0100, 0x2, 32, b"\0"*128)
|
||||
genPkt.addSubPkt(2, 0, 0x0100, 0x2, 32, b"\0"*152)
|
||||
|
||||
genPkt.addSubPkt(2, 0, 0x0120, 0x2, 2, b"\x05"*32)
|
||||
|
||||
gen_file_def = "seq_3_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc8():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置顺序地址
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = bytearray(b"\0" * 2)
|
||||
data[0] = 0x3f
|
||||
data[1] = 0xff
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, random.randint(0, 65535), 0xb, 2, data)
|
||||
|
||||
|
||||
gen_file_def = "set_addr_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
83
tb/shinTest/testcase/broadcast.py
Normal file
83
tb/shinTest/testcase/broadcast.py
Normal file
@@ -0,0 +1,83 @@
|
||||
from pyutils import *
|
||||
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播读
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x1, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x2, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x3, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(0x4, 0, 0xc0, 0x0, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0xc0, 0xd, 4, b"\0"*4)
|
||||
|
||||
|
||||
gen_file_def = "bc_r_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc2():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0" * 2)
|
||||
data[0] = 32
|
||||
data[1] = 0
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0302, 0xe, 2, data)
|
||||
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(100):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x0800, 0xe, 32, data)
|
||||
|
||||
gen_file_def = "bc_w_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc3():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>广播读写
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = bytearray(b"\0"*100)
|
||||
for i in range(4):
|
||||
data[i] = i + 1
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x00c0, 0xf, 4, data)
|
||||
|
||||
gen_file_def = "bc_rw_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
32
tb/shinTest/testcase/detect.py
Normal file
32
tb/shinTest/testcase/detect.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from pyutils import *
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>嗅探数据包1,正常的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(1)
|
||||
gen_file_def = "detect_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc2():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>嗅探数据包2,正常的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(1)
|
||||
gen_file_def = "detect_pkt2"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from pyutils import *
|
||||
import time
|
||||
import random
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
|
||||
101
tb/shinTest/testcase/errorPkt.py
Normal file
101
tb/shinTest/testcase/errorPkt.py
Normal file
@@ -0,0 +1,101 @@
|
||||
from pyutils import *
|
||||
import time
|
||||
import random
|
||||
|
||||
def tc1():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包1
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
data = data + [0x57, 0x17, 0xfd, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt1"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc2():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包2
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
|
||||
data = data + [0xb2, 0x4e, 0xd3, 0xe2, 0xa8, 0xd3, 0x86, 0x01, 0x44, 0x3f]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt2"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc3():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包3
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
for i in range(1024):
|
||||
data.append(random.randint(0, 255))
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt3"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc4():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的嗅探数据包
|
||||
|
||||
genPkt.clean()
|
||||
genPkt.setPkt(2, [0, 0, 0, 0])
|
||||
gen_file_def = "detect_err_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
283
tb/shinTest/testcase/sync.py
Normal file
283
tb/shinTest/testcase/sync.py
Normal file
@@ -0,0 +1,283 @@
|
||||
from pyutils import *
|
||||
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>同步数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(0x0, 0, random.randint(0, 65535), 0xc, 12, b'\0'*12)
|
||||
|
||||
|
||||
genPkt.addBeforeExc(genEnableInsertTimeCode(0xa))
|
||||
|
||||
gen_file_def = "sync_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx)
|
||||
+genCheckInsertTimeCode()) #+genDisableInsertTimeCode())
|
||||
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc2():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包,在波形中确认定时的有效性
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h2000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0xff #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x10 #地址0x139
|
||||
|
||||
data[28] = 0x81 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x20#sync3偏移
|
||||
data[37] = 0x00
|
||||
|
||||
genPkt.addSubPkt(random.randint(0, 2048), 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
gen_file_def = "sync_sig_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
|
||||
def tc3():
|
||||
genPkt = GenPkt()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包2
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
gen_file_def = "sync_sig2_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h3000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x80 #地址0x138, sync周期 4B
|
||||
data[25] = 0x00 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0#sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(0, 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x01 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(3, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x02 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(4, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def,), 1)
|
||||
|
||||
|
||||
def tc4():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>设置同步信号的数据包3
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
gen_file_def = "sync_sig3_pkt"
|
||||
sm_idx = 3
|
||||
|
||||
genPkt.addBeforeExc(
|
||||
'''spi_trans( (16'h0100), (`SPI_READ), (8), (`IF_IDX(0)));\n'''
|
||||
+ '''_temp_time = rxBuf[3] + (rxBuf[4] << 8) + (rxBuf[5] << 16) + (rxBuf[6] << 24) + (rxBuf[7] << 32) + (rxBuf[8] << 40) + (rxBuf[9] << 48) + (rxBuf[10] << 56);\n'''
|
||||
+ '''_temp_time = _temp_time + 32'h3000;\n\n''')
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x80 #地址0x138, sync周期 4B
|
||||
data[25] = 0x00 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0#sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(0, 0, 0x120, 0xe, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x01 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(3, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x02 #地址0x139
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(4, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
data = [0,] * 100 #bytearray(b"\0" * 100)
|
||||
data[0] = 0x0f #地址0x120
|
||||
data[2] = 0xa
|
||||
data[4] = 0xa
|
||||
data[6] = 0xa
|
||||
data[8] = 0xa
|
||||
|
||||
data[16] = '''(_temp_time & 8'hff)''' #地址0x130, sync同步点
|
||||
data[17] = '''(_temp_time >> 8) & 8'hff''' #地址0x131
|
||||
data[18] = '''(_temp_time >> 16) & 8'hff'''
|
||||
data[19] = '''(_temp_time >> 24) & 8'hff'''
|
||||
|
||||
data[24] = 0x00 #地址0x138, sync周期 4B
|
||||
data[25] = 0x04 #地址0x139genPkt.addBeforeExc(
|
||||
|
||||
data[28] = 0x0 #sync1偏移
|
||||
data[29] = 0x0
|
||||
|
||||
data[36] = 0x0 #sync3偏移
|
||||
data[37] = 0x0
|
||||
|
||||
genPkt.addSubPkt(2, 0, 0x120, 0x1, 0x28, data)
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def,), 1)
|
||||
59
tb/shinTest/testcase/watchdog.py
Normal file
59
tb/shinTest/testcase/watchdog.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from pyutils import *
|
||||
|
||||
def tc1():
|
||||
genPkt = GenPkt()
|
||||
#--------------------------------------------------------------------------
|
||||
#>>>>>> 测试用例1 看门狗测试
|
||||
genPkt.clean()
|
||||
genPkt.setPktType(0)
|
||||
|
||||
data = 1<<1 ##使能看门狗1
|
||||
data0 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
data = 0x0010 ##看门狗的超时值
|
||||
data1 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
data = 0xffffffff ##清除中断
|
||||
data2 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
||||
|
||||
genPkt.addBeforeExc( genIFRwDataCode(1, 0x404, True, 4, data0)
|
||||
+ genIFRwDataCode(1, 0x40C, True, 4, data1)
|
||||
+ genIFRwDataCode(1, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(2, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(3, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(4, 0x078, True, 4, data2)
|
||||
+ genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
||||
+ genIFRwDataCode(0, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(1, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(2, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(3, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(4, 0x074, False, 0x04)
|
||||
+ genIFRwDataCode(1, 0x400, False, 0x04))
|
||||
#genPkt.addBeforeExc( genIFRwDataCode(1, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff]))
|
||||
|
||||
data = [0,] * 2
|
||||
data[0] = 0x80
|
||||
data[1] = 0x00
|
||||
genPkt.addSubPkt(0x0, 0, 0x302, 0xe, 2, data)
|
||||
|
||||
data = [0,] * 0x50
|
||||
|
||||
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
||||
genPkt.addSubPkt(1, 0, 0x800, 0x1, 0x50, data)
|
||||
|
||||
gen_file_def = "wd_tc1"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx)
|
||||
+genIFRwDataCode(1, 0x800, False, 0x80)
|
||||
+genIFRwDataCode(0, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(1, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(2, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(3, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(4, 0x074, False, 0x04)
|
||||
+genIFRwDataCode(1, 0x400, False, 0x04))
|
||||
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
Reference in New Issue
Block a user