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

Last change on this file since 592 was 586, checked in by alain, 5 years ago

Introduce the txt_type and fbf_type (and the associated use_txt_x & use_fbf_* variables)
in arch_info. For Both the C and python files. This was required to support the tsar_generic_leti architecture.

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