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

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

reconf: merge modifications from the trunk/tsar_generic_iob (r874)

r874 commit message:
Introducing support for multiple TTY terminals (up to 16 channels)
in the tsar_generic_iob platform.

  • Property svn:executable set to *
File size: 14.9 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
76    assert nb_procs <= 4
[747]77
[831]78    assert ((x_size == 1) or (x_size == 2) or (x_size == 4) or (x_size == 8) or
79            (x_size == 16))
[747]80
[831]81    assert ((y_size == 1) or (y_size == 2) or (y_size == 4) or (y_size == 8) or
82            (y_size == 16))
[747]83
[875]84    assert ((nb_ttys >= 1) and (nb_ttys <= 16))
[748]85
[831]86    assert (((X_IO == 0) and (Y_IO == 0)) or
87            ((X_IO == x_size-1) and (Y_IO == y_size-1)))
[747]88
[831]89    platform_name = 'reconf-tsar_iob_%d_%d_%d' % (x_size, y_size, nb_procs)
[747]90
[831]91    # define physical segments
92    ram_base = 0x0000000000
93    if 1:
94        ram_size = 0x4000000              # 64 Mbytes
95    else:
96        ram_size = 0x0040000              # 256 Kbytes
[747]97
[831]98    xcu_base = 0x00B0000000
99    xcu_size = 0x1000                     # 4 Kbytes
[747]100
[831]101    dma_base = 0x00B1000000
102    dma_size = 0x1000 * nb_procs          # 4 Kbytes * nb_procs
[747]103
[831]104    mmc_base = 0x00B2000000
105    mmc_size = 0x1000                     # 4 Kbytes
[748]106
[831]107    rom_base = 0x00BFC00000
108    rom_size = 0x8000                     # 32 Kbytes
[747]109
[831]110    offset_io = pmsb(X_IO, Y_IO) << (PADDR_WIDTH - X_WIDTH - Y_WIDTH)
[747]111
[831]112    bdv_base = 0x00B3000000 + offset_io
113    bdv_size = 0x1000                     # 4 kbytes
[747]114
[831]115    tty_base = 0x00B4000000 + offset_io
116    tty_size = 0x1000                     # 4 Kbytes
[747]117
[831]118    nic_base = 0x00B5000000 + offset_io
119    nic_size = 0x80000                    # 512 kbytes
[747]120
[831]121    cma_base = 0x00B6000000 + offset_io
122    cma_size = 0x1000 * 2 * NB_NICS       # 4 kbytes * 2 * NB_NICS
[747]123
[831]124    fbf_base = 0x00B7000000 + offset_io
125    fbf_size = fbf_width * fbf_width      # fbf_width * fbf_width bytes
[747]126
[831]127    pic_base = 0x00B8000000 + offset_io
128    pic_size = 0x1000                     # 4 Kbytes
[769]129
[831]130    sim_base = 0x00B9000000 + offset_io
131    sim_size = 0x1000                     # 4 kbytes
[747]132
[831]133    iob_base = 0x00BE000000 + offset_io
134    iob_size = 0x1000                     # 4 kbytes
[747]135
[831]136    # create mapping
137    mapping = Mapping(name=platform_name,
138                      x_size=x_size,
139                      y_size=y_size,
140                      nprocs=nb_procs,
141                      x_width=X_WIDTH,
142                      y_width=Y_WIDTH,
[858]143                      p_width=P_WIDTH,
[831]144                      paddr_width=PADDR_WIDTH,
145                      coherence=True,
146                      irq_per_proc=IRQ_PER_PROC,
147                      use_ramdisk=USE_RAMDISK,
148                      x_io=X_IO,
149                      y_io=Y_IO,
150                      peri_increment=PERI_INCREMENT,
151                      ram_base=ram_base,
152                      ram_size=ram_size)
[747]153
[831]154    # external peripherals (accessible in cluster[0,0] only for this mapping)
155    mapping.addPeriph('IOB', base=iob_base, size=iob_size,
156                      ptype='IOB')
[748]157
[831]158    mapping.addPeriph('BDV', base=bdv_base, size=bdv_size,
159                      ptype='IOC', subtype='BDV')
[747]160
[831]161    mapping.addPeriph('TTY', base=tty_base, size=tty_size,
[875]162                      ptype='TTY', channels=nb_ttys)
[747]163
[831]164    mapping.addPeriph('NIC', base=nic_base, size=nic_size,
165                      ptype='NIC', channels=NB_NICS)
[747]166
[831]167    mapping.addPeriph('CMA', base=cma_base, size=cma_size,
168                      ptype='CMA', channels=2*NB_NICS)
[747]169
[831]170    mapping.addPeriph('FBF', base=fbf_base, size=fbf_size,
171                      ptype='FBF', arg=fbf_width)
[747]172
[831]173    mapping.addPeriph('SIM', base=sim_base, size=sim_size,
174                      ptype='SIM')
[747]175
[831]176    pic = mapping.addPeriph('PIC', base=pic_base, size=pic_size,
177                            ptype='PIC', channels=32)
[747]178
[831]179    mapping.addIrq(pic, index=0, isrtype='ISR_NIC_RX', channel=0)
180    mapping.addIrq(pic, index=1, isrtype='ISR_NIC_RX', channel=1)
181    mapping.addIrq(pic, index=2, isrtype='ISR_NIC_TX', channel=0)
182    mapping.addIrq(pic, index=3, isrtype='ISR_NIC_TX', channel=1)
183    mapping.addIrq(pic, index=4, isrtype='ISR_CMA', channel=0)
184    mapping.addIrq(pic, index=5, isrtype='ISR_CMA', channel=1)
185    mapping.addIrq(pic, index=6, isrtype='ISR_CMA', channel=2)
186    mapping.addIrq(pic, index=7, isrtype='ISR_CMA', channel=3)
187    mapping.addIrq(pic, index=8, isrtype='ISR_BDV', channel=0)
[747]188
[875]189    for i in xrange(nb_ttys):
190        mapping.addIrq(pic, index=16+i, isrtype='ISR_TTY_RX', channel=i)
191
[831]192    # hardware components replicated in all clusters
193    for x in xrange(x_size):
194        for y in xrange(y_size):
195            offset = pmsb(x, y) << (PADDR_WIDTH - X_WIDTH - Y_WIDTH)
[747]196
[831]197            mapping.addRam('RAM', base=ram_base + offset, size=ram_size)
[747]198
[831]199            mapping.addPeriph('MMC', base=mmc_base + offset, size=mmc_size,
200                              ptype='MMC')
[747]201
[831]202            mapping.addPeriph('ROM', base=rom_base + offset, size=rom_size,
203                              ptype='ROM')
[747]204
[831]205            dma = mapping.addPeriph('DMA', base=dma_base + offset,
206                                    size=dma_size, ptype='DMA',
207                                    channels=nb_procs)
[747]208
[831]209            xcu = mapping.addPeriph('XCU', base=xcu_base + offset,
210                                    size=xcu_size, ptype='XCU',
211                                    channels=nb_procs * IRQ_PER_PROC,
212                                    arg=16)
[747]213
[831]214            # MMC IRQ replicated in all clusters
215            mapping.addIrq(xcu, index=0, isrtype='ISR_MMC')
[747]216
[831]217            # DMA IRQ replicated in all clusters
218            for i in xrange(dma.channels):
219                mapping.addIrq(xcu, index=1+i, isrtype='ISR_DMA',
220                               channel=i)
[747]221
[831]222            # processors
223            for p in xrange(nb_procs):
224                mapping.addProc(x, y, p)
[747]225
[831]226    ############################################################################
227    # GIET_VM specifics
[747]228
[831]229    # define bootloader vsegs base addresses
230    bmapping_vbase = 0x00001000           # ident
231    bmapping_size = 0x0007F000            # 508 Kbytes
[769]232
[831]233    bcode_vbase = 0x00080000              # ident
234    bcode_size = 0x00040000               # 256 Kbytes
[747]235
[831]236    bdata_vbase = 0x000C0000              # ident
237    bdata_size = 0x00080000               # 512 Kbytes
[747]238
[831]239    bstack_vbase = 0x00140000             # ident
240    bstack_size = 0x00050000              # 320 Kbytes
[747]241
[831]242    # define kernel vsegs base addresses and sizes
243    kcode_vbase = 0x80000000
244    kcode_size = 0x00080000               # 512 Kbytes
[747]245
[831]246    kinit_vbase = 0x80800000
247    kinit_size = 0x00080000               # 512 Kbytes
[747]248
[831]249    kdata_vbase = 0x80100000
250    kdata_size = 0x00080000               # 512 Kbytes
[747]251
[831]252    kuncdata_vbase = 0x80180000
253    kuncdata_size = 0x00001000            # 4 Kbytes
[747]254
[831]255    kptab_vbase = 0xC0000000
256    kptab_size = 0x00200000               # 512 Kbytes
[747]257
[831]258    ksched_vbase = 0xF0000000             # distributed in all clusters
259    ksched_size = 0x2000 * nb_procs       # 8 kbytes per processor
[747]260
[831]261    # global vsegs for boot_loader / identity mapping
262    mapping.addGlobal('seg_boot_mapping', bmapping_vbase, bmapping_size,
263                      'CXW_', vtype='BLOB', x=0, y=0, pseg='RAM',
264                      identity=True, local=False, big=True)
[747]265
[831]266    mapping.addGlobal('seg_boot_code', bcode_vbase, bcode_size,
267                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
268                      identity=True, local=False, big=True)
[747]269
[831]270    mapping.addGlobal('seg_boot_data', bdata_vbase, bdata_size,
271                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
272                      identity=True, local=False, big=True)
[748]273
[831]274    mapping.addGlobal('seg_boot_stack', bstack_vbase, bstack_size,
275                      'CXW_', vtype='BUFFER', x=0, y=0, pseg='RAM',
276                      identity=True, local=False, big=True)
[747]277
[831]278    # the code global vsegs for kernel can be replicated in all clusters
279    # if the page tables are distributed in all clusters.
280    for x in xrange(x_size):
281        for y in xrange(y_size):
282            mapping.addGlobal('seg_kernel_code', kcode_vbase, kcode_size,
283                              'CXW_', vtype='ELF', x=x, y=y, pseg='RAM',
284                              binpath='build/kernel/kernel.elf',
285                              local=True, big=True)
[770]286
[831]287            mapping.addGlobal('seg_kernel_init', kinit_vbase, kinit_size,
288                              'CXW_', vtype='ELF', x=x, y=y, pseg='RAM',
289                              binpath='build/kernel/kernel.elf',
290                              local=True, big=True)
[747]291
[831]292            offset = pmsb(x, y) * PTAB_INCREMENT
293            mapping.addGlobal('seg_kernel_ptab_%d_%d' % (x, y),
294                              kptab_vbase + offset, kptab_size, 'C_W_',
295                              vtype='PTAB', x=x, y=y, pseg='RAM',
296                              local=False, big=True)
[747]297
298
[831]299            offset = pmsb(x, y) * SCHED_INCREMENT
300            mapping.addGlobal('seg_kernel_sched_%d_%d' % (x, y),
301                              ksched_vbase + offset, ksched_size, 'C_W_',
302                              vtype='SCHED', x=x, y=y, pseg='RAM',
303                              local=False, big=False)
[747]304
[831]305    # shared global vsegs for kernel
306    mapping.addGlobal('seg_kernel_data', kdata_vbase, kdata_size,
307                      'CXW_', vtype='ELF', x=0, y=0, pseg='RAM',
308                      binpath='build/kernel/kernel.elf', local=False,
309                      big=True)
[747]310
[831]311    mapping.addGlobal('seg_kernel_uncdata', kuncdata_vbase, kuncdata_size,
312                      'CXW_', vtype='ELF', x=0, y=0, pseg='RAM',
313                      binpath='build/kernel/kernel.elf', local=False,
314                      big=True)
[747]315
[831]316    # global vsegs for external peripherals / identity mapping
317    mapping.addGlobal('seg_iob', iob_base, iob_size, '__W_', vtype='PERI',
318                      x=X_IO, y=Y_IO, pseg='IOB', local=False, big=False)
[747]319
[831]320    mapping.addGlobal('seg_bdv', bdv_base, bdv_size, '__W_', vtype='PERI',
321                      x=X_IO, y=Y_IO, pseg='BDV', local=False, big=False)
[747]322
[831]323    mapping.addGlobal('seg_tty', tty_base, tty_size, '__W_', vtype='PERI',
324                      x=X_IO, y=Y_IO, pseg='TTY', local=False, big=False)
[747]325
[831]326    mapping.addGlobal('seg_nic', nic_base, nic_size, '__W_', vtype='PERI',
327                      x=X_IO, y=Y_IO, pseg='NIC', local=False, big=False)
[747]328
[831]329    mapping.addGlobal('seg_cma', cma_base, cma_size, '__W_', vtype='PERI',
330                      x=X_IO, y=Y_IO, pseg='CMA', local=False, big=False)
[747]331
[831]332    mapping.addGlobal('seg_fbf', fbf_base, fbf_size, '__W_', vtype='PERI',
333                      x=X_IO, y=Y_IO, pseg='FBF', local=False, big=True)
[747]334
[831]335    mapping.addGlobal('seg_pic', pic_base, pic_size, '__W_', vtype='PERI',
336                      x=X_IO, y=Y_IO, pseg='PIC', local=False, big=False)
[747]337
[831]338    mapping.addGlobal('seg_sim', sim_base, sim_size, '__W_', vtype='PERI',
339                      x=X_IO, y=Y_IO, pseg='SIM', local=False, big=False)
[766]340
[831]341    # global vsegs for internal peripherals
342    for x in xrange(x_size):
343        for y in xrange(y_size):
344            offset = pmsb(x, y) * PERI_INCREMENT
[747]345
[831]346            mapping.addGlobal('seg_rom_%d_%d' % (x, y), rom_base + offset,
347                              rom_size, 'CX__', vtype='PERI', x=x, y=y,
348                              pseg='ROM', local=False, big=False)
[747]349
[831]350            mapping.addGlobal('seg_xcu_%d_%d' % (x, y), xcu_base + offset,
351                              xcu_size, '__W_', vtype='PERI', x=x, y=y,
352                              pseg='XCU', local=False, big=False)
[747]353
[831]354            mapping.addGlobal('seg_dma_%d_%d' % (x, y), dma_base + offset,
355                              dma_size, '__W_', vtype='PERI', x=x, y=y,
356                              pseg='DMA', local=False, big=False)
[747]357
[831]358            mapping.addGlobal('seg_mmc_%d_%d' % (x, y), mmc_base + offset,
359                              mmc_size, '__W_', vtype='PERI', x=x, y=y,
360                              pseg='MMC', local=False, big=False)
[747]361
362    return mapping
363
[774]364def main(x, y, p, hard_path, xml_path):
[831]365    """main function: it generates the map.xml and the hard_config.h file based
366    on the Mapping object returned by arch()"""
367    mapping = arch(x_size=x,
368                   y_size=y,
369                   nb_procs=p)
[774]370
371    with open(xml_path, "w") as map_xml:
372        map_xml.write(mapping.xml())
373    with open(hard_path, "w") as hard_config:
374        hard_config.write(mapping.hard_config())
375
[831]376################################# platform test ################################
[806]377import sys
[747]378if __name__ == '__main__':
[831]379    main(x=int(sys.argv[1]),
380         y=int(sys.argv[2]),
381         p=int(sys.argv[3]),
382         hard_path="hard_config.test.h",
383         xml_path="map.test.xml")
[747]384
385# Local Variables:
386# tab-width: 4;
387# c-basic-offset: 4;
388# c-file-offsets:((innamespace . 0)(inline-open . 0));
389# indent-tabs-mode: nil;
390# End:
391#
392# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
393
Note: See TracBrowser for help on using the repository browser.