source: trunk/platforms/tsar_mono_fpga/arch.py @ 1064

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

Update arch.py scripts to support the new mapping.py version

  • In this new version, the addIrq() function takes as a supplementary argument the instance of the interrupt generating peripheral.
File size: 12.3 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_monocluster_fpga architecture)
8#   date   : March 2015
9#   author : Cesar Fuguet
10###############################################################################
11#  This file contains a mapping generator for the "tsar_mono_fpga"
12#  platform.
13#  This includes both the hardware architecture (clusters, processors,
14#  peripherals, physical space segmentation) and the mapping of all boot
15#  and kernel objects (global vsegs).
16#
17#  It is inspired on the tsar_mono_fpga platform but includes a ROM in the
18#  cluster.
19#
20#  The others hardware parameters are:
21#  - fbf_width      : frame_buffer width = frame_buffer heigth
22#  - nb_ttys        : number of TTY channels
23#  - nb_nics        : number of NIC channels
24#  - nb_cmas        : number of CMA channels
25#  - irq_per_proc   : number of input IRQs per processor
26#  - use_ramdisk    : use a RAMDISK when True
27#  - peri_increment : address increment for replicated peripherals
28###############################################################################
29
30########################
31def arch( x_size    = 1,
32          y_size    = 1,
33          nb_procs  = 2,
34          nb_ttys   = 1,
35          fbf_width = 480,
36          ioc_type  = 'BDV' ):
37
38    ### define architecture constants
39
40    x_io            = 0
41    y_io            = 0
42    x_width         = 4
43    y_width         = 4
44    p_width         = 2
45    paddr_width     = 40
46    irq_per_proc    = 4
47    use_ramdisk     = False
48    peri_increment  = 0x10000     # distributed peripherals vbase increment
49    reset_address   = 0xFF000000  # wired preloader pbase address
50    use_backup_peri = True
51
52    ### parameters checking
53
54    assert( nb_procs <= (1 << p_width) )
55    assert( (x_size == 1) and (y_size == 1) );
56
57    ### define type and name
58
59    platform_type  = 'tsar_fpga'
60    platform_name  = '%s_%d' % (platform_type, nb_procs )
61
62    ### define physical segments replicated in all clusters
63    ### the base address is extended by the cluster_xy (8 bits)
64
65    ram_base = 0x00000000
66    ram_size = 0x8000000                   # 128 Mbytes
67
68    xcu_base = 0xF0000000
69    xcu_size = 0x1000                      # 4 Kbytes
70
71    mmc_base = 0xF1000000
72    mmc_size = 0x1000                      # 4 Kbytes
73
74    rom_base = 0xFF000000
75    rom_size = 0x10000                     # 64 Kbytes
76
77    bdv_base = 0xF2000000
78    bdv_size = 0x1000                     # 4kbytes
79
80    tty_base = 0xF4000000
81    tty_size = 0x4000                     # 16 Kbytes
82
83    fbf_base = 0xF3000000
84    fbf_size = fbf_width * fbf_width      # fbf_width * fbf_width bytes
85
86    ### define preloader & bootloader vsegs base addresses and sizes
87    ### We want to pack these 5 vsegs in the same big page
88    ### => boot cost is one BPP in cluster[0][0]
89
90    preloader_vbase      = reset_address   # ident
91    preloader_size       = 0x00010000      # 64 Kbytes
92
93    boot_mapping_vbase   = 0x00010000      # ident
94    boot_mapping_size    = 0x00080000      # 512 Kbytes
95
96    boot_code_vbase      = 0x00090000      # ident
97    boot_code_size       = 0x00040000      # 256 Kbytes
98
99    boot_data_vbase      = 0x000D0000      # ident
100    boot_data_size       = 0x000B0000      # 704 Kbytes
101
102    boot_stack_vbase     = 0x00180000      # ident
103    boot_stack_size      = 0x00080000      # 512 Kbytes
104
105    ### define ramdisk vseg / must be identity mapping in cluster[0][0]
106    ### occupies 15 BPP after the boot
107    ramdisk_vbase        = 0x00200000
108    ramdisk_size         = 0x02000000      # 32 Mbytes
109
110    ### define kernel vsegs base addresses and sizes
111    ### code, init, ptab, heap & sched vsegs are replicated in all clusters.
112    ### data & uncdata vsegs are only mapped in cluster[0][0].
113
114    kernel_code_vbase    = 0x80000000
115    kernel_code_size     = 0x00100000      # 1 Mbytes per cluster
116
117    kernel_init_vbase    = 0x80100000
118    kernel_init_size     = 0x00100000      # 1 Mbytes per cluster
119
120    kernel_data_vbase    = 0x90000000
121    kernel_data_size     = 0x00200000      # 2 Mbytes in cluster[0][0]
122
123    kernel_ptab_vbase    = 0xE0000000
124    kernel_ptab_size     = 0x00200000      # 2 Mbytes per cluster
125
126    kernel_heap_vbase    = 0xD0000000
127    kernel_heap_size     = 0x00200000      # 2 Mbytes per cluster
128
129    kernel_sched_vbase   = 0xA0000000
130    kernel_sched_size    = 0x00002000 * nb_procs # 8 kbytes per proc per cluster
131
132    #####################
133    ### create mapping
134    #####################
135
136    mapping = Mapping( name           = platform_name,
137                       x_size         = x_size,
138                       y_size         = y_size,
139                       nprocs         = nb_procs,
140                       x_width        = x_width,
141                       y_width        = y_width,
142                       p_width        = p_width,
143                       paddr_width    = paddr_width,
144                       coherence      = True,
145                       irq_per_proc   = irq_per_proc,
146                       use_ramdisk    = use_ramdisk,
147                       x_io           = x_io,
148                       y_io           = y_io,
149                       peri_increment = peri_increment,
150                       reset_address  = reset_address,
151                       ram_base       = ram_base,
152                       ram_size       = ram_size )
153
154    ###########################
155    ### Hardware Description
156    ###########################
157
158    ### components replicated in all clusters but the upper row
159    ram = mapping.addRam( 'RAM', base = ram_base, size = ram_size )
160
161    xcu = mapping.addPeriph( 'XCU', base = xcu_base, size = xcu_size,
162                             ptype = 'XCU', channels = nb_procs * irq_per_proc,
163                             arg0 = 16, arg1 = 16, arg2 = 16 )
164
165    mmc = mapping.addPeriph( 'MMC', base = mmc_base, size = mmc_size,
166                             ptype = 'MMC' )
167
168    mapping.addIrq( xcu, index = 8 , src = mmc, isrtype = 'ISR_MMC' )
169
170    for p in xrange ( nb_procs ): mapping.addProc( 0, 0, p )
171
172    bdv = mapping.addPeriph( 'BDV0', base = bdv_base, size = bdv_size,
173                             ptype = 'IOC', subtype = 'BDV' )
174
175    mapping.addIrq( xcu, index = 9 , src = bdv, isrtype = 'ISR_BDV' )
176
177    tty = mapping.addPeriph( 'TTY0', base = tty_base, size = tty_size,
178                             ptype = 'TTY', channels = nb_ttys )
179
180    mapping.addIrq( xcu, index = 10, src = tty, isrtype = 'ISR_TTY_RX' )
181
182    rom = mapping.addPeriph( 'ROM', base = rom_base, size = rom_size,
183                             ptype = 'ROM' )
184
185    fbf = mapping.addPeriph( 'FBF', base = fbf_base, size = fbf_size,
186                             ptype = 'FBF', arg0 = fbf_width , arg1 = fbf_width)
187
188    ###################################
189    ### boot & kernel vsegs mapping
190    ###################################
191
192    ### global vsegs for preloader & boot_loader are mapped in cluster[0][0]
193    ### => same flags CXW_ / identity mapping / non local / big page
194
195    mapping.addGlobal( 'seg_preloader', preloader_vbase, preloader_size,
196                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
197                       identity = True, local = False, big = True )
198
199    mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size,
200                       'CXW_', vtype = 'BLOB'  , x = 0, y = 0, pseg = 'RAM',
201                       identity = True, local = False, big = True )
202
203    mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size,
204                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
205                       identity = True, local = False, big = True )
206
207    mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size,
208                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
209                       identity = True, local = False, big = True )
210
211    mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size,
212                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
213                       identity = True, local = False, big = True )
214
215    ### global vseg for RAM-DISK in cluster[0][0]
216    ### identity mapping / non local / big pages
217    if use_ramdisk:
218
219        mapping.addGlobal( 'seg_ramdisk', ramdisk_vbase, ramdisk_size,
220                           'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
221                           identity = True, local = True, big = True )
222
223    ### global vsegs kernel_code, kernel_init : local / big page
224    ### replicated in all clusters containing processors
225    ### same content => same name / same vbase
226    mapping.addGlobal( 'seg_kernel_code',
227                       kernel_code_vbase, kernel_code_size,
228                       'CXW_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
229                       binpath = 'build/kernel/kernel.elf',
230                       local = True, big = True )
231
232    mapping.addGlobal( 'seg_kernel_init',
233                       kernel_init_vbase, kernel_init_size,
234                       'CXW_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
235                       binpath = 'build/kernel/kernel.elf',
236                       local = True, big = True )
237
238    ### global vseg kernel_data: non local / big page
239    ### Only mapped in cluster[0][0]
240    mapping.addGlobal( 'seg_kernel_data',
241                       kernel_data_vbase, kernel_data_size,
242                       'C_W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
243                       binpath = 'build/kernel/kernel.elf',
244                       local = False, big = True )
245
246    ### Global vsegs kernel_ptab_x_y: non local / big page
247    ### replicated in all clusters containing processors
248    ### different content => name & vbase indexed by (x,y)
249    mapping.addGlobal( 'seg_kernel_ptab',
250                       kernel_ptab_vbase, kernel_ptab_size,
251                       'CXW_', vtype = 'PTAB', x = 0, y = 0, pseg = 'RAM',
252                       local = False, big = True )
253
254    ### global vsegs kernel_heap_x_y : non local / big pages
255    ### distributed in all clusters containing processors
256    ### different content => name & vbase indexed by (x,y)
257    mapping.addGlobal( 'seg_kernel_heap',
258                       kernel_heap_vbase, kernel_heap_size,
259                       'C_W_', vtype = 'HEAP', x = 0 , y = 0 , pseg = 'RAM',
260                       local = False, big = True )
261
262    ### global vsegs for external peripherals: non local / big page
263    ### only mapped in cluster_io
264    mapping.addGlobal( 'seg_bdv', bdv_base, bdv_size,
265                       '__W_', vtype = 'PERI', x = 0, y = 0, pseg = 'BDV',
266                       local = False, big = True )
267
268    mapping.addGlobal( 'seg_tty', tty_base, tty_size,
269                       '__W_', vtype = 'PERI', x = 0, y = 0, pseg = 'TTY',
270                       local = False, big = True )
271
272    mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size,
273                       '__W_', vtype = 'PERI', x = 0, y = 0, pseg = 'FBF',
274                       local = False, big = True )
275
276    ### global vsegs for internal peripherals : non local / small pages
277    ### allocated in all clusters containing processors
278    ### name and vbase indexed by (x,y)
279    mapping.addGlobal( 'seg_xcu',
280                       xcu_base, xcu_size,
281                       '__W_', vtype = 'PERI' , x = 0 , y = 0 , pseg = 'XCU',
282                       local = False, big = False )
283
284    mapping.addGlobal( 'seg_mmc',
285                       mmc_base, mmc_size,
286                       '__W_', vtype = 'PERI' , x = 0 , y = 0 , pseg = 'MMC',
287                       local = False, big = False )
288
289    ### global vsegs kernel_sched : non local / small pages
290    ### allocated in all clusters containing processors
291    ### different content => name & vbase indexed by (x,y)
292    mapping.addGlobal( 'seg_kernel_sched',
293                       kernel_sched_vbase, kernel_sched_size,
294                       'C_W_', vtype = 'SCHED', x = 0, y = 0, pseg = 'RAM',
295                       local = False, big = False )
296
297    return mapping
298
299########################## platform test #############################################
300
301if __name__ == '__main__':
302    mapping = arch( x_size = 1,
303                    y_size = 1,
304                    nb_procs = 2 )
305
306#   print mapping.netbsd_dts()
307
308    print mapping.xml()
309
310#   print mapping.giet_vsegs()
311
312
313# Local Variables:
314# tab-width: 4;
315# c-basic-offset: 4;
316# c-file-offsets:((innamespace . 0)(inline-open . 0));
317# indent-tabs-mode: nil;
318# End:
319#
320# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
321
Note: See TracBrowser for help on using the repository browser.