source: soft/giet_vm/giet_python/genmap @ 521

Last change on this file since 521 was 520, checked in by alain, 10 years ago

1) Simplification of the mapping objects: the coproc and cp_port objects
have been removedr.:A coprocessor is now described as a peripheral with MWR type,
and the coprocessor type is defined by the subtype argument.
The addPeriph() prototype has been modified to support 4 arguments: arg0, arg1, arg2, arg3
(the semanting depends on the peripheral type).

2) A new application, called "coproc", and using the GCD coprocessor and
the MWMR_DMA controller, has been introduced in genmap.

  • Property svn:executable set to *
File size: 12.3 KB
Line 
1#!/usr/bin/env python
2
3#######################################################################################
4#   file   : genmap
5#   date   : april 2014
6#   author : Alain Greiner
7#######################################################################################
8# This generic script maps one or several applications on a specific
9# instance of the multi-processors/multi-clusters TSAR architecture.
10# It generates the files required for hardware and software compilation:
11# 1) The "hard_config.h" file is used to generate the top.cpp file (hardware),
12#    and to compile the tsar_preloader.elf, the GietVM boot.elf and kernel.elf files.
13# 2) The optionals "map.bin" and vsegs.ld" files are used to configure the GietVM.
14# 3) The optional "netbsd.dts" file can be used to configure NetBSD.
15# 4) The optional "netbsd.dts" file can be used to configure NetBSD.
16# 5) The optional "arch.bib" file can be used to configure ALMOS.
17# 6) An optional "map.xml" file can be generated for debug.
18#######################################################################################
19# The hardware parameters  are:
20#  - x_size    : number of clusters in a row
21#  - y_size    : number of clusters in a column
22#  - nb_procs  : number of processors per cluster
23#  - nb_ttys   : number of TTY channels
24#  - fbf_size  : frame buffer width & heigth
25#######################################################################################
26# The supported platforms are:
27# - tsar_generic_iob
28# - tsar_generic_leti
29# - tsar_geberic_mwmr
30#######################################################################################
31# The supported applications are:
32# - sort
33# - transpose
34# - convol
35# - router
36# - classif
37# - display
38# - gameoflife
39# - coproc
40#######################################################################################
41
42from optparse import OptionParser
43from mapping import *
44
45import sys
46
47######################################################################################
48#   define command line arguments   
49######################################################################################
50
51parser = OptionParser()
52
53parser.add_option( '--arch', type = 'string', dest = 'arch_path',
54                   help = 'define pathname to architecture' )
55
56parser.add_option( '--x', type = 'int', dest = 'x_size', 
57                   default = 2,
58                   help = 'define number of clusters in a row' )
59
60parser.add_option( '--y', type = 'int', dest = 'y_size', 
61                   default = 2,
62                   help = 'define number of clusters in a column' )
63
64parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
65                   default = 2,
66                   help = 'define number of processors per cluster' )
67
68parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
69                   default = 1,
70                   help = 'define number of tty channels' )
71
72parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
73                   default = 128,
74                   help = 'define frame buffer width and heigth' )
75
76parser.add_option( '--v', action = 'store_true', dest = 'verbose',
77                   default = False,
78                   help = 'display detailed report on map.bin file generation' )
79
80parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path', 
81                   help = 'define pathname for the netbsd.dts file' )
82
83parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
84                   help = 'define pathname for the linux.dts file' )
85
86parser.add_option( '--almos', type = 'string', dest = 'almos_path', 
87                   help = 'define pathname for the arch.bib file' )
88
89parser.add_option( '--giet', type = 'string', dest = 'giet_path', 
90                   help = 'define pathname for the map.bin & vsegs.ld file ' )
91
92parser.add_option( '--hard', type = 'string', dest = 'hard_path',
93                   help = 'define pathname for the hard_config.h file ' )
94
95parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
96                   help = 'define pathname for the map.xml file' )
97
98############  supported applications   ###############################################
99
100parser.add_option( '--transpose', action = 'store_true', dest = 'transpose',
101                   default = False,
102                   help = 'map the "transpose" application for the GietVM' )
103
104parser.add_option( '--sort', action = 'store_true', dest = 'sort',     
105                   default = False,
106                   help = 'map the "sort" application for the GietVM' )
107
108parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
109                   default = False,
110                   help = 'map the "convol" application for the GietVM' )
111
112parser.add_option( '--router', action = 'store_true', dest = 'router',     
113                   default = False,
114                   help = 'map the "router" application for the GietVM' )
115
116parser.add_option( '--display', action = 'store_true', dest = 'display',     
117                   default = False,
118                   help = 'map the "display" application for the GietVM' )
119
120parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
121                   default = False,
122                   help = 'map the "classif" application for the GietVM' )
123
124parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
125                   default = False,
126                   help = 'map the "gameoflife" application for the GietVM' )
127
128parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
129                   default = False,
130                   help = 'map the "coproc" application for the GietVM' )
131
132######################################################################################
133#   Get command line arguments
134######################################################################################
135
136(options,args) = parser.parse_args()
137
138x_size         = options.x_size      # number of clusters in a row
139y_size         = options.y_size      # number of clusters in a column
140nb_procs       = options.nb_procs    # number of processors in a cluster
141nb_ttys        = options.nb_ttys     # number of TTY channels           
142fbf_size       = options.fbf_size    # frame buffer width & heigth
143
144verbose        = options.verbose     # report on map.bin generation if True
145
146netbsd_path    = options.netbsd_path # path for netbsd.dts file
147linux_path     = options.linux_path  # path for linux.dts file
148almos_path     = options.almos_path  # path for arch.bib file
149giet_path      = options.giet_path   # path for map.bin & vsegs.ld files
150hard_path      = options.hard_path   # path for the hard_config.h file
151
152arch_path      = options.arch_path   # path to selected architecture
153
154xml_path       = options.xml_path    # path for map.xml file     
155
156map_transpose  = options.transpose   # map "transpose" application if True
157map_sort       = options.sort        # map "sort" application if True
158map_convol     = options.convol      # map "convol" application if True
159map_router     = options.router      # map "router" application if True
160map_display    = options.display     # map "display" application if True
161map_classif    = options.classif     # map "classif" application if True
162map_gameoflife = options.gameoflife  # map "gameoflife" application if True
163map_coproc     = options.coproc      # map "coproc" application if True
164
165######################################################################################
166#   build empty platform (no applications yet)
167######################################################################################
168
169if   ( arch_path == None  ): 
170    print 'You must select a generic architecture on the command line' 
171    sys.exit(1)
172
173# dynamically append the architecture to PYTHON path (directory pathname)
174sys.path.append( arch_path )
175
176# dynamically import the PYTHON mapping generator module (file name)
177select = __import__( 'arch' )
178
179# build mapping calling the function (function name)
180mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size )
181print '[genmap] platform %s build' % mapping.name
182
183######################################################################################
184#   complete mapping with application(s) as required
185######################################################################################
186
187if ( map_transpose ):
188    app = __import__( 'transpose' )
189    app.transpose( mapping )
190    print '[genmap] application "transpose" will be loaded'
191
192if ( map_sort ):     
193    app = __import__( 'sort' )
194    app.sort( mapping )
195    print '[genmap] application "sort" will be loaded'
196
197if ( map_convol ):     
198    app = __import__( 'convol' )
199    app.convol( mapping )
200    print '[genmap] application "convol" will be loaded'
201
202if ( map_router ):     
203    app = __import__( 'router' )
204    app.router( mapping )
205    print '[genmap] application "router" will be loaded'
206
207if ( map_display ):     
208    app = __import__( 'display' )
209    app.display( mapping )
210    print '[genmap] application "display" will be loaded'
211
212if ( map_classif ):     
213    app = __import__( 'classif' )
214    app.classif( mapping )
215    print '[genmap] application "classif" will be loaded'
216
217if ( map_gameoflife ):
218    app = __import__( 'gameoflife' )
219    app.gameoflife( mapping )
220    print '[genmap] application "gameoflife" will be loaded'
221
222if ( map_coproc ):
223    app = __import__( 'coproc' )
224    app.coproc( mapping )
225    print '[genmap] application "coproc" will be loaded'
226
227######################################################################################
228#   Generate xml file if required.
229#   It can be used for debug.
230######################################################################################
231
232if ( xml_path != None ):
233    pathname = xml_path + '/map.xml'
234    f = open ( pathname, 'w' )
235    f.write( mapping.xml() )
236    print '[genmap] %s generated for debug' % pathname
237
238######################################################################################
239#   Generate netbsd.dts file if required.
240#   It is used for NetBSD configuration.
241######################################################################################
242
243if ( (netbsd_path != None) and (arch_path != None) ):
244    pathname = netbsd_path + '/netbsd.dts'
245    f = open ( pathname, 'w' )
246    f.write( mapping.netbsd_dts() )
247    print '[genmap] %s generated' % pathname
248
249######################################################################################
250#   Generate linux.dts file if required.
251#   It is used for LINUX configuration.
252######################################################################################
253
254if ( (linux_path != None) and (arch_path != None) ):
255    pathname = linux_path + '/linux.dts'
256    f = open ( pathname, 'w' )
257    f.write( mapping.linux_dts() )
258    print '[genmap] %s generated' % pathname
259
260######################################################################################
261#   Generate arch.bib file if required.
262#   It is used for ALMOS configuration.
263######################################################################################
264
265if ( (almos_path != None) and (arch_path != None) ):
266    pathname = almos_path + '/arch.info'
267    f = open ( pathname, 'w' )
268    f.write( mapping.almos_arch() )
269    print '[genmap] %s generated for almos' % pathname
270
271######################################################################################
272#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
273#   They are used for GietVM compilation and configuration.
274######################################################################################
275
276if ( (giet_path != None) and (arch_path != None) ):
277
278    pathname = giet_path + '/map.bin'
279    f = open ( pathname, 'w' )
280    f.write( str( mapping.cbin( verbose ) ) )
281    print '[genmap] %s generated for giet_vm' % pathname
282
283    pathname = giet_path + '/hard_config.h'
284    f = open ( pathname, 'w' )
285    f.write( mapping.hard_config() )
286    print '[genmap] %s generated for giet_vm' % pathname
287
288    pathname = giet_path + '/giet_vsegs.ld'
289    f = open ( pathname, 'w' )
290    f.write( mapping.giet_vsegs() )
291    print '[genmap] %s generated for giet_vm' % pathname
292
293######################################################################################
294#   Generate hard_config.h file if required.
295######################################################################################
296
297if ( hard_path != None ):
298
299    pathname = hard_path + '/hard_config.h'
300    f = open ( pathname, 'w' )
301    f.write( mapping.hard_config() )
302    print '[genmap] %s generated for %s' % (pathname, arch_path)
303
Note: See TracBrowser for help on using the repository browser.