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

Last change on this file since 940 was 927, checked in by cfuguet, 9 years ago

reconf: improve test scripts for tsar_generic_iob platform

  • Now it is possible to pass the number of OpenMP threads as a parameter
  • Property svn:executable set to *
File size: 15.0 KB
RevLine 
[747]1#!/usr/bin/env python
[831]2"""This file contains a mapping generator for the tsar_generic_iob platform"""
3
[806]4from math import log
[831]5from mapping import Mapping
[747]6
[831]7################################################################################
[747]8#   file   : arch.py  (for the tsar_generic_iob architecture)
9#   date   : may 2014
10#   author : Alain Greiner
11#
[831]12#   modified by:
13#       Cesar Fuguet
14#           - Adding distributed ROMs used by the distributed reconfiguration
15#             procedure
16#
17################################################################################
18#  This platform includes 6 external peripherals, accessible through two
19#  IO_Bridge components located in cluster [0,0] and cluster [x_size-1,
20#  y_size-1]. Available peripherals are: TTY, BDV, FBF, ROM, NIC, CMA.
21#
[747]22#  The "constructor" parameters are:
23#  - x_size         : number of clusters in a row
24#  - y_size         : number of clusters in a column
25#  - nb_procs       : number of processors per cluster
[875]26#  - nb_ttys        : number of TTY channels
[831]27#  - fbf_width      : frame_buffer width = frame_buffer heigth
[747]28#
[766]29#  The "hidden" parameters (defined below) are:
[831]30#  - NB_NICS        : number of NIC channels
31#  - X_IO           : cluster_io x coordinate
32#  - Y_IO           : cluster_io y coordinate
33#  - X_WIDTH        : number of bits for x coordinate
34#  - Y_WIDTH        : number of bits for y coordinate
[858]35#  - P_WIDTH        : number of bits for processor local id field
[831]36#  - PADDR_WIDTH    : number of bits for physical address
37#  - IRQ_PER_PROC   : number of input IRQs per processor
38#  - USE_RAMDISK    : use a ramdisk when True
39#  - PERI_INCREMENT : virtual address increment for replicated peripherals
40#  - PTAB_INCREMENT : virtual address increment for replicated page tables
41#  - SCHED_INCREMENT: virtual address increment for replicated schedulers
42################################################################################
[747]43
[831]44# define architecture constants
45PADDR_WIDTH = 40
46NB_NICS = 2
47FBF_WIDTH = 128
48X_WIDTH = 4
49Y_WIDTH = 4
[858]50P_WIDTH = 2
[831]51X_IO = 0
52Y_IO = 0
53IRQ_PER_PROC = 4
54USE_RAMDISK = False
[747]55
[831]56# virtual address increment for distributed memory segments in the GietVM OS
57PERI_INCREMENT = 0x10000
58PTAB_INCREMENT = 0x200000
59SCHED_INCREMENT = 0x10000
[747]60
[831]61def pmsb(x, y):
62    """This function returns the physical most signicant bits for the
63    cluster(x,y)"""
[748]64
[831]65    return (x << X_WIDTH) | y
[747]66
[831]67def arch(x_size=2,
68         y_size=2,
69         nb_procs=4,
[875]70         nb_ttys=1,
[831]71         fbf_width=FBF_WIDTH):
72    """This function describes the tsar_generic_iob platform and defines its
73    parameters"""
[747]74
[831]75    # parameters checking
[876]76    assert (nb_procs <= (1 << P_WIDTH))
[747]77
[876]78    assert ((x_size >= 1) and (x_size <= (1 << X_WIDTH)))
[747]79
[876]80    assert ((y_size >= 1) and (y_size <= (1 << Y_WIDTH)))
[747]81
[875]82    assert ((nb_ttys >= 1) and (nb_ttys <= 16))
[748]83
[831]84    assert (((X_IO == 0) and (Y_IO == 0)) or
[876]85            ((X_IO == (x_size - 1)) and (Y_IO == (y_size - 1))))
[747]86
[831]87    platform_name = 'reconf-tsar_iob_%d_%d_%d' % (x_size, y_size, nb_procs)
[747]88
[831]89    # define physical segments
90    ram_base = 0x0000000000
[927]91    ram_size = 0x10000000 / (x_size * y_size)
[747]92
[831]93    xcu_base = 0x00B0000000
94    xcu_size = 0x1000                     # 4 Kbytes
[747]95
[831]96    dma_base = 0x00B1000000
97    dma_size = 0x1000 * nb_procs          # 4 Kbytes * nb_procs
[747]98
[831]99    mmc_base = 0x00B2000000
100    mmc_size = 0x1000                     # 4 Kbytes
[748]101
[926]102    drom_base = 0x00BFC00000
103    drom_size = 0x8000                    # 32 Kbytes
[747]104
[831]105    offset_io = pmsb(X_IO, Y_IO) << (PADDR_WIDTH - X_WIDTH - Y_WIDTH)
[747]106
[831]107    bdv_base = 0x00B3000000 + offset_io
108    bdv_size = 0x1000                     # 4 kbytes
[747]109
[831]110    tty_base = 0x00B4000000 + offset_io
111    tty_size = 0x1000                     # 4 Kbytes
[747]112
[831]113    nic_base = 0x00B5000000 + offset_io
114    nic_size = 0x80000                    # 512 kbytes
[747]115
[831]116    cma_base = 0x00B6000000 + offset_io
117    cma_size = 0x1000 * 2 * NB_NICS       # 4 kbytes * 2 * NB_NICS
[747]118
[831]119    fbf_base = 0x00B7000000 + offset_io
120    fbf_size = fbf_width * fbf_width      # fbf_width * fbf_width bytes
[747]121
[831]122    pic_base = 0x00B8000000 + offset_io
123    pic_size = 0x1000                     # 4 Kbytes
[769]124
[831]125    sim_base = 0x00B9000000 + offset_io
126    sim_size = 0x1000                     # 4 kbytes
[747]127
[831]128    iob_base = 0x00BE000000 + offset_io
129    iob_size = 0x1000                     # 4 kbytes
[747]130
[926]131    rom_base = 0x00BA000000
132    rom_size = 0x8000                     # 32 Kbytes
133
[831]134    # create mapping
135    mapping = Mapping(name=platform_name,
136                      x_size=x_size,
137                      y_size=y_size,
138                      nprocs=nb_procs,
139                      x_width=X_WIDTH,
140                      y_width=Y_WIDTH,
[858]141                      p_width=P_WIDTH,
[831]142                      paddr_width=PADDR_WIDTH,
143                      coherence=True,
144                      irq_per_proc=IRQ_PER_PROC,
145                      use_ramdisk=USE_RAMDISK,
146                      x_io=X_IO,
147                      y_io=Y_IO,
148                      peri_increment=PERI_INCREMENT,
149                      ram_base=ram_base,
150                      ram_size=ram_size)
[747]151
[831]152    # external peripherals (accessible in cluster[0,0] only for this mapping)
153    mapping.addPeriph('IOB', base=iob_base, size=iob_size,
154                      ptype='IOB')
[748]155
[831]156    mapping.addPeriph('BDV', base=bdv_base, size=bdv_size,
157                      ptype='IOC', subtype='BDV')
[747]158
[831]159    mapping.addPeriph('TTY', base=tty_base, size=tty_size,
[875]160                      ptype='TTY', channels=nb_ttys)
[747]161
[831]162    mapping.addPeriph('NIC', base=nic_base, size=nic_size,
163                      ptype='NIC', channels=NB_NICS)
[747]164
[831]165    mapping.addPeriph('CMA', base=cma_base, size=cma_size,
166                      ptype='CMA', channels=2*NB_NICS)
[747]167
[831]168    mapping.addPeriph('FBF', base=fbf_base, size=fbf_size,
169                      ptype='FBF', arg=fbf_width)
[747]170
[831]171    mapping.addPeriph('SIM', base=sim_base, size=sim_size,
172                      ptype='SIM')
[747]173
[926]174    mapping.addPeriph('ROM', base=rom_base, size=rom_size,
175                      ptype='ROM')
176
[831]177    pic = mapping.addPeriph('PIC', base=pic_base, size=pic_size,
178                            ptype='PIC', channels=32)
[747]179
[831]180    mapping.addIrq(pic, index=0, isrtype='ISR_NIC_RX', channel=0)
181    mapping.addIrq(pic, index=1, isrtype='ISR_NIC_RX', channel=1)
182    mapping.addIrq(pic, index=2, isrtype='ISR_NIC_TX', channel=0)
183    mapping.addIrq(pic, index=3, isrtype='ISR_NIC_TX', channel=1)
184    mapping.addIrq(pic, index=4, isrtype='ISR_CMA', channel=0)
185    mapping.addIrq(pic, index=5, isrtype='ISR_CMA', channel=1)
186    mapping.addIrq(pic, index=6, isrtype='ISR_CMA', channel=2)
187    mapping.addIrq(pic, index=7, isrtype='ISR_CMA', channel=3)
188    mapping.addIrq(pic, index=8, isrtype='ISR_BDV', channel=0)
[747]189
[875]190    for i in xrange(nb_ttys):
191        mapping.addIrq(pic, index=16+i, isrtype='ISR_TTY_RX', channel=i)
192
[831]193    # hardware components replicated in all clusters
194    for x in xrange(x_size):
195        for y in xrange(y_size):
196            offset = pmsb(x, y) << (PADDR_WIDTH - X_WIDTH - Y_WIDTH)
[747]197
[831]198            mapping.addRam('RAM', base=ram_base + offset, size=ram_size)
[747]199
[831]200            mapping.addPeriph('MMC', base=mmc_base + offset, size=mmc_size,
201                              ptype='MMC')
[747]202
[926]203            mapping.addPeriph('DROM', base=drom_base + offset, size=drom_size,
204                              ptype='DROM')
[747]205
[831]206            dma = mapping.addPeriph('DMA', base=dma_base + offset,
207                                    size=dma_size, ptype='DMA',
208                                    channels=nb_procs)
[747]209
[831]210            xcu = mapping.addPeriph('XCU', base=xcu_base + offset,
211                                    size=xcu_size, ptype='XCU',
212                                    channels=nb_procs * IRQ_PER_PROC,
213                                    arg=16)
[747]214
[831]215            # MMC IRQ replicated in all clusters
216            mapping.addIrq(xcu, index=0, isrtype='ISR_MMC')
[747]217
[831]218            # DMA IRQ replicated in all clusters
219            for i in xrange(dma.channels):
220                mapping.addIrq(xcu, index=1+i, isrtype='ISR_DMA',
221                               channel=i)
[747]222
[831]223            # processors
224            for p in xrange(nb_procs):
225                mapping.addProc(x, y, p)
[747]226
[831]227    ############################################################################
228    # GIET_VM specifics
[747]229
[831]230    # define bootloader vsegs base addresses
231    bmapping_vbase = 0x00001000           # ident
232    bmapping_size = 0x0007F000            # 508 Kbytes
[769]233
[831]234    bcode_vbase = 0x00080000              # ident
235    bcode_size = 0x00040000               # 256 Kbytes
[747]236
[831]237    bdata_vbase = 0x000C0000              # ident
238    bdata_size = 0x00080000               # 512 Kbytes
[747]239
[831]240    bstack_vbase = 0x00140000             # ident
241    bstack_size = 0x00050000              # 320 Kbytes
[747]242
[831]243    # define kernel vsegs base addresses and sizes
244    kcode_vbase = 0x80000000
245    kcode_size = 0x00080000               # 512 Kbytes
[747]246
[900]247    kdata_vbase = 0x80100000
248    kdata_size = 0x00080000               # 512 Kbytes
249
[831]250    kinit_vbase = 0x80800000
251    kinit_size = 0x00080000               # 512 Kbytes
[747]252
[831]253    kuncdata_vbase = 0x80180000
254    kuncdata_size = 0x00001000            # 4 Kbytes
[747]255
[831]256    kptab_vbase = 0xC0000000
257    kptab_size = 0x00200000               # 512 Kbytes
[747]258
[831]259    ksched_vbase = 0xF0000000             # distributed in all clusters
260    ksched_size = 0x2000 * nb_procs       # 8 kbytes per processor
[747]261
[831]262    # global vsegs for boot_loader / identity mapping
263    mapping.addGlobal('seg_boot_mapping', bmapping_vbase, bmapping_size,
264                      'CXW_', vtype='BLOB', x=0, y=0, pseg='RAM',
265                      identity=True, local=False, big=True)
[747]266
[831]267    mapping.addGlobal('seg_boot_code', bcode_vbase, bcode_size,
268                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
269                      identity=True, local=False, big=True)
[747]270
[831]271    mapping.addGlobal('seg_boot_data', bdata_vbase, bdata_size,
272                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
273                      identity=True, local=False, big=True)
[748]274
[831]275    mapping.addGlobal('seg_boot_stack', bstack_vbase, bstack_size,
276                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
277                      identity=True, local=False, big=True)
[747]278
[831]279    # the code global vsegs for kernel can be replicated in all clusters
280    # if the page tables are distributed in all clusters.
281    for x in xrange(x_size):
282        for y in xrange(y_size):
283            mapping.addGlobal('seg_kernel_code', kcode_vbase, kcode_size,
284                              'CXW_', vtype='ELF', x=x, y=y, pseg='RAM',
285                              binpath='build/kernel/kernel.elf',
286                              local=True, big=True)
[770]287
[831]288            mapping.addGlobal('seg_kernel_init', kinit_vbase, kinit_size,
289                              'CXW_', vtype='ELF', x=x, y=y, pseg='RAM',
290                              binpath='build/kernel/kernel.elf',
291                              local=True, big=True)
[747]292
[831]293            offset = pmsb(x, y) * PTAB_INCREMENT
294            mapping.addGlobal('seg_kernel_ptab_%d_%d' % (x, y),
295                              kptab_vbase + offset, kptab_size, 'C_W_',
296                              vtype='PTAB', x=x, y=y, pseg='RAM',
297                              local=False, big=True)
[747]298
299
[831]300            offset = pmsb(x, y) * SCHED_INCREMENT
301            mapping.addGlobal('seg_kernel_sched_%d_%d' % (x, y),
302                              ksched_vbase + offset, ksched_size, 'C_W_',
303                              vtype='SCHED', x=x, y=y, pseg='RAM',
304                              local=False, big=False)
[747]305
[831]306    # shared global vsegs for kernel
307    mapping.addGlobal('seg_kernel_data', kdata_vbase, kdata_size,
308                      'CXW_', vtype='ELF', x=0, y=0, pseg='RAM',
309                      binpath='build/kernel/kernel.elf', local=False,
310                      big=True)
[747]311
[831]312    mapping.addGlobal('seg_kernel_uncdata', kuncdata_vbase, kuncdata_size,
313                      'CXW_', vtype='ELF', x=0, y=0, pseg='RAM',
314                      binpath='build/kernel/kernel.elf', local=False,
315                      big=True)
[747]316
[831]317    # global vsegs for external peripherals / identity mapping
318    mapping.addGlobal('seg_iob', iob_base, iob_size, '__W_', vtype='PERI',
319                      x=X_IO, y=Y_IO, pseg='IOB', local=False, big=False)
[747]320
[831]321    mapping.addGlobal('seg_bdv', bdv_base, bdv_size, '__W_', vtype='PERI',
322                      x=X_IO, y=Y_IO, pseg='BDV', local=False, big=False)
[747]323
[831]324    mapping.addGlobal('seg_tty', tty_base, tty_size, '__W_', vtype='PERI',
325                      x=X_IO, y=Y_IO, pseg='TTY', local=False, big=False)
[747]326
[831]327    mapping.addGlobal('seg_nic', nic_base, nic_size, '__W_', vtype='PERI',
328                      x=X_IO, y=Y_IO, pseg='NIC', local=False, big=False)
[747]329
[831]330    mapping.addGlobal('seg_cma', cma_base, cma_size, '__W_', vtype='PERI',
331                      x=X_IO, y=Y_IO, pseg='CMA', local=False, big=False)
[747]332
[831]333    mapping.addGlobal('seg_fbf', fbf_base, fbf_size, '__W_', vtype='PERI',
334                      x=X_IO, y=Y_IO, pseg='FBF', local=False, big=True)
[747]335
[831]336    mapping.addGlobal('seg_pic', pic_base, pic_size, '__W_', vtype='PERI',
337                      x=X_IO, y=Y_IO, pseg='PIC', local=False, big=False)
[747]338
[831]339    mapping.addGlobal('seg_sim', sim_base, sim_size, '__W_', vtype='PERI',
340                      x=X_IO, y=Y_IO, pseg='SIM', local=False, big=False)
[766]341
[893]342    # for the Giet-VM is not necessary to map the replicated ROMs
[926]343    mapping.addGlobal('seg_rom', drom_base, drom_size, 'CX__', vtype='PERI',
[893]344                      x=X_IO, y=Y_IO, pseg='ROM', local=False, big=True)
345
[831]346    # global vsegs for internal peripherals
347    for x in xrange(x_size):
348        for y in xrange(y_size):
349            offset = pmsb(x, y) * PERI_INCREMENT
[747]350
[831]351            mapping.addGlobal('seg_xcu_%d_%d' % (x, y), xcu_base + offset,
352                              xcu_size, '__W_', vtype='PERI', x=x, y=y,
353                              pseg='XCU', local=False, big=False)
[747]354
[831]355            mapping.addGlobal('seg_dma_%d_%d' % (x, y), dma_base + offset,
356                              dma_size, '__W_', vtype='PERI', x=x, y=y,
357                              pseg='DMA', local=False, big=False)
[747]358
[831]359            mapping.addGlobal('seg_mmc_%d_%d' % (x, y), mmc_base + offset,
360                              mmc_size, '__W_', vtype='PERI', x=x, y=y,
361                              pseg='MMC', local=False, big=False)
[747]362
363    return mapping
364
[907]365def main(x, y, p, hard_path, xml_path, dts_path):
[831]366    """main function: it generates the map.xml and the hard_config.h file based
367    on the Mapping object returned by arch()"""
368    mapping = arch(x_size=x,
369                   y_size=y,
370                   nb_procs=p)
[774]371
372    with open(xml_path, "w") as map_xml:
373        map_xml.write(mapping.xml())
374    with open(hard_path, "w") as hard_config:
375        hard_config.write(mapping.hard_config())
[907]376    with open(dts_path, "w") as linux_dts:
377        linux_dts.write(mapping.linux_dts())
[774]378
[831]379################################# platform test ################################
[806]380import sys
[747]381if __name__ == '__main__':
[831]382    main(x=int(sys.argv[1]),
383         y=int(sys.argv[2]),
384         p=int(sys.argv[3]),
385         hard_path="hard_config.test.h",
[907]386         xml_path="map.test.xml",
387         dts_path="linux.dts")
[747]388
389# Local Variables:
390# tab-width: 4;
391# c-basic-offset: 4;
392# c-file-offsets:((innamespace . 0)(inline-open . 0));
393# indent-tabs-mode: nil;
394# End:
395#
396# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
397
Note: See TracBrowser for help on using the repository browser.