1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from arch_classes import * |
---|
4 | |
---|
5 | ####################################################################################### |
---|
6 | # file : arch_info.py |
---|
7 | # date : june 2018 |
---|
8 | # author : Alain Greiner |
---|
9 | # |
---|
10 | # This file describes the <tsar_generic_leti> architecture for ALMOS-MKH. |
---|
11 | ####################################################################################### |
---|
12 | # This file defines a specific instance of the "tsar_generic_leti" architecture. |
---|
13 | # It is used to generate the "hard_config.h" file, |
---|
14 | # used to configure the hardware architecture, and the "arch_info.bin" file, used by |
---|
15 | # the ALMOS-MK bootloader. |
---|
16 | # |
---|
17 | # The constructor prototype format is imposed by the genarch.py application, |
---|
18 | # and should not be modified. |
---|
19 | # The default argument values are for the TSARLET 16 cores prototype. |
---|
20 | # |
---|
21 | # The "tsar_generic_leti" architecture includes 5 external peripherals located |
---|
22 | # in cluster[x_size-1][y_size-1]: TTY, IOC, FBF, NIC, PIC. |
---|
23 | # The upper row (y = y_size-1) does not contain processors or memory. |
---|
24 | # The "tsar_generic_leti" does not use the IOB component. |
---|
25 | # It does not use an external ROM, as the preloader code is (pre)loaded |
---|
26 | # at address 0x0, in the physical memory of cluster[0][0]. |
---|
27 | # |
---|
28 | # Two backup peripherals one (one TXT_TTY and one IOC_BDV) are connected |
---|
29 | # on local interconnect in cluster 0. |
---|
30 | # |
---|
31 | # The "constructor" parameters (defined in Makefile) are: |
---|
32 | # - x_size : number of clusters in a row (from 1 to 16) |
---|
33 | # - y_size : number of clusters in a column (from 1 to 16) |
---|
34 | # - nb_cores : number of cores per cluster (from 1 to 4) |
---|
35 | # - nb_ttys : number of TTY channels (from 1 to 8) |
---|
36 | # - nb_nics : number of NIC channels (from 1 to 2) |
---|
37 | # - fbf_width : frame_buffer width = frame_buffer heigth |
---|
38 | # - ioc_type : can be 'IOC_BDV','IOC_HBA','IOC_SDC','IOC_RDK' |
---|
39 | # |
---|
40 | # The others hardware parameters are defined below : |
---|
41 | # - x_width : number of bits for x coordinate |
---|
42 | # - y_width : number of bits for y coordinate |
---|
43 | # - p_width : number of bits for local core index |
---|
44 | # - paddr_width : number of bits for physical address |
---|
45 | # - irq_per_proc : number of input IRQs per processor |
---|
46 | # - io_cxy : IO_cluster identifier |
---|
47 | # - boot_cxy : boot_cluster identifier |
---|
48 | # - cache_line : number of bytes in cache line (64 for tsar) |
---|
49 | # - devices_max : max number of internal devices per cluster |
---|
50 | ##################################################################################### |
---|
51 | |
---|
52 | |
---|
53 | ######################## |
---|
54 | def arch( x_size = 2, |
---|
55 | y_size = 3, |
---|
56 | nb_cores = 4, |
---|
57 | nb_ttys = 3, |
---|
58 | nb__nics = 1, |
---|
59 | fbf_width = 128, |
---|
60 | ioc_type = 'IOC_BDV'): |
---|
61 | |
---|
62 | ### architecture constants |
---|
63 | |
---|
64 | p_width = 2 |
---|
65 | x_width = 4 |
---|
66 | y_width = 4 |
---|
67 | paddr_width = 40 |
---|
68 | irq_per_proc = 4 # NetBSD constraint |
---|
69 | io_cxy = ((x_size-1)<<y_width) + (y_size-1) # upper right cluster |
---|
70 | boot_cxy = 0 |
---|
71 | cache_line = 64 |
---|
72 | devices_max = 16 |
---|
73 | reset_address = 0x00000000 # LETI constraint |
---|
74 | |
---|
75 | ### constructors parameters checking |
---|
76 | |
---|
77 | assert( nb_cores <= 4 ) |
---|
78 | |
---|
79 | assert( x_size <= (1 << x_width) ) |
---|
80 | |
---|
81 | assert( (y_size > 1) and (y_size <= (1 << y_width)) ) |
---|
82 | |
---|
83 | assert( (nb_ttys >= 1) and (nb_ttys <= 8) ) |
---|
84 | |
---|
85 | assert( (nb_nics >= 1) and (nb_nics <= 2) ) |
---|
86 | |
---|
87 | assert( ioc_type in ['IOC_BDV','IOC_HBA','IOC_SDC','IOC_SPI','IOC_RDK'] ) |
---|
88 | |
---|
89 | assert( ((boot_cxy >> y_width) < x_size) and ((boot_cxy & ((1<<y_width)-1)) < (y_size - 1) ) ) |
---|
90 | |
---|
91 | ### define type and name |
---|
92 | |
---|
93 | platform_name = 'tsar_leti_%d_%d_%d' % ( x_size, y_size, nb_cores ) |
---|
94 | |
---|
95 | ### define physical segments replicated in all non-IO clusters |
---|
96 | ### the base address is extended by the cxy (8 bits) |
---|
97 | |
---|
98 | ram_base = 0x0000000000 |
---|
99 | ram_size = 0x4000000 # 64 Mbytes |
---|
100 | |
---|
101 | xcu_base = 0x00F0000000 |
---|
102 | xcu_size = 0x1000 # 4 Kbytes |
---|
103 | |
---|
104 | mmc_base = 0x00F1000000 |
---|
105 | mmc_size = 0x1000 # 4 Kbytes |
---|
106 | |
---|
107 | ### define physical segments for external peripherals in IO cluster |
---|
108 | ## These segments are extended byb the IO_cluster cxy (8bits) |
---|
109 | |
---|
110 | ioc_base = 0x00F2000000 |
---|
111 | ioc_size = 0x1000 # 4kbytes |
---|
112 | |
---|
113 | fbf_base = 0x00F3000000 |
---|
114 | fbf_size = fbf_width * fbf_width # fbf_width * fbf_width bytes |
---|
115 | |
---|
116 | tty_base = 0x00F4000000 |
---|
117 | tty_size = 0x8000 # 4 Kbytes * 8 channels |
---|
118 | |
---|
119 | nic_base = 0x00F7000000 |
---|
120 | nic_size = 0x4000 # 4 Kbytes * 4 channels |
---|
121 | |
---|
122 | pic_base = 0x00F9000000 |
---|
123 | pic_size = 0x1000 # 4 Kbytes |
---|
124 | |
---|
125 | ############################# |
---|
126 | ### call header constructor |
---|
127 | ############################# |
---|
128 | |
---|
129 | archi = Archinfo( name = platform_name, |
---|
130 | x_size = x_size, |
---|
131 | y_size = y_size, |
---|
132 | cores_max = nb_cores, |
---|
133 | devices_max = devices_max, |
---|
134 | paddr_width = paddr_width, |
---|
135 | x_width = x_width, |
---|
136 | y_width = y_width, |
---|
137 | irqs_per_core = irqs_per_core, |
---|
138 | io_cxy = io_cxy, |
---|
139 | boot_cxy = boot_cxy, |
---|
140 | cache_line = cache_line, |
---|
141 | reset_address = reset_address, |
---|
142 | p_width = p_width ) |
---|
143 | |
---|
144 | ########################### |
---|
145 | ### Hardware Description |
---|
146 | ########################### |
---|
147 | |
---|
148 | for x in xrange( x_size ): |
---|
149 | for y in xrange( y_size ): |
---|
150 | cluster_xy = (x << y_width) + y; |
---|
151 | offset = cluster_xy << (paddr_width - x_width - y_width) |
---|
152 | |
---|
153 | ### components replicated in all clusters but the upper row |
---|
154 | if ( y < (y_size - 1) ): |
---|
155 | |
---|
156 | ram = archi.addDevice( ptype = 'RAM_SCL', |
---|
157 | base = ram_base + offset, |
---|
158 | size = ram_size ) |
---|
159 | |
---|
160 | mmc = archi.addDevice( ptype = 'MMC_TSR', |
---|
161 | base = mmc_base + offset, |
---|
162 | size = mmc_size ) |
---|
163 | |
---|
164 | xcu = archi.addDevice( ptype = 'ICU_XCU', |
---|
165 | base = xcu_base + offset, |
---|
166 | size = xcu_size, |
---|
167 | channels = nb_cores * irq_per_proc, |
---|
168 | arg0 = 16, arg1 = 16, arg2 = 16 ) |
---|
169 | |
---|
170 | archi.addIrq( dstdev = xcu, |
---|
171 | port = 8, |
---|
172 | srcdev = mmc ) |
---|
173 | |
---|
174 | ### TTY and IOC backup |
---|
175 | if ( x==0 ) and ( y==0 ): |
---|
176 | tty_bak = archi.addDevice( ptype = 'TXT_TTY', |
---|
177 | base = tty_base + offset, |
---|
178 | size = tty_size, |
---|
179 | channels = nb_ttys ) |
---|
180 | |
---|
181 | archi.addIrq( dstdev = xcu, |
---|
182 | port = TODO |
---|
183 | srcdev = tty_bak, |
---|
184 | channel = 0, |
---|
185 | is_rx = False ) |
---|
186 | |
---|
187 | ioc_bak = archi.addDevice( ptype = 'IOC_SPI', |
---|
188 | base = ioc_base + offset, |
---|
189 | size = ioc_size ) |
---|
190 | |
---|
191 | archi.addIrq( dstdev = xcu, |
---|
192 | port = TODO |
---|
193 | srcdev = ioc_bak ) |
---|
194 | |
---|
195 | for p in xrange ( nb_cores ): |
---|
196 | archi.addProc( x, y, p ) |
---|
197 | |
---|
198 | ### peripherals in external cluster_io |
---|
199 | if( cluster_xy == io_cxy ): |
---|
200 | |
---|
201 | tty = archi.addDevice( ptype = 'TXT_TTY', |
---|
202 | base = tty_base + offset, |
---|
203 | size = tty_size, |
---|
204 | channels = nb_ttys ) |
---|
205 | |
---|
206 | ioc = archi.addDevice( ptype = ioc_type, |
---|
207 | base = ioc_base + offset, |
---|
208 | size = ioc_size ) |
---|
209 | |
---|
210 | nic = archi.addDevice( ptype = 'NIC_CBF', |
---|
211 | base = nic_base + offset, |
---|
212 | size = nic_size, |
---|
213 | channels = nb_nics ) |
---|
214 | |
---|
215 | fbf = archi.addDevice( ptype = 'FBF_SCL', |
---|
216 | base = fbf_base + offset, |
---|
217 | size = fbf_size, |
---|
218 | arg0 = fbf_width, arg1 = fbf_width ) |
---|
219 | |
---|
220 | pic = archi.addDevice( 'PIC', base = pic_base + offset, size = pic_size, |
---|
221 | ptype = 'PIC', channels = 32 ) |
---|
222 | |
---|
223 | archi.addIrq( dstdev = pic, port = 0, srcdev = nic, channel = 0 ) |
---|
224 | # todo |
---|
225 | # archi.addIrq( pic, index = 1, src = nic, |
---|
226 | # isrtype = 'ISR_NIC_RX', channel = 1 ) |
---|
227 | # archi.addIrq( pic, index = 2, src = nic, |
---|
228 | # isrtype = 'ISR_NIC_TX', channel = 0 ) |
---|
229 | # archi.addIrq( pic, index = 3, src = nic, |
---|
230 | # isrtype = 'ISR_NIC_TX', channel = 1 ) |
---|
231 | # archi.addIrq( pic, index = 4, src = cma, |
---|
232 | # isrtype = 'ISR_CMA', channel = 0 ) |
---|
233 | # archi.addIrq( pic, index = 5, src = cma, |
---|
234 | # isrtype = 'ISR_CMA', channel = 1 ) |
---|
235 | # archi.addIrq( pic, index = 6, src = cma, |
---|
236 | # isrtype = 'ISR_CMA', channel = 2 ) |
---|
237 | # archi.addIrq( pic, index = 7, src = cma, |
---|
238 | # isrtype = 'ISR_CMA', channel = 3 ) |
---|
239 | |
---|
240 | |
---|
241 | archi.addIrq( dstdev = pic, port = 8, srcdev = ioc ) |
---|
242 | |
---|
243 | # archi.addIrq( pic, index = 16, src = tty, |
---|
244 | # isrtype = 'ISR_TTY_RX', channel = 0 ) |
---|
245 | # archi.addIrq( pic, index = 17, src = tty, |
---|
246 | # isrtype = 'ISR_TTY_RX', channel = 1 ) |
---|
247 | # archi.addIrq( pic, index = 18, src = tty, |
---|
248 | # isrtype = 'ISR_TTY_RX', channel = 2 ) |
---|
249 | # archi.addIrq( pic, index = 19, src = tty, |
---|
250 | # isrtype = 'ISR_TTY_RX', channel = 3 ) |
---|
251 | # archi.addIrq( pic, index = 20, src = tty, |
---|
252 | # isrtype = 'ISR_TTY_RX', channel = 4 ) |
---|
253 | # archi.addIrq( pic, index = 21, src = tty, |
---|
254 | # isrtype = 'ISR_TTY_RX', channel = 5 ) |
---|
255 | # archi.addIrq( pic, index = 22, src = tty, |
---|
256 | # isrtype = 'ISR_TTY_RX', channel = 6 ) |
---|
257 | # archi.addIrq( pic, index = 23, src = tty, |
---|
258 | # isrtype = 'ISR_TTY_RX', channel = 7 ) |
---|
259 | |
---|
260 | return archi |
---|
261 | |
---|
262 | ########################## platform test ############################################# |
---|
263 | |
---|
264 | if __name__ == '__main__': |
---|
265 | |
---|
266 | archi = Archinfo( x_size = 2, |
---|
267 | y_size = 3, |
---|
268 | nb_cores = 2 ) |
---|
269 | |
---|
270 | print archi.xml() |
---|
271 | |
---|
272 | # print archi.giet_vsegs() |
---|
273 | |
---|
274 | |
---|
275 | # Local Variables: |
---|
276 | # tab-width: 4; |
---|
277 | # c-basic-offset: 4; |
---|
278 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
279 | # indent-tabs-mode: nil; |
---|
280 | # End: |
---|
281 | # |
---|
282 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
283 | |
---|