source: trunk/platforms/tsar_generic_iob/non_distributed_arch.py @ 1025

Last change on this file since 1025 was 802, checked in by cfuguet, 10 years ago

tsar_generic_iob: Using the new P_WIDTH constant from hard_config.h

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