source: trunk/platforms/tsar_generic_iob/arch_info.py @ 1046

Last change on this file since 1046 was 1046, checked in by alain, 8 years ago

Modify top.cpp to select the virtual disk as a parameter.
Fix a bug in arch_info.py.

  • Property svn:executable set to *
File size: 13.1 KB
Line 
1#!/usr/bin/env python
2
3from arch_classes import *
4
5#########################################################################################
6#   file   : arch_info.py for the tsar_generic_iob architecture)
7#   date   : august 2016
8#   author : Alain Greiner
9#########################################################################################
10#  This python script defines a specific instance of "tsar_generic_iob" architecture
11#  for the ALMOS-MK operating system. It is used to generate the "hard_config.h"
12#  and the "arch_info.bin files, used by bthe ALMOS-MK bootloader.
13#
14#  The constructor prototype format is imposed by the genarch.py application,
15#  and should not be modified.
16#
17#  The "tsar_generic_iob" architecture includes 7 external peripherals, accessed
18#  through an IOB components located in cluster [0,0] or in cluster [x_size-1, y_size-1].
19#  Available peripherals are: TTY, IOC, FBF, ROM, NIC, CMA, PIC.
20#  All clusters contain (nb_cores) processors, one L2 cache, one XCU, and
21#  one optional hardware coprocessor connected to a MWMR controller.
22#
23#  As the "tsar_generic_iob" architecture is generic, the following parameters
24#  are defined as constructor arguments and can be redefined in the Makefile when
25#  a new kernel image is generated :
26#  - x_size         : number of clusters in a row (from 1 to 16)
27#  - y_size         : number of clusters in a column (from & to 16)
28#  - nb_cores       : number of processors per cluster (from 1 to 4)
29#  - nb_ttys        : number of TTY channels (can be from 1 to 8)
30#  - nb_nics        : number of NIC channels (from 1 to 2)
31#  - nb_cmas        : number of CMA channels (from 1 to 4)
32#  - fbf_width      : frame_buffer width = frame_buffer heigth
33#  - ioc_type       : can be 'IOC_BDV','IOC_HBA','IOC_SDC', 'IOC_SPI','NONE'
34#  - mwr_type       : can be 'MWR_GCD','MWR_DCT','MWR_CPY','NONE'
35#  - io_cxy         : IO cluster identifier
36#  - boot_cxy       : boot cluster identifier
37#
38#  The following parameters are imposed by the "tsar_generic_iob" architecture:
39#  - devices_max    : max number of devices per cluster
40#  - x_width        : number of bits for x coordinate
41#  - y_width        : number of bits for y coordinate
42#  - paddr_width    : number of bits for physical address
43#  - p_width        : number of bits for local processor index
44#  - irqs_per_core  : number of input IRQs per processor
45########################################################################################
46
47############################
48def arch( x_size        = 2,
49          y_size        = 2,
50          nb_cores      = 2,
51          nb_ttys       = 1,
52          nb_nics       = 1, 
53          nb_cmas       = 2,
54          fbf_width     = 128,
55          ioc_type      = 'IOC_BDV',
56          mwr_type      = 'MWR_CPY',
57          io_cxy        = 0,
58          boot_cxy      = 0 ):
59
60    ### architecture constants
61
62    p_width       = 2
63    x_width       = 4
64    y_width       = 4
65    paddr_width   = 40
66    irqs_per_core = 4           
67    devices_max   = 16 
68
69    ### constructor parameters checking
70
71    assert( (x_size == 1) or (x_size == 2) or (x_size == 4)
72             or (x_size == 8) or (x_size == 16) )
73
74    assert( (y_size == 1) or (y_size == 2) or (y_size == 4)
75             or (y_size == 8) or (y_size == 16) )
76
77    assert( nb_cores <= 4 )
78
79    assert( (nb_ttys >= 1) and (nb_ttys <= 8) )
80
81    assert( (nb_nics >= 1) and (nb_nics <= 2) )
82
83    assert( (nb_cmas >= 1) and (nb_cmas <= 4) )
84
85    assert( ioc_type in ['IOC_BDV','IOC_HBA','IOC_SDC','IOC_SPI','IOC_RDK'] )
86
87    assert( mwr_type in ['MWR_GCD','MWR_DCT','MWR_CPY'] )
88
89    assert( (io_cxy == 0) or (io_cxy == ((x_size-1)<<y_width) + (y_size-1)) ) 
90
91    assert( ((boot_cxy >> y_width) < x_size) and ((boot_cxy & ((1<<y_width)-1)) < y_size) )
92 
93    ### define platform name
94
95    platform_name = 'tsar_iob_%d_%d_%d' % ( x_size, y_size , nb_cores )
96
97    ### define physical segments replicated in all clusters
98
99    ram_base = 0x0000000000
100    ram_size = 0x4000000                   # 64 Mbytes
101
102    xcu_base = 0x00B0000000
103    xcu_size = 0x1000                      # 4 Kbytes
104
105    mwr_base = 0x00B1000000
106    mwr_size = 0x1000                      # 4 Kbytes
107
108    mmc_base = 0x00B2000000
109    mmc_size = 0x1000                      # 4 Kbytes
110
111    ### define physical segments for external peripherals
112    ## These segments are only defined in cluster_io
113
114    ioc_base  = 0x00B3000000
115    ioc_size  = 0x1000                     # 4 Kbytes
116
117    tty_base  = 0x00B4000000
118    tty_size  = 0x4000                     # 16 Kbytes
119
120    nic_base  = 0x00B5000000
121    nic_size  = 0x80000                    # 512 kbytes
122
123    cma_base  = 0x00B6000000
124    cma_size  = 0x1000 * nb_cmas           # 4 kbytes * nb_cmas
125
126    fbf_base  = 0x00B7000000
127    fbf_size  = fbf_width * fbf_width      # fbf_width * fbf_width bytes
128
129    pic_base  = 0x00B8000000
130    pic_size  = 0x1000                     # 4 Kbytes
131
132    iob_base  = 0x00BE000000
133    iob_size  = 0x1000                     # 4 bytes
134
135    rom_base  = 0x00BFC00000
136    rom_size  = 0x4000                     # 16 Kbytes
137
138    ############################
139    ### call Header constructor
140    ############################
141
142    archi = Archinfo( name           = platform_name,
143                      x_size         = x_size,
144                      y_size         = y_size,
145                      cores_max      = nb_cores,
146                      devices_max    = devices_max,
147                      paddr_width    = paddr_width,
148                      x_width        = x_width,
149                      y_width        = y_width,
150                      irqs_per_core  = irqs_per_core,
151                      io_cxy         = io_cxy,         
152                      boot_cxy       = boot_cxy,
153                      reset_address  = rom_base, 
154                      p_width        = p_width )
155
156    ####################################################
157    ### construct hardware components for each cluster
158    ####################################################
159
160    for x in xrange( x_size ):
161        for y in xrange( y_size ):
162            cxy    = (x << y_width) + y;
163            offset = cxy << (paddr_width - x_width - y_width)
164
165            # build devices
166            ram = archi.addDevice( ptype    = 'RAM' , 
167                                   base     = ram_base + offset, 
168                                   size     = ram_size )
169
170            xcu = archi.addDevice( ptype    = 'XCU', 
171                                   base     = xcu_base + offset, 
172                                   size     = xcu_size,
173                                   channels = nb_cores * irqs_per_core, 
174                                   arg0     = 16, 
175                                   arg1     = 16,
176                                   arg2     = 16 )
177
178            mmc = archi.addDevice( ptype    = 'MMC',
179                                   base     = mmc_base + offset,
180                                   size     = mmc_size )
181            archi.addIrq( dstdev = xcu, port = 0, srcdev = mmc, isrtype = 'ISR_MMC' )
182
183            if ( mwr_type == 'MWR_GCD' ):
184                mwr = archi.addDevice( ptype = 'MWR_GCD',
185                                       base  = mwr_base + offset,
186                                       size  = mwr_size,
187                                       arg0  = 2, 
188                                       arg1  = 1,
189                                       arg2  = 1, 
190                                       arg3  = 0 )
191                archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr, isrtype = 'ISR_MWR' )
192
193            if ( mwr_type == 'MWR_DCT' ):
194                mwr = archi.addDevice( ptype = 'MWR_DCT',
195                                       base  = mwr_base + offset,
196                                       size  = mwr_size,
197                                       arg0  = 1, 
198                                       arg1  = 1,
199                                       arg2  = 1, 
200                                       arg3  = 0 )
201                archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr, isrtype = 'ISR_MWR' )
202
203            if ( mwr_type == 'MWR_CPY' ):
204                mwr = archi.addDevice( ptype = 'MWR_CPY',
205                                       base  = mwr_base + offset,
206                                       size  = mwr_size,
207                                       arg0  = 1, 
208                                       arg1  = 1,
209                                       arg2  = 1, 
210                                       arg3  = 0 )
211                archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr, isrtype = 'ISR_MWR' )
212
213            if( cxy == io_cxy ):
214
215                iob = archi.addDevice( ptype    = 'IOB', 
216                                       base     = iob_base + offset,
217                                       size     = iob_size )
218
219                ioc = archi.addDevice( ptype    = ioc_type,
220                                       base     = ioc_base + offset,
221                                       size     = ioc_size )
222
223                tty = archi.addDevice( ptype    = 'TTY',
224                                       base     = tty_base + offset,
225                                       size     = tty_size, 
226                                       channels = nb_ttys )
227
228                nic = archi.addDevice( ptype    = 'NIC',
229                                       base     = nic_base + offset, 
230                                       size     = nic_size, 
231                                       channels = nb_nics )
232
233                cma = archi.addDevice( ptype    = 'CMA',
234                                       base     = cma_base + offset,
235                                       size     = cma_size, 
236                                       channels = nb_cmas )
237
238                fbf = archi.addDevice( ptype    = 'FBF',
239                                       base     = fbf_base + offset,
240                                       size     = fbf_size, 
241                                       arg0     = fbf_width,
242                                       arg1     = fbf_width )
243
244                rom = archi.addDevice( ptype    = 'ROM',
245                                       base     = rom_base + offset, 
246                                       size     = rom_size )
247
248                pic = archi.addDevice( ptype    ='PIC',
249                                       base     = pic_base + offset,
250                                       size     = pic_size, 
251                                       arg0     = 32 )
252
253                if   ( ioc_type == 'IOC_BDV' ): isr_ioc = 'ISR_BDV'
254                elif ( ioc_type == 'IOC_HBA' ): isr_ioc = 'ISR_HBA'
255                elif ( ioc_type == 'IOC_SDC' ): isr_ioc = 'ISR_SDC'
256                elif ( ioc_type == 'IOC_SPI' ): isr_ioc = 'ISR_SPI'
257                else                          : isr_ioc = 'ISR_DEFAULT'
258
259                archi.addIrq( dstdev = pic, port = 0 , srcdev = nic, isrtype = 'ISR_NIC_RX', channel = 0 )
260                archi.addIrq( dstdev = pic, port = 1 , srcdev = nic, isrtype = 'ISR_NIC_RX', channel = 1 )
261                archi.addIrq( dstdev = pic, port = 2 , srcdev = nic, isrtype = 'ISR_NIC_TX', channel = 0 )
262                archi.addIrq( dstdev = pic, port = 3 , srcdev = nic, isrtype = 'ISR_NIC_TX', channel = 1 )
263                archi.addIrq( dstdev = pic, port = 4 , srcdev = cma, isrtype = 'ISR_CMA'   , channel = 0 )
264                archi.addIrq( dstdev = pic, port = 5 , srcdev = cma, isrtype = 'ISR_CMA'   , channel = 1 )
265                archi.addIrq( dstdev = pic, port = 6 , srcdev = cma, isrtype = 'ISR_CMA'   , channel = 2 )
266                archi.addIrq( dstdev = pic, port = 7 , srcdev = cma, isrtype = 'ISR_CMA'   , channel = 3 )
267                archi.addIrq( dstdev = pic, port = 8 , srcdev = ioc, isrtype = isr_ioc     , channel = 0 )
268                archi.addIrq( dstdev = pic, port = 16, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 0 )
269                archi.addIrq( dstdev = pic, port = 17, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 1 )
270                archi.addIrq( dstdev = pic, port = 18, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 2 )
271                archi.addIrq( dstdev = pic, port = 19, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 3 )
272                archi.addIrq( dstdev = pic, port = 20, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 4 )
273                archi.addIrq( dstdev = pic, port = 21, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 5 )
274                archi.addIrq( dstdev = pic, port = 22, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 6 )
275                archi.addIrq( dstdev = pic, port = 23, srcdev = tty, isrtype = 'ISR_TTY_RX', channel = 7 )
276
277            # build cores
278            for p in xrange ( nb_cores ):
279                core = archi.addCore( (x<<(y_width+p_width)) + (y<<p_width) + p,  # hardware identifier
280                                      (x<<y_width) + y,                           # cluster identifier
281                                       p )                                        # local index
282
283    return archi
284
285################################# platform test ####################################
286
287if __name__ == '__main__':
288
289    archi = arch()
290
291    print archi.xml()
292
293
294# Local Variables:
295# tab-width: 4;
296# c-basic-offset: 4;
297# c-file-offsets:((innamespace . 0)(inline-open . 0));
298# indent-tabs-mode: nil;
299# End:
300#
301# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
302
Note: See TracBrowser for help on using the repository browser.