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