#!/usr/bin/python

import os 
import sys
import datetime
import xlrd
import string


if len(sys.argv) < 2:
	print "need 8096 .xls file such as GGdatapath_embedway_ES5801B1_CENTEC-171130.xls"
	exit()

fname = 'e580_datapath.txt'

file_def = open(fname, 'w')

data = xlrd.open_workbook(sys.argv[1])

table = data.sheets()[0]

nrows = table.nrows
ncols = table.ncols

print >>file_def, "#Generated by wuheshi datapath tools  %s" %(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
print >> file_def, ""

print >> file_def,"###########################################Port Mapping###########################################"
print >> file_def, "#                                               API port                                         #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#   | network port | network port  | reserved port|  network port | network port|reserved port|  #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#   |    0~39      |     40~47     |    48~63     |    64~103     |   104~111   |   112~127   |  #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#                                             Chip port                                          #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#   |Slice0 0~39   |Slice0 40~47   |      -       | Slice1 0~39   |Slice1 40~47 |      -      |  #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#                                              Mac Id                                            #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "#   |Slice0 0~39   |Slice0 48~55   |      -       | Slice1 0~39   |Slice1 48~55 |      -      |  #"
print >> file_def, "#   |--------------|---------------|--------------|---------------|-------------|-------------|  #"
print >> file_def, "##################################################################################################"
print >> file_def, ""
print >> file_def, ""

print >>file_def, "#SERDES_MODE   : 0-NONE, 1-XFI, 2-SGMII, 3-Not Support, 4-Not Support, 5-XAUI, 6-DXAUI, 7-XLG, 8-CG, 9-2.5G"
print >> file_def, "#SERDES_RX_POLY: 0-Normal, 1-Inverse"
print >> file_def, "#SERDES_SWITCH : 0-Not Support Dynamic Switch, 1-Support Dynamic Switch"

print >> file_def, ""


print >> file_def, "[CORE_PLLA] = %d" %(table.row(98)[1].value)
print >> file_def, "[CORE_PLLB] = %d" %(table.row(99)[1].value)
print >> file_def, ""
print >> file_def, ""
print >> file_def, "[SERDES_ITEM]"
print >> file_def, "#repeat 96 step 5"
for i in range(1,97):
	print >> file_def, "[SERDES_ID] = %d" % (table.row(i)[1].value)
        if table.row(i)[2].value == 'SGMII':
		speed = 2
	elif table.row(i)[2].value == 'NA':
		speed = 0
        elif table.row(i)[2].value == 'XFI':
                speed = 1
        elif table.row(i)[2].value == 'XAUI':
                speed = 5
        elif table.row(i)[2].value == 'XLG':
                speed = 7
        elif table.row(i)[2].value == 'DXAUI':
                speed = 6
	else:
		speed = 0
	print >> file_def, "[SERDES_MODE] = %s" % (speed)
	if table.row(i)[3].value == 'N':
                rxpoly = 0
        elif table.row(i)[3].value == 'Y':
                rxpoly = 1
        else:
		rxpoly = 0
	print >> file_def, "[SERDES_RX_POLY] = %d" % rxpoly
        if table.row(i)[4].value == 'N':
                txpoly = 0
        elif table.row(i)[4].value == 'Y':
                txpoly = 1
        else:
                txpoly = 0
        print >> file_def, "[SERDES_TX_POLY] = %d" % txpoly
        if table.row(i)[5].value == 'N':
                switch = 0
        elif table.row(i)[5].value == 'Y':
                switch = 1
        else:
                switch = 0
        print >> file_def, "[SERDES_SWITCH] = %d" % switch
        print >> file_def, " "

        
file_def.close()


Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐