source: branches/reconfiguration/platforms/tsar_generic_iob/scripts/arch.py @ 775

Last change on this file since 775 was 774, checked in by cfuguet, 10 years ago

reconfiguration/tsar_generic_iob: moving all python scripts in subdirectory

  • The run.py don't use anymore the genmap tool. It uses directly the a new main function in the arch.py module to generate the hard_config.h
  • Property svn:executable set to *
File size: 14.8 KB
RevLine 
[747]1#!/usr/bin/env python
[774]2import sys
[747]3from mapping import *
4
5#######################################################################################
6#   file   : arch.py  (for the tsar_generic_iob architecture)
7#   date   : may 2014
8#   author : Alain Greiner
9#######################################################################################
[748]10#  This file contains a mapping generator for the "tsar_generic_iob" platform.
[747]11#  This includes both the hardware architecture (clusters, processors, peripherals,
12#  physical space segmentation) and the mapping of all kernel objects (global vsegs).
13#  This platform includes 6 external peripherals, accessible through two IO_Bridge
14#  components located in cluster [0,0] and cluster [x_size-1, y_size-1].
15#  Available peripherals are: TTY, BDV, FBF, ROM, NIC, CMA.
16#
17#  The "constructor" parameters are:
18#  - x_size         : number of clusters in a row
19#  - y_size         : number of clusters in a column
20#  - nb_procs       : number of processors per cluster
21#
[766]22#  The "hidden" parameters (defined below) are:
[747]23#  - nb_ttys        : number of TTY channels
24#  - nb_nics        : number of NIC channels
25#  - fbf_width      : frame_buffer width = frame_buffer heigth
26#  - x_io           : cluster_io x coordinate
27#  - y_io           : cluster_io y coordinate
28#  - x_width        : number of bits for x coordinate
29#  - y_width        : number of bits for y coordinate
30#  - paddr_width    : number of bits for physical address
31#  - irq_per_proc   : number of input IRQs per processor
32#  - use_ramdisk    : use a ramdisk when True
33#  - peri_increment : address increment for replicated peripherals
34####################################################################################
35
36########################
37def arch( x_size    = 2,
38          y_size    = 2,
39          nb_procs  = 2 ):
40
41    ### define architecture constants
42
43    nb_ttys           = 1
[748]44    nb_nics           = 2
[766]45    fbf_width         = 128
[747]46    x_io              = 0
47    y_io              = 0
48    x_width           = 4
49    y_width           = 4
50    paddr_width       = 40
51    irq_per_proc      = 4
52    use_ramdisk       = False
53    peri_increment    = 0x10000
54    distributed_ptabs = True
[748]55
[747]56    ### parameters checking
57
58    assert( nb_procs <= 4 )
59
[748]60    assert( (x_size == 1) or (x_size == 2) or (x_size == 4)
[766]61             or (x_size == 8) or (x_size == 16) )
[747]62
[748]63    assert( (y_size == 1) or (y_size == 2) or (y_size == 4)
[747]64             or (y_size == 8) or (y_size == 16) )
65
66    assert( nb_ttys == 1 )
67
68    assert( ((x_io == 0) and (y_io == 0)) or
69            ((x_io == x_size-1) and (y_io == y_size-1)) )
70
71    platform_name  = 'tsar_iob_%d_%d_%d' % ( x_size, y_size, nb_procs )
[748]72
[747]73    ### define physical segments
74
[748]75    ram_base  = 0x0000000000
[768]76    if 0: ram_size  = 0x4000000            # 64 Mbytes
77    else: ram_size  = 0x0040000            # 256 Kbytes
[747]78
[748]79    xcu_base  = 0x00B0000000
80    xcu_size  = 0x1000                     # 4 Kbytes
[747]81
[748]82    dma_base  = 0x00B1000000
83    dma_size  = 0x1000 * nb_procs          # 4 Kbytes * nb_procs
[747]84
[748]85    mmc_base  = 0x00B2000000
86    mmc_size  = 0x1000                     # 4 Kbytes
[747]87
[748]88    rom_base  = 0x00BFC00000
89    rom_size  = 0x8000                     # 32 Kbytes
90
[747]91    offset_io = ((x_io << y_width) + y_io) << (paddr_width - x_width - y_width)
92
93    bdv_base  = 0x00B3000000 + offset_io
94    bdv_size  = 0x1000                     # 4kbytes
95
96    tty_base  = 0x00B4000000 + offset_io
97    tty_size  = 0x4000                     # 16 Kbytes
98
99    nic_base  = 0x00B5000000 + offset_io
100    nic_size  = 0x80000                    # 512 kbytes
101
102    cma_base  = 0x00B6000000 + offset_io
103    cma_size  = 0x1000 * 2 * nb_nics       # 4 kbytes * 2 * nb_nics
104
105    fbf_base  = 0x00B7000000 + offset_io
106    fbf_size  = fbf_width * fbf_width      # fbf_width * fbf_width bytes
107
108    pic_base  = 0x00B8000000 + offset_io
109    pic_size  = 0x1000                     # 4 Kbytes
110
[769]111    sim_base  = 0x00B9000000 + offset_io
112    sim_size  = 0x1000                     # 4 kbytes
113
[747]114    iob_base  = 0x00BE000000 + offset_io
[748]115    iob_size  = 0x1000                     # 4 kbytes
[747]116
[748]117    ### GIET_VM specifics virtual segments
[766]118    ### define bootloader vsegs base addresses
[747]119
120    boot_mapping_vbase   = 0x00000000      # ident
[766]121    boot_mapping_size    = 0x00080000      # 512 Kbytes
[747]122
[766]123    boot_code_vbase      = 0x00080000      # ident
124    boot_code_size       = 0x00040000      # 256 Kbytes
[748]125
[766]126    boot_data_vbase      = 0x000C0000      # ident
127    boot_data_size       = 0x00080000      # 512 Kbytes
[747]128
[766]129    boot_stack_vbase     = 0x00140000      # ident
130    boot_stack_size      = 0x00050000      # 320 Kbytes
[747]131
[766]132    ### define kernel vsegs base addresses and sizes
[747]133
[748]134    kernel_code_vbase    = 0x80000000
[747]135    kernel_code_size     = 0x00020000      # 128 Kbytes
136
137    kernel_data_vbase    = 0x80020000
[766]138    kernel_data_size     = 0x00020000      # 128 Kbytes
[747]139
[766]140    kernel_uncdata_vbase = 0x80040000
141    kernel_uncdata_size  = 0x00010000      # 64 Kbytes
[747]142
[766]143    kernel_init_vbase    = 0x80050000
[747]144    kernel_init_size     = 0x00010000      # 64 Kbytes
145
146    kernel_sched_vbase   = 0xF0000000            # distributed in all clusters
[766]147    kernel_sched_size    = 0x2000 * nb_procs     # 8 kbytes per processor
[747]148
149    ### create mapping
150
[748]151    mapping = Mapping( name           = platform_name,
152                       x_size         = x_size,
153                       y_size         = y_size,
154                       procs_max      = nb_procs,
155                       x_width        = x_width,
156                       y_width        = y_width,
157                       paddr_width    = paddr_width,
158                       coherence      = True,
159                       irq_per_proc   = irq_per_proc,
160                       use_ramdisk    = use_ramdisk,
161                       x_io           = x_io,
[747]162                       y_io           = y_io,
[748]163                       peri_increment = peri_increment,
164                       ram_base       = ram_base,
165                       ram_size       = ram_size )
[747]166
167    ###  external peripherals (accessible in cluster[0,0] only for this mapping)
168
169    iob = mapping.addPeriph( 'IOB', base = iob_base, size = iob_size, ptype = 'IOB' )
170
171    bdv = mapping.addPeriph( 'BDV', base = bdv_base, size = bdv_size, ptype = 'IOC', subtype = 'BDV' )
172
173    tty = mapping.addPeriph( 'TTY', base = tty_base, size = tty_size, ptype = 'TTY', channels = nb_ttys )
174
[748]175    nic = mapping.addPeriph( 'NIC', base = nic_base, size = nic_size, ptype = 'NIC', channels = nb_nics )
[747]176
177    cma = mapping.addPeriph( 'CMA', base = cma_base, size = cma_size, ptype = 'CMA', channels = 2*nb_nics )
178
179    fbf = mapping.addPeriph( 'FBF', base = fbf_base, size = fbf_size, ptype = 'FBF', arg = fbf_width )
180
181    pic = mapping.addPeriph( 'PIC', base = pic_base, size = pic_size, ptype = 'PIC', channels = 32 )
182
[769]183    sim = mapping.addPeriph( 'SIM', base = sim_base, size = sim_size, ptype = 'SIM' )
184
[747]185    mapping.addIrq( pic, index = 0, isrtype = 'ISR_NIC_RX', channel = 0 )
186    mapping.addIrq( pic, index = 1, isrtype = 'ISR_NIC_RX', channel = 1 )
187
188    mapping.addIrq( pic, index = 2, isrtype = 'ISR_NIC_TX', channel = 0 )
189    mapping.addIrq( pic, index = 3, isrtype = 'ISR_NIC_TX', channel = 1 )
190
191    mapping.addIrq( pic, index = 4, isrtype = 'ISR_CMA'   , channel = 0 )
192    mapping.addIrq( pic, index = 5, isrtype = 'ISR_CMA'   , channel = 1 )
193    mapping.addIrq( pic, index = 6, isrtype = 'ISR_CMA'   , channel = 2 )
194    mapping.addIrq( pic, index = 7, isrtype = 'ISR_CMA'   , channel = 3 )
195
196    mapping.addIrq( pic, index = 8, isrtype = 'ISR_BDV'   , channel = 0 )
197
198    mapping.addIrq( pic, index = 9, isrtype = 'ISR_TTY_RX', channel = 0 )
199
[748]200    ### hardware components replicated in all clusters
[747]201
202    for x in xrange( x_size ):
203        for y in xrange( y_size ):
204            cluster_xy = (x << y_width) + y;
205            offset     = cluster_xy << (paddr_width - x_width - y_width)
206
207            ram = mapping.addRam( 'RAM', base = ram_base + offset, size = ram_size )
208
[748]209            mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset, size = mmc_size,
[747]210                                     ptype = 'MMC' )
211
[748]212            dma = mapping.addPeriph( 'DMA', base = dma_base + offset, size = dma_size,
213                                     ptype = 'DMA', channels = nb_procs )
[747]214
[748]215            xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, size = xcu_size,
[747]216                                     ptype = 'XCU', channels = nb_procs * irq_per_proc, arg = 16 )
217
[748]218            rom = mapping.addPeriph( 'ROM', base = rom_base + offset, size = rom_size,
219                                     ptype = 'ROM' )
220
[747]221            # MMC IRQ replicated in all clusters
222            mapping.addIrq( xcu, index = 0, isrtype = 'ISR_MMC' )
223
[770]224            # DMA IRQ replicated in all clusters
225            for i in xrange ( dma.channels ):
226                mapping.addIrq( xcu, index = 1+i, isrtype = 'ISR_DMA',
227                        channel = i )
228
[747]229            # processors
230            for p in xrange ( nb_procs ):
231                mapping.addProc( x, y, p )
232
[748]233    ### global vsegs for boot_loader / identity mapping
[747]234
[766]235    mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size,
236                       'C_W_', vtype = 'BLOB'  , x = 0, y = 0, pseg = 'RAM',
237                       identity = True )
[747]238
[766]239    mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size,
240                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
241                       identity = True )
[747]242
[766]243    mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size,
244                       'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
245                       identity = True )
[747]246
[766]247    mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size,
248                       'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
249                       identity = True )
[747]250
[766]251    ### the code global vsegs for kernel can be replicated in all clusters
252    ### if the page tables are distributed in all clusters.
[747]253
254    if distributed_ptabs:
255        for x in xrange( x_size ):
256            for y in xrange( y_size ):
257                cluster_xy = (x << y_width) + y;
258
259                mapping.addGlobal( 'seg_kernel_code', kernel_code_vbase, kernel_code_size,
260                                   'CXW_', vtype = 'ELF', x = x , y = y , pseg = 'RAM',
261                                   binpath = 'build/kernel/kernel.elf', local = True )
262
263                mapping.addGlobal( 'seg_kernel_init', kernel_init_vbase, kernel_init_size,
264                                   'CXW_', vtype = 'ELF', x = x , y = y , pseg = 'RAM',
265                                   binpath = 'build/kernel/kernel.elf', local = True )
266    else:
267        mapping.addGlobal( 'seg_kernel_code', kernel_code_vbase, kernel_code_size,
268                           'CXW_', vtype = 'ELF', x = 0 , y = 0 , pseg = 'RAM',
[766]269                           binpath = 'build/kernel/kernel.elf', local = False )
[747]270
271        mapping.addGlobal( 'seg_kernel_init', kernel_init_vbase, kernel_init_size,
272                           'CXW_', vtype = 'ELF', x = 0 , y = 0 , pseg = 'RAM',
[766]273                           binpath = 'build/kernel/kernel.elf', local = False )
[747]274
[766]275    ### shared global vsegs for kernel
[747]276
[766]277    mapping.addGlobal( 'seg_kernel_data', kernel_data_vbase, kernel_data_size,
278                       'C_W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
279                       binpath = 'build/kernel/kernel.elf', local = False )
[747]280
[766]281    mapping.addGlobal( 'seg_kernel_uncdata', kernel_uncdata_vbase, kernel_uncdata_size,
282                       '__W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
283                       binpath = 'build/kernel/kernel.elf', local = False )
284
[747]285    ### global vsegs for external peripherals / identity mapping
286
[748]287    mapping.addGlobal( 'seg_iob', iob_base, iob_size, '__W_',
[766]288                       vtype = 'PERI', x = 0, y = 0, pseg = 'IOB',
289                       identity = True )
[747]290
[748]291    mapping.addGlobal( 'seg_bdv', bdv_base, bdv_size, '__W_',
[766]292                       vtype = 'PERI', x = 0, y = 0, pseg = 'BDV',
293                       identity = True )
[747]294
[748]295    mapping.addGlobal( 'seg_tty', tty_base, tty_size, '__W_',
[766]296                       vtype = 'PERI', x = 0, y = 0, pseg = 'TTY',
297                       identity = True )
[747]298
[748]299    mapping.addGlobal( 'seg_nic', nic_base, nic_size, '__W_',
[766]300                       vtype = 'PERI', x = 0, y = 0, pseg = 'NIC',
301                       identity = True )
[747]302
[748]303    mapping.addGlobal( 'seg_cma', cma_base, cma_size, '__W_',
[766]304                       vtype = 'PERI', x = 0, y = 0, pseg = 'CMA',
305                       identity = True )
[747]306
[748]307    mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size, '__W_',
[766]308                       vtype = 'PERI', x = 0, y = 0, pseg = 'FBF',
309                       identity = True )
[747]310
[748]311    mapping.addGlobal( 'seg_pic', pic_base, pic_size, '__W_',
[766]312                       vtype = 'PERI', x = 0, y = 0, pseg = 'PIC',
313                       identity = True )
[747]314
[769]315    mapping.addGlobal( 'seg_sim', sim_base, sim_size, '__W_',
316                       vtype = 'PERI', x = 0, y = 0, pseg = 'SIM',
317                       identity = True )
[766]318
[748]319    ### global vsegs for internal peripherals, and for schedulers
[747]320    ### name is indexed by (x,y) / vbase address is incremented by (cluster_xy * peri_increment)
321
322    for x in xrange( x_size ):
323        for y in xrange( y_size ):
324            cluster_xy = (x << y_width) + y;
325            offset     = cluster_xy * peri_increment
326
[748]327            mapping.addGlobal( 'seg_rom_%d_%d' %(x,y), rom_base + offset, rom_size,
328                               'CX__', vtype = 'PERI' , x = x , y = y , pseg = 'ROM' )
329
[747]330            mapping.addGlobal( 'seg_xcu_%d_%d' %(x,y), xcu_base + offset, xcu_size,
331                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'XCU' )
332
333            mapping.addGlobal( 'seg_dma_%d_%d' %(x,y), dma_base + offset, dma_size,
334                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'DMA' )
335
336            mapping.addGlobal( 'seg_mmc_%d_%d' %(x,y), mmc_base + offset, mmc_size,
337                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'MMC' )
338
339            mapping.addGlobal( 'seg_sched_%d_%d' %(x,y), kernel_sched_vbase + offset, kernel_sched_size,
340                               'C_W_', vtype = 'SCHED', x = x , y = y , pseg = 'RAM' )
341
342    ### return mapping ###
343
344    return mapping
345
[774]346def main(x, y, p, hard_path, xml_path):
347    mapping = arch( x_size    = x,
348                    y_size    = y,
349                    nb_procs  = p)
350
351    with open(xml_path, "w") as map_xml:
352        map_xml.write(mapping.xml())
353    with open(hard_path, "w") as hard_config:
354        hard_config.write(mapping.hard_config())
355
[747]356################################# platform test #######################################################
357
358if __name__ == '__main__':
[774]359    main( x_size    = int(sys.argv[1]),
360          y_size    = int(sys.argv[2]),
361          nb_procs  = int(sys.argv[3]))
[747]362
363# Local Variables:
364# tab-width: 4;
365# c-basic-offset: 4;
366# c-file-offsets:((innamespace . 0)(inline-open . 0));
367# indent-tabs-mode: nil;
368# End:
369#
370# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
371
Note: See TracBrowser for help on using the repository browser.