source: soft/giet_vm/giet_python/platforms/tsar_generic_iob.py @ 305

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

Introducing python interface to generate the map.xml files.

  • Property svn:executable set to *
File size: 14.4 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5#################################################################################width #
6#   file   : tsar_generic_iob.py
7#   date   : april 2014
8#   author : Alain Greiner
9#######################################################################################
10#  This file contains a mapping generator for the tsar_generic_iob platform.
11#  This includes both the hardware architecture (clusters, processors, peripherals,
12#  physical space segmentation) and the mapping of all kernel objects (global vsegs).
13#  The parameters are:
14#  - x_size    : number of clusters in a row
15#  - y_size    : number of clusters in a column
16#  - nb_procs  : number of processors per cluster
17#  - nb_ttys   : number of TTY channels
18#  - nb_nics   : number of NIC channels
19#  - fbf_size  : frame_buffer width = frame_buffer heigth
20#  - x_io      : cluster_io x coordinate
21#  - y_io      : cluster_io y coordinate
22####################################################################################
23
24#####################################
25def tsar_generic_iob( x_size     = 2,
26                      y_size     = 2,
27                      nb_procs   = 1,
28                      nb_ttys    = 1,
29                      nb_nics    = 2, 
30                      fbf_width  = 128,
31                      x_io       = 0,
32                      y_io       = 0 ):
33                     
34    ### parameters checking
35    assert ( nb_procs <= 4 )
36    assert ( (x_size == 1) or (x_size == 2) or (x_size == 4) 
37             or (y_size == 8) or (x_size == 16) )
38    assert ( (y_size == 1) or (y_size == 2) or (y_size == 4) 
39             or (y_size == 8) or (y_size == 16) )
40    assert ( nb_ttys <= 2 )
41   
42    ### define architecture constants
43
44    platform_name = 'tsar_iob_%d_%d_%d' % (x_size, y_size, nb_procs)
45    x_width       = 4
46    y_width       = 4
47    paddr_width   = 40
48    irq_per_proc  = 1
49    use_ramdisk   = False
50
51    ### define physical segments
52
53    ram_base = 0x0000000000
54    ram_size = 0x4000000                         # 64 Mbytes
55
56    xcu_base = 0x00B0000000 
57    xcu_size = 0x1000                            # 4 Kbytes
58
59    dma_base = 0x00B1000000
60    dma_size = 0x1000 * nb_procs                 # 4 Kbytes * nb_procs
61
62    mmc_base = 0x00B2000000 
63    mmc_size = 0x1000                            # 4 Kbytes
64
65    offset_io = ((x_io << y_width) + y_io) << (paddr_width - x_width - y_width)
66
67    bdv_base  = 0x00B3000000 + offset_io
68    bdv_size  = 0x1000                           # 4kbytes
69
70    tty_base  = 0x00B4000000 + offset_io
71    tty_size  = 0x4000                           # 16 Kbytes
72
73    nic_base  = 0x00B5000000 + offset_io
74    nic_size  = 0x80000                          # 512 kbytes
75
76    cma_base  = 0x00B6000000 + offset_io
77    cma_size  = 0x1000 * 2 * nb_nics             # 4 kbytes * 2 * nb_nics
78
79    fbf_base  = 0x00B7000000 + offset_io
80    fbf_size  = fbf_width * fbf_width            # fbf_width * fbf_width bytes
81
82    pic_base  = 0x00B8000000 + offset_io
83    pic_size  = 0x1000                           # 4 Kbytes
84
85    iob_base  = 0x00BE000000 + offset_io
86    iob_size  = 0x1000                           # 4kbytes
87
88    rom_base  = 0x00BFC00000 + offset_io
89    rom_size  = 0x4000                           # 16 Kbytes
90
91    ### define  bootloader vsegs base addresses
92
93    boot_mapping_vbase   = 0x00000000            # ident
94    boot_mapping_vsize   = 0x00010000            # 64 Kbytes
95
96    boot_code_vbase      = 0x00010000            # ident
97    boot_code_vsize      = 0x00020000            # 128 Kbytes
98 
99    boot_data_vbase      = 0x00030000            # ident
100    boot_data_vsize      = 0x00010000            # 64 Kbytes
101
102    boot_buffer_vbase    = 0x00040000            # ident
103    boot_buffer_vsize    = 0x00060000            # 384 Kbytes
104
105    boot_stack_vbase     = 0x000A0000            # ident
106    boot_stack_vsize     = 0x00050000            # 320 Kbytes
107
108    ### define kernel vsegs base addresses
109
110    kernel_code_vbase    = 0x80000000           
111    kernel_code_vsize    = 0x00020000            # 128 Kbytes
112
113    kernel_data_vbase    = 0x80020000
114    kernel_data_vsize    = 0x00060000            # 384 Kbytes
115
116    kernel_uncdata_vbase = 0x80080000
117    kernel_uncdata_vsize = 0x00040000            # 256 Kbytes
118
119    kernel_init_vbase    = 0x800C0000
120    kernel_init_vsize    = 0x00010000            # 64 Kbytes
121
122    kernel_sched_vbase   = 0xF0000000            # distributed in all clusters
123    kernel_sched_vsize   = 0x1000 * nb_procs     # 4 kbytes per processor
124
125    ### create mapping
126
127    mapping = Mapping(  name         = platform_name,
128                        x_size       = x_size,
129                        y_size       = y_size,
130                        nb_procs     = nb_procs,
131                        x_width      = x_width, 
132                        y_width      = y_width,
133                        paddr_width  = paddr_width,
134                        coherence    = True,
135                        irq_per_proc = irq_per_proc,
136                        use_ramdisk  = use_ramdisk,
137                        x_io         = x_io,
138                        y_io         = y_io )
139
140    ###  add external peripherals
141
142    iob = Iob( 'PSEG_IOB', base = iob_base, size = iob_size )
143    mapping.addPeripheral( iob )
144
145    bdv = Bdv( 'PSEG_BDV', base = bdv_base, size = bdv_size )
146    mapping.addPeripheral( bdv )
147
148    tty = Tty( 'PSEG_TTY', base = tty_base, size = tty_size, channels = nb_ttys )
149    mapping.addPeripheral( tty )
150
151    nic = Nic( 'PSEG_NIC', base = nic_base, size = nic_size, channels = nb_nics ) 
152    mapping.addPeripheral( nic )
153
154    cma = Cma( 'PSEG_CMA', base = cma_base, size = cma_size, channels = 2 * nb_nics )
155    mapping.addPeripheral( cma )
156
157    fbf = Fbf( 'PSEG_FBF', base = fbf_base, size = fbf_size )
158    mapping.addPeripheral( fbf )
159
160    rom = Rom( 'PSEG_ROM', base = rom_base, size = rom_size )
161    mapping.addPeripheral( rom )
162
163    pic = Pic( 'PSEG_PIC', base = pic_base, size = pic_size, channels = 32 )
164    pic.add( PicIrq( srcid = 0  , dstx = 0, dsty = 0, dstid = 4  ) )
165    pic.add( PicIrq( srcid = 1  , dstx = 0, dsty = 0, dstid = 5  ) )
166    pic.add( PicIrq( srcid = 2  , dstx = 0, dsty = 0, dstid = 6  ) )
167    pic.add( PicIrq( srcid = 3  , dstx = 0, dsty = 0, dstid = 7  ) )
168    pic.add( PicIrq( srcid = 4  , dstx = 0, dsty = 0, dstid = 8  ) )
169    pic.add( PicIrq( srcid = 5  , dstx = 0, dsty = 0, dstid = 9  ) )
170    pic.add( PicIrq( srcid = 6  , dstx = 0, dsty = 0, dstid = 10 ) )
171    pic.add( PicIrq( srcid = 7  , dstx = 0, dsty = 0, dstid = 11 ) )
172    pic.add( PicIrq( srcid = 8  , dstx = 0, dsty = 0, dstid = 12 ) )
173    pic.add( PicIrq( srcid = 16 , dstx = 0, dsty = 0, dstid = 13 ) )
174    pic.add( PicIrq( srcid = 17 , dstx = 0, dsty = 0, dstid = 14 ) )
175    pic.add( PicIrq( srcid = 18 , dstx = 0, dsty = 1, dstid = 13 ) )
176    pic.add( PicIrq( srcid = 19 , dstx = 0, dsty = 1, dstid = 14 ) )
177    pic.add( PicIrq( srcid = 20 , dstx = 1, dsty = 0, dstid = 13 ) )
178    pic.add( PicIrq( srcid = 21 , dstx = 1, dsty = 0, dstid = 14 ) )
179    pic.add( PicIrq( srcid = 22 , dstx = 1, dsty = 1, dstid = 13 ) )
180    pic.add( PicIrq( srcid = 23 , dstx = 1, dsty = 1, dstid = 14 ) )
181    mapping.addPeripheral( pic )
182
183    ### add components replicated in all clusters   
184
185    for x in xrange( x_size ):
186        for y in xrange( y_size ):
187            cluster_xy = (x << y_width) + y;
188            offset     = cluster_xy << (paddr_width - x_width - y_width)
189
190            ram = Pseg( 'PSEG_RAM', base = ram_base + offset, size = ram_size, segtype = 'RAM' )
191            mapping.addPseg( ram )
192
193            mmc = Mmc( 'PSEG_MMC', base  = mmc_base + offset, size = mmc_size )
194            mapping.addPeripheral( mmc )
195
196            dma = Dma( 'PSEG_DMA', base = dma_base + offset, size = dma_size, channels  = nb_procs ) 
197            mapping.addPeripheral( dma )
198
199            xcu = Xcu( 'PSEG_XCU', base = xcu_base + offset, size = xcu_size, channels = nb_procs )
200            xcu.add ( XcuIrq ( srctype = 'HWI', srcid = 0, isrtype = 'ISR_MMC', dstid = 0 ) )
201            for p in xrange( nb_procs ):
202                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = p, isrtype = 'ISR_WAKUP', dstid = p ) )
203                xcu.add ( XcuIrq ( srctype = 'PTI', srcid = p, isrtype = 'ISR_TICK' , dstid = p ) )
204            if (x == 0) and (y == 0):
205                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 4  , isrtype = 'ISR_NIC_RX', channel = 0) )
206                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 5  , isrtype = 'ISR_NIC_RX', channel = 1) )
207                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 6  , isrtype = 'ISR_NIC_TX', channel = 0) )
208                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 7  , isrtype = 'ISR_NIC_TX', channel = 1) )
209                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 8  , isrtype = 'ISR_CMA'   , channel = 0) )
210                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 9  , isrtype = 'ISR_CMA'   , channel = 1) )
211                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 10 , isrtype = 'ISR_CMA'   , channel = 2) )
212                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 11 , isrtype = 'ISR_CMA'   , channel = 3) )
213                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 12 , isrtype = 'ISR_BDV'   , channel = 0) )
214                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 13 , isrtype = 'ISR_TTY_RX', channel = 0) )
215                xcu.add ( XcuIrq ( srctype = 'WTI', srcid = 14 , isrtype = 'ISR_TTY_RX', channel = 1) )
216            mapping.addPeripheral( xcu )
217
218    ### add processors
219
220    for x in xrange (x_size):
221        for y in xrange (y_size):
222            for p in xrange (nb_procs):
223                proc = Processor ( x, y, p )
224                mapping.addProc ( proc )
225
226    ### add global vsegs for boot_loader segments
227
228    vseg = Vseg( 'seg_boot_mapping'   , boot_mapping_vbase   , 'C_W_' , 0, 0, 'PSEG_RAM', ident = True )
229    vseg.add ( Vobj( 'boot_mapping'   , boot_mapping_vsize   , 'BLOB' , binpath = 'map.bin' ) )
230    mapping.addGlobal( vseg )   
231
232    vseg = Vseg( 'seg_boot_code'      , boot_code_vbase      , 'CXW_' , 0, 0, 'PSEG_RAM', ident = True )
233    vseg.add ( Vobj( 'boot_code'      , boot_code_vsize      , 'BUFFER' ) )
234    mapping.addGlobal( vseg )   
235   
236    vseg = Vseg( 'seg_boot_data'      , boot_data_vbase      , 'C_W_' , 0, 0, 'PSEG_RAM', ident = True )
237    vseg.add ( Vobj( 'boot_data'      , boot_data_vsize      , 'BUFFER' ) )
238    mapping.addGlobal( vseg )   
239
240    vseg = Vseg( 'seg_boot_buffer'    , boot_buffer_vbase    , 'C_W_' , 0, 0, 'PSEG_RAM', ident = True )
241    vseg.add ( Vobj( 'boot_buffer'    , boot_buffer_vsize    , 'BUFFER' ) )
242    mapping.addGlobal( vseg )   
243
244    vseg = Vseg( 'seg_boot_stack'     , boot_stack_vbase     , 'C_W_' , 0, 0, 'PSEG_RAM', ident = True )
245    vseg.add ( Vobj( 'boot_stack'     , boot_stack_vsize     , 'BUFFER' ) )
246    mapping.addGlobal( vseg )   
247
248    ### add global vsegs for kernel  segments
249
250    vseg = Vseg( 'seg_kernel_code'    , kernel_code_vbase    , 'CXW_' , 0, 0, 'PSEG_RAM' )
251    vseg.add ( Vobj( 'kernel_code'    , kernel_code_vsize    , 'ELF'  , binpath = 'build/kernel/kernel.elf' ) )
252    mapping.addGlobal( vseg )   
253
254    vseg = Vseg( 'seg_kernel_data'    , kernel_data_vbase    , 'C_W_' , 0, 0, 'PSEG_RAM' )
255    vseg.add ( Vobj( 'kernel_data'    , kernel_data_vsize    , 'ELF'  , binpath = 'build/kernel/kernel.elf' ) )
256    mapping.addGlobal( vseg )   
257
258    vseg = Vseg( 'seg_kernel_uncdata' , kernel_uncdata_vbase , '__W_' , 0, 0, 'PSEG_RAM' )
259    vseg.add ( Vobj( 'kernel_uncdata' , kernel_uncdata_vsize , 'ELF'  , binpath = 'build/kernel/kernel.elf' ) )
260    mapping.addGlobal( vseg )   
261
262    vseg = Vseg( 'seg_kernel_init'    , kernel_init_vbase    , 'CXW_' , 0, 0, 'PSEG_RAM' )
263    vseg.add ( Vobj( 'kernel_init'    , kernel_init_vsize    , 'ELF'  , binpath = 'build/kernel/kernel.elf' ) )
264    mapping.addGlobal( vseg )   
265
266    ### add global vsegs for external peripherals
267
268    vseg = Vseg( 'seg_iob'            , iob_base , '__W_' , 0, 0, 'PSEG_IOB' )
269    vseg.add ( Vobj( 'iob'            , iob_size , 'PERI' ) )
270    mapping.addGlobal( vseg )   
271
272    vseg = Vseg( 'seg_bdv'            , bdv_base , '__W_' , 0, 0, 'PSEG_BDV' )
273    vseg.add ( Vobj( 'bdv'            , bdv_size , 'PERI' ) )
274    mapping.addGlobal( vseg )   
275
276    vseg = Vseg( 'seg_tty'            , tty_base , '__W_' , 0, 0, 'PSEG_TTY' )
277    vseg.add ( Vobj( 'tty'            , tty_size , 'PERI' ) )
278    mapping.addGlobal( vseg )   
279
280    vseg = Vseg( 'seg_nic'            , nic_base , '__W_' , 0, 0, 'PSEG_NIC' )
281    vseg.add ( Vobj( 'nic'            , nic_size , 'PERI' ) )
282    mapping.addGlobal( vseg )   
283
284    vseg = Vseg( 'seg_cma'            , cma_base , '__W_' , 0, 0, 'PSEG_CMA' )
285    vseg.add ( Vobj( 'cma'            , cma_size , 'PERI' ) )
286    mapping.addGlobal( vseg )   
287
288    vseg = Vseg( 'seg_fbf'            , fbf_base , '__W_' , 0, 0, 'PSEG_FBF' )
289    vseg.add ( Vobj( 'fbf'            , fbf_size , 'PERI' ) )
290    mapping.addGlobal( vseg )   
291
292    vseg = Vseg( 'seg_pic'            , pic_base , '__W_' , 0, 0, 'PSEG_PIC' )
293    vseg.add ( Vobj( 'pic'            , pic_size , 'PERI' ) )
294    mapping.addGlobal( vseg )   
295
296    vseg = Vseg( 'seg_rom'            , rom_base , 'CXW_' , 0, 0, 'PSEG_ROM' )
297    vseg.add ( Vobj( 'rom'            , rom_size , 'PERI' ) )
298    mapping.addGlobal( vseg )   
299
300    ### Global vsegs for replicated XCU, DMA, MMC and Scheduler ###
301
302    for x in xrange (x_size):
303        for y in xrange (y_size):
304            offset = ((x << y_width) + y) << 16
305
306            vseg = Vseg( 'seg_xcu_%d_%d' %(x,y) , xcu_base + offset, '__W_' , x, y, 'PSEG_XCU' )
307            vseg.add ( Vobj( 'xcu_%d_%d' %(x,y) , xcu_size, 'PERI' ) )
308            mapping.addGlobal( vseg )
309
310            vseg = Vseg( 'seg_dma_%d_%d' %(x,y) , dma_base + offset, '__W_' , x, y, 'PSEG_DMA' )
311            vseg.add ( Vobj( 'dma_%d_%d' %(x,y) , dma_size, 'PERI' ) )
312            mapping.addGlobal( vseg )
313
314            vseg = Vseg( 'seg_mmc_%d_%d' %(x,y) , mmc_base + offset, '__W_' , x, y, 'PSEG_MMC' )
315            vseg.add ( Vobj( 'mmc_%d_%d' %(x,y) , mmc_size, 'PERI' ) )
316            mapping.addGlobal( vseg )
317
318            vseg = Vseg( 'seg_sch_%d_%d' %(x,y) , kernel_sched_vbase + offset, '__W_' , x, y, 'PSEG_RAM' )
319            vseg.add ( Vobj( 'sch_%d_%d' %(x,y) , kernel_sched_vsize, 'SCHED' ) )
320            mapping.addGlobal( vseg )
321
322    ### return mapping ###
323
324    return mapping
325
326################################# transpose test #######################################################
327
328if __name__ == '__main__':
329    print tsar_generic_iob()
330
331
332# Local Variables:
333# tab-width: 4;
334# c-basic-offset: 4;
335# c-file-offsets:((innamespace . 0)(inline-open . 0));
336# indent-tabs-mode: nil;
337# End:
338#
339# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
340
Note: See TracBrowser for help on using the repository browser.