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

Last change on this file since 563 was 553, checked in by nicolas.van.phan@…, 6 years ago

Add SEGS_SET param in params-hard.mk

File size: 7.7 KB
RevLine 
[1]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
[548]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
[553]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
[1]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
[548]115sys_clk        = options.sys_clk     # system clock frequency in kHz
[553]116segs_set       = options.segs_set    # Set of base addresses used (simu or real)
[1]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, 
[553]146                        ioc_type,
147                        segs_set )
[1]148
149print '[genarch] archinfo build for %s' % archinfo.name
150
151###################################################################################
152#   Generate arch_info.xml file if required.
153###################################################################################
154
155if ( xml_path != None ):
156    pathname = xml_path + '/arch_info.xml'
157    f = open ( pathname, 'w' )
158    f.write( archinfo.xml() )
159
160    print '[genarch] %s generated' % pathname
161
162###################################################################################
163#   Generate arch_info.bin file if required.
164###################################################################################
165
166if ( bin_path != None ):
167    pathname = bin_path + '/arch_info.bin'
168    f = open ( pathname, 'wb' )
169    f.write( archinfo.cbin( verbose ) )
170    print '[genarch] %s generated' % pathname
171
172###################################################################################
173#   Generate hard_config.h file if required.
174###################################################################################
175
176if ( hard_path != None ):
177
178    pathname = hard_path + '/hard_config.h'
179    f = open ( pathname, 'w' )
[548]180    f.write( archinfo.hard_config( ioc_type, sys_clk ) )
[1]181    print '[genarch] %s generated' % pathname
182
Note: See TracBrowser for help on using the repository browser.