source: trunk/tools/arch_info/genarch.py @ 1

Last change on this file since 1 was 1, checked in by alain, 7 years ago

First import

File size: 8.6 KB
Line 
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
41import sys
42
43from arch_classes import *
44from optparse import OptionParser
45
46###################################################################################
47#   define command line arguments   
48###################################################################################
49
50parser = OptionParser()
51
52parser.add_option( '--arch', type = 'string', dest = 'arch_path',
53                   help = 'define pathname to directory containing arch_info.py file' )
54
55parser.add_option( '--bin', type = 'string', dest = 'bin_path',
56                   help = 'define pathname to directory to store arch_info.bin file' )
57
58parser.add_option( '--x_size', type = 'int', dest = 'x_size', 
59                   default = 2,
60                   help = 'define number of clusters in a row' )
61
62parser.add_option( '--y_size', type = 'int', dest = 'y_size', 
63                   default = 2,
64                   help = 'define number of clusters in a column' )
65
66parser.add_option( '--nb_cores', type = 'int', dest = 'nb_cores', 
67                   default = 2,
68                   help = 'define number of cores per cluster' )
69
70parser.add_option( '--nb_ttys', type = 'int', dest = 'nb_ttys', 
71                   default = 1,
72                   help = 'define number of TTY channels' )
73
74parser.add_option( '--nb_nics', type = 'int', dest = 'nb_nics',
75                   default = 1,
76                   help = 'define number ot NIC channels' )
77
78parser.add_option( '--nb_cmas', type = 'int', dest = 'nb_cmas',
79                   default = 2,
80                   help = 'define number ot CMA channels' )
81
82parser.add_option( '--fbf_size', type = 'int', dest = 'fbf_size', 
83                   default = 128,
84                   help = 'define frame buffer width and heigth' )
85
86parser.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
90parser.add_option( '--mwr_type', type = 'string', dest = 'mwr_type',
91                   default = 'MWR_CPY',
92                   help = 'define type of COPROC: CPY / DCT / GCD' )
93
94parser.add_option( '--io_cxy', type = 'int', dest = 'io_cxy',
95                   default = 0,
96                   help = 'define IO cluster identifier' )
97
98parser.add_option( '--boot_cxy', type = 'int', dest = 'boot_cxy',
99                   default = 0,
100                   help = 'define boot cluster identifier' )
101
102parser.add_option( '--cache_line', type = 'int', dest = 'cache_line',
103                   default = 64,
104                   help = 'define number of bytes in a cache line' )
105
106parser.add_option( '--hard', type = 'string', dest = 'hard_path',
107                   help = 'define pathname to directory for the hard_config.h file ' )
108
109parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
110                   help = 'define pathname to directory for the arch_info.xml file' )
111
112parser.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
122arch_path      = options.arch_path   # path to arch_info.py file
123bin_path       = options.bin_path    # path for arch_info.bin file
124
125x_size         = options.x_size      # number of clusters in a row
126y_size         = options.y_size      # number of clusters in a column
127nb_cores       = options.nb_cores    # number of cores in a cluster
128nb_ttys        = options.nb_ttys     # number of TTY channels           
129fbf_size       = options.fbf_size    # frame buffer width & heigth
130nb_nics        = options.nb_nics     # number of NIC channels           
131nb_cmas        = options.nb_cmas     # number of CMA channels           
132ioc_type       = options.ioc_type    # ioc controller type
133mwr_type       = options.mwr_type    # hardware coprocessor type
134io_cxy         = options.io_cxy      # IO cluster identifier
135boot_cxy       = options.boot_cxy    # boot cluster identifier
136cache_line     = options.cache_line  # number of bytes in a cache line
137
138hard_path      = options.hard_path   # path for hard_config.h file
139xml_path       = options.xml_path    # path for arch_info.xml file     
140
141verbose        = options.verbose     # report on arch_info.bin generation
142
143
144###################################################################################
145#   Build the archinfo structure for the selected arch_info.py
146###################################################################################
147
148if   ( 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
153sys.path.append( arch_path )
154
155# import the arch_info.py module (using file name without suffix)
156select = __import__( 'arch_info' )
157print select
158
159# build the arch_info structure by calling the arch function
160archinfo = 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
173print '[genarch] archinfo build for %s' % archinfo.name
174
175###################################################################################
176#   Generate arch_info.xml file if required.
177###################################################################################
178
179if ( 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
190if ( 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
200if ( 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
Note: See TracBrowser for help on using the repository browser.