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

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

Add SYS_CLK parameter to set in params-hard

Add forgotten sys_clk parameter in Makefile

File size: 7.3 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( '--hard', type = 'string', dest = 'hard_path',
86                   help = 'define pathname to directory for the hard_config.h file ' )
87
88parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
89                   help = 'define pathname to directory for the arch_info.xml file' )
90
91parser.add_option( '--v', action = 'store_true', dest = 'verbose',
92                   default = False,
93                   help = 'display detailed report on arch_info.bin generation' )
94
95###################################################################################
96#   Get command line arguments
97###################################################################################
98
99(options,args) = parser.parse_args()
100
101arch_path      = options.arch_path   # path to arch_info.py file
102bin_path       = options.bin_path    # path for arch_info.bin file
103
104x_size         = options.x_size      # number of clusters in a row
105y_size         = options.y_size      # number of clusters in a column
106nb_cores       = options.nb_cores    # number of cores in a cluster
107nb_ttys        = options.nb_ttys     # number of TTY channels           
108fbf_size       = options.fbf_size    # frame buffer width & heigth
109nb_nics        = options.nb_nics     # number of NIC channels           
110ioc_type       = options.ioc_type    # ioc controller type
111sys_clk        = options.sys_clk     # system clock frequency in kHz
112
113hard_path      = options.hard_path   # path for hard_config.h file
114xml_path       = options.xml_path    # path for arch_info.xml file     
115
116verbose        = options.verbose     # report on arch_info.bin generation
117
118
119###################################################################################
120#   Build the archinfo structure for the selected arch_info.py
121###################################################################################
122
123if   ( arch_path == None  ): 
124    print 'You must define a path to the arch_info.py file on command line' 
125    sys.exit(1)
126
127# dynamically append arch_path to PYTHONPATH
128sys.path.append( arch_path )
129
130# import the arch_info.py module (using file name without suffix)
131select = __import__( 'arch_info' )
132print select
133
134# build the arch_info structure by calling the arch function
135archinfo = select.arch( x_size,
136                        y_size, 
137                        nb_cores,
138                        nb_ttys, 
139                        nb_nics, 
140                        fbf_size, 
141                        ioc_type )
142
143print '[genarch] archinfo build for %s' % archinfo.name
144
145###################################################################################
146#   Generate arch_info.xml file if required.
147###################################################################################
148
149if ( xml_path != None ):
150    pathname = xml_path + '/arch_info.xml'
151    f = open ( pathname, 'w' )
152    f.write( archinfo.xml() )
153
154    print '[genarch] %s generated' % pathname
155
156###################################################################################
157#   Generate arch_info.bin file if required.
158###################################################################################
159
160if ( bin_path != None ):
161    pathname = bin_path + '/arch_info.bin'
162    f = open ( pathname, 'wb' )
163    f.write( archinfo.cbin( verbose ) )
164    print '[genarch] %s generated' % pathname
165
166###################################################################################
167#   Generate hard_config.h file if required.
168###################################################################################
169
170if ( hard_path != None ):
171
172    pathname = hard_path + '/hard_config.h'
173    f = open ( pathname, 'w' )
174    f.write( archinfo.hard_config( ioc_type, sys_clk ) )
175    print '[genarch] %s generated' % pathname
176
Note: See TracBrowser for help on using the repository browser.