[1044] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
[1045] | 3 | from arch_classes import * |
---|
[1044] | 4 | |
---|
| 5 | ######################################################################################### |
---|
[1045] | 6 | # file : arch_info.py for the tsar_generic_iob architecture) |
---|
| 7 | # date : august 2016 |
---|
[1044] | 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 | # |
---|
[1045] | 14 | # The constructor prototype format is imposed by the genarch.py application, |
---|
| 15 | # and should not be modified. |
---|
| 16 | # |
---|
[1044] | 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 | # |
---|
[1045] | 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 : |
---|
[1044] | 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) |
---|
[1045] | 30 | # - nb_nics : number of NIC channels (from 1 to 2) |
---|
[1044] | 31 | # - fbf_width : frame_buffer width = frame_buffer heigth |
---|
| 32 | # - ioc_type : can be 'IOC_BDV','IOC_HBA','IOC_SDC', 'IOC_SPI','NONE' |
---|
[1045] | 33 | # - mwr_type : can be 'MWR_GCD','MWR_DCT','MWR_CPY','NONE' |
---|
| 34 | # - io_cxy : IO cluster identifier |
---|
[1044] | 35 | # - boot_cxy : boot cluster identifier |
---|
[1050] | 36 | # - cache_line : number of bytes in cache line (in 16,32,64) |
---|
[1044] | 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 |
---|
[1045] | 43 | # - p_width : number of bits for local processor index |
---|
[1044] | 44 | # - irqs_per_core : number of input IRQs per processor |
---|
| 45 | ######################################################################################## |
---|
| 46 | |
---|
| 47 | ############################ |
---|
| 48 | def arch( x_size = 2, |
---|
| 49 | y_size = 2, |
---|
| 50 | nb_cores = 2, |
---|
| 51 | nb_ttys = 1, |
---|
[1045] | 52 | nb_nics = 1, |
---|
[1044] | 53 | fbf_width = 128, |
---|
| 54 | ioc_type = 'IOC_BDV', |
---|
| 55 | mwr_type = 'MWR_CPY', |
---|
| 56 | io_cxy = 0, |
---|
[1050] | 57 | boot_cxy = 0, |
---|
| 58 | cache_line = 64): |
---|
[1044] | 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( ioc_type in ['IOC_BDV','IOC_HBA','IOC_SDC','IOC_SPI','IOC_RDK'] ) |
---|
| 84 | |
---|
| 85 | assert( mwr_type in ['MWR_GCD','MWR_DCT','MWR_CPY'] ) |
---|
| 86 | |
---|
| 87 | assert( (io_cxy == 0) or (io_cxy == ((x_size-1)<<y_width) + (y_size-1)) ) |
---|
| 88 | |
---|
| 89 | assert( ((boot_cxy >> y_width) < x_size) and ((boot_cxy & ((1<<y_width)-1)) < y_size) ) |
---|
[1050] | 90 | |
---|
| 91 | assert( (cache_line == 16) or (cache_line == 32) or (cache_line == 64) ) |
---|
[1044] | 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 |
---|
[1050] | 100 | ram_size = 0x800000 # 8 Mbytes |
---|
[1044] | 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 |
---|
[1050] | 121 | nic_size = 0x4000 # 16 kbytes |
---|
[1044] | 122 | |
---|
| 123 | fbf_base = 0x00B7000000 |
---|
| 124 | fbf_size = fbf_width * fbf_width # fbf_width * fbf_width bytes |
---|
| 125 | |
---|
| 126 | pic_base = 0x00B8000000 |
---|
| 127 | pic_size = 0x1000 # 4 Kbytes |
---|
| 128 | |
---|
| 129 | iob_base = 0x00BE000000 |
---|
| 130 | iob_size = 0x1000 # 4 bytes |
---|
| 131 | |
---|
| 132 | rom_base = 0x00BFC00000 |
---|
| 133 | rom_size = 0x4000 # 16 Kbytes |
---|
| 134 | |
---|
| 135 | ############################ |
---|
| 136 | ### call Header constructor |
---|
| 137 | ############################ |
---|
| 138 | |
---|
[1045] | 139 | archi = Archinfo( name = platform_name, |
---|
| 140 | x_size = x_size, |
---|
| 141 | y_size = y_size, |
---|
| 142 | cores_max = nb_cores, |
---|
| 143 | devices_max = devices_max, |
---|
| 144 | paddr_width = paddr_width, |
---|
| 145 | x_width = x_width, |
---|
| 146 | y_width = y_width, |
---|
| 147 | irqs_per_core = irqs_per_core, |
---|
| 148 | io_cxy = io_cxy, |
---|
| 149 | boot_cxy = boot_cxy, |
---|
[1050] | 150 | cache_line = cache_line, |
---|
[1046] | 151 | reset_address = rom_base, |
---|
| 152 | p_width = p_width ) |
---|
[1044] | 153 | |
---|
[1045] | 154 | #################################################### |
---|
| 155 | ### construct hardware components for each cluster |
---|
| 156 | #################################################### |
---|
[1044] | 157 | |
---|
| 158 | for x in xrange( x_size ): |
---|
| 159 | for y in xrange( y_size ): |
---|
[1045] | 160 | cxy = (x << y_width) + y; |
---|
| 161 | offset = cxy << (paddr_width - x_width - y_width) |
---|
[1044] | 162 | |
---|
[1050] | 163 | # define internal devices |
---|
| 164 | ram = archi.addDevice( ptype = 'RAM_SCL' , |
---|
[1044] | 165 | base = ram_base + offset, |
---|
| 166 | size = ram_size ) |
---|
| 167 | |
---|
[1050] | 168 | xcu = archi.addDevice( ptype = 'ICU_XCU', |
---|
[1044] | 169 | base = xcu_base + offset, |
---|
| 170 | size = xcu_size, |
---|
[1050] | 171 | channels = 1, |
---|
[1044] | 172 | arg0 = 16, |
---|
| 173 | arg1 = 16, |
---|
[1050] | 174 | arg2 = 16, |
---|
| 175 | arg3 = 16 ) |
---|
[1044] | 176 | |
---|
[1050] | 177 | mmc = archi.addDevice( ptype = 'MMC_TSR', |
---|
[1044] | 178 | base = mmc_base + offset, |
---|
| 179 | size = mmc_size ) |
---|
| 180 | |
---|
[1050] | 181 | archi.addIrq( dstdev = xcu, port = 0, srcdev = mmc ) |
---|
| 182 | |
---|
[1044] | 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 ) |
---|
[1050] | 191 | archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr ) |
---|
[1044] | 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 ) |
---|
[1050] | 201 | archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr ) |
---|
[1044] | 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 ) |
---|
[1050] | 211 | archi.addIrq( dstdev = xcu, port = 1, srcdev = mwr ) |
---|
[1044] | 212 | |
---|
[1050] | 213 | # define external devices |
---|
[1045] | 214 | if( cxy == io_cxy ): |
---|
[1044] | 215 | |
---|
[1050] | 216 | iob = archi.addDevice( ptype = 'IOB_TSR', |
---|
[1045] | 217 | base = iob_base + offset, |
---|
| 218 | size = iob_size ) |
---|
[1044] | 219 | |
---|
[1045] | 220 | ioc = archi.addDevice( ptype = ioc_type, |
---|
| 221 | base = ioc_base + offset, |
---|
| 222 | size = ioc_size ) |
---|
[1044] | 223 | |
---|
[1050] | 224 | tty = archi.addDevice( ptype = 'TXT_TTY', |
---|
[1045] | 225 | base = tty_base + offset, |
---|
| 226 | size = tty_size, |
---|
| 227 | channels = nb_ttys ) |
---|
[1044] | 228 | |
---|
[1050] | 229 | nic = archi.addDevice( ptype = 'NIC_CBF', |
---|
[1045] | 230 | base = nic_base + offset, |
---|
| 231 | size = nic_size, |
---|
| 232 | channels = nb_nics ) |
---|
[1044] | 233 | |
---|
[1050] | 234 | fbf = archi.addDevice( ptype = 'FBF_SCL', |
---|
[1045] | 235 | base = fbf_base + offset, |
---|
| 236 | size = fbf_size, |
---|
| 237 | arg0 = fbf_width, |
---|
| 238 | arg1 = fbf_width ) |
---|
[1044] | 239 | |
---|
[1050] | 240 | rom = archi.addDevice( ptype = 'ROM_SCL', |
---|
[1045] | 241 | base = rom_base + offset, |
---|
| 242 | size = rom_size ) |
---|
[1044] | 243 | |
---|
[1050] | 244 | pic = archi.addDevice( ptype ='PIC_TSR', |
---|
[1045] | 245 | base = pic_base + offset, |
---|
| 246 | size = pic_size, |
---|
| 247 | arg0 = 32 ) |
---|
[1044] | 248 | |
---|
[1050] | 249 | archi.addIrq( dstdev = pic, port = 0 , srcdev = nic, channel = 0 , is_rx = True ) |
---|
| 250 | archi.addIrq( dstdev = pic, port = 1 , srcdev = nic, channel = 1 , is_rx = True ) |
---|
| 251 | archi.addIrq( dstdev = pic, port = 2 , srcdev = nic, channel = 2 , is_rx = True ) |
---|
| 252 | archi.addIrq( dstdev = pic, port = 3 , srcdev = nic, channel = 3 , is_rx = True ) |
---|
[1044] | 253 | |
---|
[1050] | 254 | archi.addIrq( dstdev = pic, port = 4 , srcdev = nic, channel = 0 , is_rx = False ) |
---|
| 255 | archi.addIrq( dstdev = pic, port = 5 , srcdev = nic, channel = 1 , is_rx = False ) |
---|
| 256 | archi.addIrq( dstdev = pic, port = 6 , srcdev = nic, channel = 2 , is_rx = False ) |
---|
| 257 | archi.addIrq( dstdev = pic, port = 7 , srcdev = nic, channel = 3 , is_rx = False ) |
---|
[1044] | 258 | |
---|
[1050] | 259 | archi.addIrq( dstdev = pic, port = 12, srcdev = ioc ) |
---|
| 260 | |
---|
| 261 | archi.addIrq( dstdev = pic, port = 16, srcdev = tty, channel = 0 , is_rx = True ) |
---|
| 262 | archi.addIrq( dstdev = pic, port = 17, srcdev = tty, channel = 1 , is_rx = True ) |
---|
| 263 | archi.addIrq( dstdev = pic, port = 18, srcdev = tty, channel = 2 , is_rx = True ) |
---|
| 264 | archi.addIrq( dstdev = pic, port = 19, srcdev = tty, channel = 3 , is_rx = True ) |
---|
| 265 | archi.addIrq( dstdev = pic, port = 20, srcdev = tty, channel = 4 , is_rx = True ) |
---|
| 266 | archi.addIrq( dstdev = pic, port = 21, srcdev = tty, channel = 5 , is_rx = True ) |
---|
| 267 | archi.addIrq( dstdev = pic, port = 22, srcdev = tty, channel = 6 , is_rx = True ) |
---|
| 268 | archi.addIrq( dstdev = pic, port = 23, srcdev = tty, channel = 7 , is_rx = True ) |
---|
| 269 | |
---|
| 270 | # define cores |
---|
[1045] | 271 | for p in xrange ( nb_cores ): |
---|
[1050] | 272 | core = archi.addCore( (x<<(y_width+p_width)) + (y<<p_width) + p, # hardware id |
---|
| 273 | (x<<y_width) + y, # cluster |
---|
[1045] | 274 | p ) # local index |
---|
[1044] | 275 | |
---|
| 276 | return archi |
---|
| 277 | |
---|
| 278 | ################################# platform test #################################### |
---|
| 279 | |
---|
| 280 | if __name__ == '__main__': |
---|
| 281 | |
---|
| 282 | archi = arch() |
---|
| 283 | |
---|
| 284 | print archi.xml() |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | # Local Variables: |
---|
| 288 | # tab-width: 4; |
---|
| 289 | # c-basic-offset: 4; |
---|
| 290 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 291 | # indent-tabs-mode: nil; |
---|
| 292 | # End: |
---|
| 293 | # |
---|
| 294 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 295 | |
---|