Skip to content

Commit d7e0253

Browse files
committed
linted and formatted py file mainTableMapping
1 parent 29793ff commit d7e0253

File tree

1 file changed

+46
-41
lines changed

1 file changed

+46
-41
lines changed

compiler/src/mainTableMapping.py

+46-41
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
from tableMapping import *
2-
import logging
1+
"""
2+
List of all pip packages imported
3+
"""
4+
35
import argparse
6+
import json
47
import os
58

9+
from tableMapping import TableMapping
10+
11+
612
def main():
7-
# create logs dir if it doesnt exist
8-
pwd=os.getcwd()
9-
logsDirPath = os.path.join(pwd,'logs')
13+
"""
14+
main func for implementing py class TableMapping
15+
"""
16+
# create logs dir if it doesn't exist
17+
pwd = os.getcwd()
18+
logsDirPath = os.path.join(pwd, "logs")
1019
if os.path.exists(logsDirPath) is False:
11-
os.makedirs('logs')
12-
20+
os.makedirs("logs")
21+
1322
# set arguments for OpenTCAM
14-
parser = argparse.ArgumentParser(prog='OpenTCAM',
15-
usage='%(prog)s [options] path',
16-
description='TCAM memory generator',
17-
epilog='Python framework for generating configurable SRAM based TCAM memories')
23+
parser = argparse.ArgumentParser(
24+
prog="OpenTCAM",
25+
usage="%(prog)s [options] path",
26+
description="TCAM memory generator",
27+
epilog="Python framework for generating configurable SRAM based TCAM memories",
28+
)
1829
# list of all possible args for OpenTCAM
19-
parser.add_argument('-tconf','--tcamConfig',
20-
type=str,default='tcamTable2',metavar='',required=True,nargs='?',help='name of specific TCAM table config')
21-
parser.add_argument('-excel',
22-
type=int,default=1,metavar='',required=False,nargs='?',help='print SRAM table map as xlsx')
23-
parser.add_argument('-html',
24-
type=int,default=0,metavar='',required=False,nargs='?',help='print SRAM table map as html')
25-
parser.add_argument('-json',
26-
type=int,default=0,metavar='',required=False,nargs='?',help='print SRAM table map as json')
27-
parser.add_argument('-txt',
28-
type=int,default=0,metavar='',required=False,nargs='?',help='print SRAM table map as txt')
29-
parser.add_argument('-d','--debug',
30-
type=int,default=0,metavar='',required=False,nargs='?',help='print debugging mode')
31-
parser.add_argument('-v','--verbose',
32-
type=int,default=0,metavar='',required=False,nargs='?',help='print verbose mode')
30+
parser.add_argument(
31+
"-tconf", "--tcamConfig", type=str, default="tcamTable2", metavar="", required=True, nargs="?", help="name of specific TCAM table config"
32+
)
33+
parser.add_argument("-excel", type=int, default=1, metavar="", required=False, nargs="?", help="print SRAM table map as xlsx")
34+
parser.add_argument("-html", type=int, default=0, metavar="", required=False, nargs="?", help="print SRAM table map as html")
35+
parser.add_argument("-json", type=int, default=0, metavar="", required=False, nargs="?", help="print SRAM table map as json")
36+
parser.add_argument("-txt", type=int, default=0, metavar="", required=False, nargs="?", help="print SRAM table map as txt")
37+
parser.add_argument("-d", "--debug", type=int, default=0, metavar="", required=False, nargs="?", help="print debugging mode")
38+
parser.add_argument("-v", "--verbose", type=int, default=0, metavar="", required=False, nargs="?", help="print verbose mode")
3339
arg = parser.parse_args()
34-
35-
# ====================================================== code main body
36-
40+
41+
# ====================================================== code main body
42+
3743
# class objects
38-
tm1=TableMapping()
39-
44+
tm1 = TableMapping()
45+
4046
# get project dir
4147
tm1.getPrjDir(arg.verbose)
4248
# get tcam table config yaml file path
4349
tm1.getYAMLFilePath(arg.verbose)
4450
# read tcam table config yaml file
45-
tm1.readYAML(tm1.tcamTableConfigsFilePath,arg.verbose)
51+
tm1.readYAML(tm1.tcamTableConfigsFilePath, arg.verbose)
4652
# print all tcam configs
4753
if arg.debug:
4854
tm1.printYAML(arg.debug)
@@ -52,29 +58,29 @@ def main():
5258
# print specific tcam config
5359
print(json.dumps(tempConfig, indent=4))
5460
# get tcam table map file path
55-
tm1.getTCAMTableFilePath(arg.tcamConfig,arg.verbose)
61+
tm1.getTCAMTableFilePath(arg.tcamConfig, arg.verbose)
5662
# read tcam table map file
5763
tm1.readTCAMTable(arg.verbose)
5864
# print tcam table map
59-
tm1.printDF(tm1._tcamTable,'TCAM Table Map')
65+
tm1.printDF(tm1.getTcamTableMap(), "TCAM Table Map")
6066
# calculate sram table dimensions
6167
tm1.getSRAMTableDim(arg.verbose)
6268
# create sram table dataframe
6369
tm1.genSRAMTable(arg.verbose)
6470
# print empty sram table map
6571
if arg.debug:
66-
tm1.printDF(tm1._sramTable,'Empty SRAM Table Map')
72+
tm1.printDF(tm1.getSramTableMap(), "Empty SRAM Table Map")
6773
# create sram tables dir
6874
tm1.createSRAMTableDir(arg.verbose)
6975
# read various params and map the tcam table to sram table
7076
tm1.splitRowsAndCols(arg.debug)
7177
# generate all possible combinations of sram addr
72-
tm1.isolateTCAMSearchQueries(arg.verbose,arg.debug)
73-
tm1.generateSRAMSubStr(arg.verbose,arg.debug)
78+
tm1.isolateTCAMSearchQueries(arg.verbose, arg.debug)
79+
tm1.generateSRAMSubStr(arg.verbose, arg.debug)
7480
# map all possible tcam table addr to sram table
75-
tm1.mapTCAMtoSRAM(arg.verbose,arg.debug)
81+
tm1.mapTCAMtoSRAM(arg.verbose, arg.debug)
7682
# print updated sram table
77-
tm1.printDF(tm1._sramTable,'SRAM Table Map')
83+
tm1.printDF(tm1.getSramTableMap(), "SRAM Table Map")
7884
# write sram table map to excel file
7985
if arg.excel:
8086
tm1.writeSRAMtoXlsx()
@@ -89,6 +95,5 @@ def main():
8995
tm1.writeSRAMtoTxt()
9096

9197

92-
93-
if __name__ == '__main__':
94-
main()
98+
if __name__ == "__main__":
99+
main()

0 commit comments

Comments
 (0)