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