1
- from tableMapping import *
2
- import logging
1
+ """
2
+ List of all pip packages imported
3
+ """
4
+
3
5
import argparse
6
+ import json
4
7
import os
5
8
9
+ from tableMapping import TableMapping
10
+
11
+
6
12
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" )
10
19
if os .path .exists (logsDirPath ) is False :
11
- os .makedirs (' logs' )
12
-
20
+ os .makedirs (" logs" )
21
+
13
22
# 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
+ )
18
29
# 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" )
33
39
arg = parser .parse_args ()
34
-
35
- # ====================================================== code main body
36
-
40
+
41
+ # ====================================================== code main body
42
+
37
43
# class objects
38
- tm1 = TableMapping ()
39
-
44
+ tm1 = TableMapping ()
45
+
40
46
# get project dir
41
47
tm1 .getPrjDir (arg .verbose )
42
48
# get tcam table config yaml file path
43
49
tm1 .getYAMLFilePath (arg .verbose )
44
50
# read tcam table config yaml file
45
- tm1 .readYAML (tm1 .tcamTableConfigsFilePath ,arg .verbose )
51
+ tm1 .readYAML (tm1 .tcamTableConfigsFilePath , arg .verbose )
46
52
# print all tcam configs
47
53
if arg .debug :
48
54
tm1 .printYAML (arg .debug )
@@ -52,29 +58,29 @@ def main():
52
58
# print specific tcam config
53
59
print (json .dumps (tempConfig , indent = 4 ))
54
60
# get tcam table map file path
55
- tm1 .getTCAMTableFilePath (arg .tcamConfig ,arg .verbose )
61
+ tm1 .getTCAMTableFilePath (arg .tcamConfig , arg .verbose )
56
62
# read tcam table map file
57
63
tm1 .readTCAMTable (arg .verbose )
58
64
# print tcam table map
59
- tm1 .printDF (tm1 ._tcamTable , ' TCAM Table Map' )
65
+ tm1 .printDF (tm1 .getTcamTableMap (), " TCAM Table Map" )
60
66
# calculate sram table dimensions
61
67
tm1 .getSRAMTableDim (arg .verbose )
62
68
# create sram table dataframe
63
69
tm1 .genSRAMTable (arg .verbose )
64
70
# print empty sram table map
65
71
if arg .debug :
66
- tm1 .printDF (tm1 ._sramTable , ' Empty SRAM Table Map' )
72
+ tm1 .printDF (tm1 .getSramTableMap (), " Empty SRAM Table Map" )
67
73
# create sram tables dir
68
74
tm1 .createSRAMTableDir (arg .verbose )
69
75
# read various params and map the tcam table to sram table
70
76
tm1 .splitRowsAndCols (arg .debug )
71
77
# 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 )
74
80
# map all possible tcam table addr to sram table
75
- tm1 .mapTCAMtoSRAM (arg .verbose ,arg .debug )
81
+ tm1 .mapTCAMtoSRAM (arg .verbose , arg .debug )
76
82
# print updated sram table
77
- tm1 .printDF (tm1 ._sramTable , ' SRAM Table Map' )
83
+ tm1 .printDF (tm1 .getSramTableMap (), " SRAM Table Map" )
78
84
# write sram table map to excel file
79
85
if arg .excel :
80
86
tm1 .writeSRAMtoXlsx ()
@@ -89,6 +95,5 @@ def main():
89
95
tm1 .writeSRAMtoTxt ()
90
96
91
97
92
-
93
- if __name__ == '__main__' :
94
- main ()
98
+ if __name__ == "__main__" :
99
+ main ()
0 commit comments