1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | ########################################################################################## |
---|
4 | # File : genarch.py |
---|
5 | # Date : 2016 |
---|
6 | # Author : Alain Greiner |
---|
7 | # Copyright (c) UPMC Sorbonne Universites |
---|
8 | ######################################################################################### |
---|
9 | # This python script generates the "arch_info.bin" file required by the ALMOS-MK |
---|
10 | # operating system bootloader and describing the target hardware architecture. |
---|
11 | # It uses an architecture specific, python script that must be called "arch_info.py". |
---|
12 | # |
---|
13 | # The source directory containing the "arch_info.py" file and the destination directory |
---|
14 | # to store the "arch_info.bin" file are defined by parameters on the command line: |
---|
15 | # --arch=string : path to directory containing the "arch_info.py" file |
---|
16 | # --bin=string : path to directory store the "arch_info.bin" file |
---|
17 | # |
---|
18 | # As the target architecture is generic, the following hardware parameters can be |
---|
19 | # defined on the command line: |
---|
20 | # --x_size=int : number of clusters in a row |
---|
21 | # --y_size=int : number of clusters in a column |
---|
22 | # --nb_cores=int : number of cores per cluster |
---|
23 | # --nb_ttys=int : number of TTY channels |
---|
24 | # --nb_nics=int : number of NIC channels |
---|
25 | # --nb_cmas=int : number of CMA channels |
---|
26 | # --fbf_size=int : frame buffer width & heigth |
---|
27 | # --ioc_type=string : can be IOC_BDV , IOC_HBA , IOC_SDC , IOC_SPI |
---|
28 | # --mwr_type=string : can be MWR_GCD , MWR_DCT , MWR_CPY |
---|
29 | # --io_cxy=int : IO cluster identifier |
---|
30 | # --boot_cxy=int : boot cluster identifier |
---|
31 | # --cache_line=int : number of bytes in a cache line |
---|
32 | # |
---|
33 | # The following parameters can be used to generate the optional "hard_config.h" file, |
---|
34 | # that is required to configurate the SystemC virtual prototype, and the "arch_info.xml" |
---|
35 | # file for debug. |
---|
36 | # --hard=string : path to directory to store the "hard_config.h" file |
---|
37 | # --xml=string : path to directory to store the "arch_info.xml" file |
---|
38 | # |
---|
39 | ######################################################################################### |
---|
40 | |
---|
41 | import sys |
---|
42 | |
---|
43 | from arch_classes import * |
---|
44 | from optparse import OptionParser |
---|
45 | |
---|
46 | ################################################################################### |
---|
47 | # define command line arguments |
---|
48 | ################################################################################### |
---|
49 | |
---|
50 | parser = OptionParser() |
---|
51 | |
---|
52 | parser.add_option( '--arch', type = 'string', dest = 'arch_path', |
---|
53 | help = 'define pathname to directory containing arch_info.py file' ) |
---|
54 | |
---|
55 | parser.add_option( '--bin', type = 'string', dest = 'bin_path', |
---|
56 | help = 'define pathname to directory to store arch_info.bin file' ) |
---|
57 | |
---|
58 | parser.add_option( '--x_size', type = 'int', dest = 'x_size', |
---|
59 | default = 2, |
---|
60 | help = 'define number of clusters in a row' ) |
---|
61 | |
---|
62 | parser.add_option( '--y_size', type = 'int', dest = 'y_size', |
---|
63 | default = 2, |
---|
64 | help = 'define number of clusters in a column' ) |
---|
65 | |
---|
66 | parser.add_option( '--nb_cores', type = 'int', dest = 'nb_cores', |
---|
67 | default = 2, |
---|
68 | help = 'define number of cores per cluster' ) |
---|
69 | |
---|
70 | parser.add_option( '--nb_ttys', type = 'int', dest = 'nb_ttys', |
---|
71 | default = 1, |
---|
72 | help = 'define number of TTY channels' ) |
---|
73 | |
---|
74 | parser.add_option( '--nb_nics', type = 'int', dest = 'nb_nics', |
---|
75 | default = 1, |
---|
76 | help = 'define number ot NIC channels' ) |
---|
77 | |
---|
78 | parser.add_option( '--nb_cmas', type = 'int', dest = 'nb_cmas', |
---|
79 | default = 2, |
---|
80 | help = 'define number ot CMA channels' ) |
---|
81 | |
---|
82 | parser.add_option( '--fbf_size', type = 'int', dest = 'fbf_size', |
---|
83 | default = 128, |
---|
84 | help = 'define frame buffer width and heigth' ) |
---|
85 | |
---|
86 | parser.add_option( '--ioc_type', type = 'string', dest = 'ioc_type', |
---|
87 | default = 'IOC_BDV', |
---|
88 | help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' ) |
---|
89 | |
---|
90 | parser.add_option( '--mwr_type', type = 'string', dest = 'mwr_type', |
---|
91 | default = 'MWR_CPY', |
---|
92 | help = 'define type of COPROC: CPY / DCT / GCD' ) |
---|
93 | |
---|
94 | parser.add_option( '--io_cxy', type = 'int', dest = 'io_cxy', |
---|
95 | default = 0, |
---|
96 | help = 'define IO cluster identifier' ) |
---|
97 | |
---|
98 | parser.add_option( '--boot_cxy', type = 'int', dest = 'boot_cxy', |
---|
99 | default = 0, |
---|
100 | help = 'define boot cluster identifier' ) |
---|
101 | |
---|
102 | parser.add_option( '--cache_line', type = 'int', dest = 'cache_line', |
---|
103 | default = 64, |
---|
104 | help = 'define number of bytes in a cache line' ) |
---|
105 | |
---|
106 | parser.add_option( '--hard', type = 'string', dest = 'hard_path', |
---|
107 | help = 'define pathname to directory for the hard_config.h file ' ) |
---|
108 | |
---|
109 | parser.add_option( '--xml', type = 'string', dest = 'xml_path', |
---|
110 | help = 'define pathname to directory for the arch_info.xml file' ) |
---|
111 | |
---|
112 | parser.add_option( '--v', action = 'store_true', dest = 'verbose', |
---|
113 | default = False, |
---|
114 | help = 'display detailed report on arch_info.bin generation' ) |
---|
115 | |
---|
116 | ################################################################################### |
---|
117 | # Get command line arguments |
---|
118 | ################################################################################### |
---|
119 | |
---|
120 | (options,args) = parser.parse_args() |
---|
121 | |
---|
122 | arch_path = options.arch_path # path to arch_info.py file |
---|
123 | bin_path = options.bin_path # path for arch_info.bin file |
---|
124 | |
---|
125 | x_size = options.x_size # number of clusters in a row |
---|
126 | y_size = options.y_size # number of clusters in a column |
---|
127 | nb_cores = options.nb_cores # number of cores in a cluster |
---|
128 | nb_ttys = options.nb_ttys # number of TTY channels |
---|
129 | fbf_size = options.fbf_size # frame buffer width & heigth |
---|
130 | nb_nics = options.nb_nics # number of NIC channels |
---|
131 | nb_cmas = options.nb_cmas # number of CMA channels |
---|
132 | ioc_type = options.ioc_type # ioc controller type |
---|
133 | mwr_type = options.mwr_type # hardware coprocessor type |
---|
134 | io_cxy = options.io_cxy # IO cluster identifier |
---|
135 | boot_cxy = options.boot_cxy # boot cluster identifier |
---|
136 | cache_line = options.cache_line # number of bytes in a cache line |
---|
137 | |
---|
138 | hard_path = options.hard_path # path for hard_config.h file |
---|
139 | xml_path = options.xml_path # path for arch_info.xml file |
---|
140 | |
---|
141 | verbose = options.verbose # report on arch_info.bin generation |
---|
142 | |
---|
143 | |
---|
144 | ################################################################################### |
---|
145 | # Build the archinfo structure for the selected arch_info.py |
---|
146 | ################################################################################### |
---|
147 | |
---|
148 | if ( arch_path == None ): |
---|
149 | print 'You must define a path to the arch_info.py file on command line' |
---|
150 | sys.exit(1) |
---|
151 | |
---|
152 | # dynamically append arch_path to PYTHONPATH |
---|
153 | sys.path.append( arch_path ) |
---|
154 | |
---|
155 | # import the arch_info.py module (using file name without suffix) |
---|
156 | select = __import__( 'arch_info' ) |
---|
157 | print select |
---|
158 | |
---|
159 | # build the arch_info structure by calling the arch function |
---|
160 | archinfo = select.arch( x_size, |
---|
161 | y_size, |
---|
162 | nb_cores, |
---|
163 | nb_ttys, |
---|
164 | nb_nics, |
---|
165 | nb_cmas, |
---|
166 | fbf_size, |
---|
167 | ioc_type, |
---|
168 | mwr_type, |
---|
169 | io_cxy, |
---|
170 | boot_cxy, |
---|
171 | cache_line ) |
---|
172 | |
---|
173 | print '[genarch] archinfo build for %s' % archinfo.name |
---|
174 | |
---|
175 | ################################################################################### |
---|
176 | # Generate arch_info.xml file if required. |
---|
177 | ################################################################################### |
---|
178 | |
---|
179 | if ( xml_path != None ): |
---|
180 | pathname = xml_path + '/arch_info.xml' |
---|
181 | f = open ( pathname, 'w' ) |
---|
182 | f.write( archinfo.xml() ) |
---|
183 | |
---|
184 | print '[genarch] %s generated' % pathname |
---|
185 | |
---|
186 | ################################################################################### |
---|
187 | # Generate arch_info.bin file if required. |
---|
188 | ################################################################################### |
---|
189 | |
---|
190 | if ( bin_path != None ): |
---|
191 | pathname = bin_path + '/arch_info.bin' |
---|
192 | f = open ( pathname, 'wb' ) |
---|
193 | f.write( archinfo.cbin( verbose ) ) |
---|
194 | print '[genarch] %s generated' % pathname |
---|
195 | |
---|
196 | ################################################################################### |
---|
197 | # Generate hard_config.h file if required. |
---|
198 | ################################################################################### |
---|
199 | |
---|
200 | if ( hard_path != None ): |
---|
201 | |
---|
202 | pathname = hard_path + '/hard_config.h' |
---|
203 | f = open ( pathname, 'w' ) |
---|
204 | f.write( archinfo.hard_config() ) |
---|
205 | print '[genarch] %s generated' % pathname |
---|
206 | |
---|