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

Last change on this file since 582 was 575, checked in by alain, 6 years ago

revert modifs done by Nicolas.
This line, and those below, will be ignored--

M genarch.py

File size: 7.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#  --fbf_size=int    : frame buffer width & heigth
26#  --ioc_type=string : can be IOC_BDV , IOC_HBA , IOC_SDC , IOC_SPI
27#
28# The following parameters can be used to generate the optional "hard_config.h" file,
29# that is required to configurate the SystemC virtual prototype, and the "arch_info.xml"
30# file for debug.
31#  --hard=string     : path to directory to store the "hard_config.h" file
32#  --xml=string      : path to directory to store the "arch_info.xml" file
33#
34#########################################################################################
35
36import sys
37
38from arch_classes import *
39from optparse import OptionParser
40
41###################################################################################
42#   define command line arguments   
43###################################################################################
44
45parser = OptionParser()
46
47parser.add_option( '--arch', type = 'string', dest = 'arch_path',
48                   help = 'define pathname to directory containing arch_info.py file' )
49
50parser.add_option( '--bin', type = 'string', dest = 'bin_path',
51                   help = 'define pathname to directory to store arch_info.bin file' )
52
53parser.add_option( '--x_size', type = 'int', dest = 'x_size', 
54                   default = 2,
55                   help = 'define number of clusters in a row' )
56
57parser.add_option( '--y_size', type = 'int', dest = 'y_size', 
58                   default = 2,
59                   help = 'define number of clusters in a column' )
60
61parser.add_option( '--nb_cores', type = 'int', dest = 'nb_cores', 
62                   default = 2,
63                   help = 'define number of cores per cluster' )
64
65parser.add_option( '--nb_ttys', type = 'int', dest = 'nb_ttys', 
66                   default = 1,
67                   help = 'define number of TTY channels' )
68
69parser.add_option( '--nb_nics', type = 'int', dest = 'nb_nics',
70                   default = 1,
71                   help = 'define number ot NIC channels' )
72
73parser.add_option( '--fbf_size', type = 'int', dest = 'fbf_size', 
74                   default = 128,
75                   help = 'define frame buffer width and heigth' )
76
77parser.add_option( '--ioc_type', type = 'string', dest = 'ioc_type',
78                   default = 'IOC_BDV',
79                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
80
81parser.add_option( '--sys_clk', type = 'int', dest = 'sys_clk', 
82                   default = 25000,
83                   help = 'define system clock frequency (25MHz for FPGA, 600MHz for TSARLET)' )
84
85parser.add_option( '--segs_set', type = 'string', dest = 'segs_set',
86                   default = 'SIMU',
87                   help = 'define which set of base addresses to use (may differ between simulation and real machine' )
88
89parser.add_option( '--hard', type = 'string', dest = 'hard_path',
90                   help = 'define pathname to directory for the hard_config.h file ' )
91
92parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
93                   help = 'define pathname to directory for the arch_info.xml file' )
94
95parser.add_option( '--v', action = 'store_true', dest = 'verbose',
96                   default = False,
97                   help = 'display detailed report on arch_info.bin generation' )
98
99###################################################################################
100#   Get command line arguments
101###################################################################################
102
103(options,args) = parser.parse_args()
104
105arch_path      = options.arch_path   # path to arch_info.py file
106bin_path       = options.bin_path    # path for arch_info.bin file
107
108x_size         = options.x_size      # number of clusters in a row
109y_size         = options.y_size      # number of clusters in a column
110nb_cores       = options.nb_cores    # number of cores in a cluster
111nb_ttys        = options.nb_ttys     # number of TTY channels           
112fbf_size       = options.fbf_size    # frame buffer width & heigth
113nb_nics        = options.nb_nics     # number of NIC channels           
114ioc_type       = options.ioc_type    # ioc controller type
115sys_clk        = options.sys_clk     # system clock frequency in kHz
116segs_set       = options.segs_set    # Set of base addresses used (simu or real)
117
118hard_path      = options.hard_path   # path for hard_config.h file
119xml_path       = options.xml_path    # path for arch_info.xml file     
120
121verbose        = options.verbose     # report on arch_info.bin generation
122
123
124###################################################################################
125#   Build the archinfo structure for the selected arch_info.py
126###################################################################################
127
128if   ( arch_path == None  ): 
129    print 'You must define a path to the arch_info.py file on command line' 
130    sys.exit(1)
131
132# dynamically append arch_path to PYTHONPATH
133sys.path.append( arch_path )
134
135# import the arch_info.py module (using file name without suffix)
136select = __import__( 'arch_info' )
137print select
138
139# build the arch_info structure by calling the arch function
140archinfo = select.arch( x_size,
141                        y_size, 
142                        nb_cores,
143                        nb_ttys, 
144                        nb_nics, 
145                        fbf_size, 
146                        ioc_type )
147
148print '[genarch] archinfo build for %s' % archinfo.name
149
150###################################################################################
151#   Generate arch_info.xml file if required.
152###################################################################################
153
154if ( xml_path != None ):
155    pathname = xml_path + '/arch_info.xml'
156    f = open ( pathname, 'w' )
157    f.write( archinfo.xml() )
158
159    print '[genarch] %s generated' % pathname
160
161###################################################################################
162#   Generate arch_info.bin file if required.
163###################################################################################
164
165if ( bin_path != None ):
166    pathname = bin_path + '/arch_info.bin'
167    f = open ( pathname, 'wb' )
168    f.write( archinfo.cbin( verbose ) )
169    print '[genarch] %s generated' % pathname
170
171###################################################################################
172#   Generate hard_config.h file if required.
173###################################################################################
174
175if ( hard_path != None ):
176
177    pathname = hard_path + '/hard_config.h'
178    f = open ( pathname, 'w' )
179    f.write( archinfo.hard_config() )
180    print '[genarch] %s generated' % pathname
181
Note: See TracBrowser for help on using the repository browser.