[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 | # - io_cxy : IO cluster identifier |
---|
[1044] | 34 | # - boot_cxy : boot cluster identifier |
---|
[1050] | 35 | # - cache_line : number of bytes in cache line (in 16,32,64) |
---|
[1044] | 36 | # |
---|
| 37 | # The following parameters are imposed by the "tsar_generic_iob" architecture: |
---|
| 38 | # - devices_max : max number of devices per cluster |
---|
| 39 | # - x_width : number of bits for x coordinate |
---|
| 40 | # - y_width : number of bits for y coordinate |
---|
| 41 | # - paddr_width : number of bits for physical address |
---|
[1045] | 42 | # - p_width : number of bits for local processor index |
---|
[1044] | 43 | # - irqs_per_core : number of input IRQs per processor |
---|
| 44 | ######################################################################################## |
---|
| 45 | |
---|
| 46 | ############################ |
---|
| 47 | def arch( x_size = 2, |
---|
| 48 | y_size = 2, |
---|
| 49 | nb_cores = 2, |
---|
| 50 | nb_ttys = 1, |
---|
[1045] | 51 | nb_nics = 1, |
---|
[1044] | 52 | fbf_width = 128, |
---|
| 53 | ioc_type = 'IOC_BDV', |
---|
| 54 | io_cxy = 0, |
---|
[1050] | 55 | boot_cxy = 0, |
---|
| 56 | cache_line = 64): |
---|
[1044] | 57 | |
---|
| 58 | ### architecture constants |
---|
| 59 | |
---|
| 60 | p_width = 2 |
---|
| 61 | x_width = 4 |
---|
| 62 | y_width = 4 |
---|
| 63 | paddr_width = 40 |
---|
| 64 | irqs_per_core = 4 |
---|
| 65 | devices_max = 16 |
---|
| 66 | |
---|
| 67 | ### constructor parameters checking |
---|
| 68 | |
---|
| 69 | assert( (x_size == 1) or (x_size == 2) or (x_size == 4) |
---|
| 70 | or (x_size == 8) or (x_size == 16) ) |
---|
| 71 | |
---|
| 72 | assert( (y_size == 1) or (y_size == 2) or (y_size == 4) |
---|
| 73 | or (y_size == 8) or (y_size == 16) ) |
---|
| 74 | |
---|
| 75 | assert( nb_cores <= 4 ) |
---|
| 76 | |
---|
| 77 | assert( (nb_ttys >= 1) and (nb_ttys <= 8) ) |
---|
| 78 | |
---|
| 79 | assert( (nb_nics >= 1) and (nb_nics <= 2) ) |
---|
| 80 | |
---|
| 81 | assert( ioc_type in ['IOC_BDV','IOC_HBA','IOC_SDC','IOC_SPI','IOC_RDK'] ) |
---|
| 82 | |
---|
| 83 | assert( (io_cxy == 0) or (io_cxy == ((x_size-1)<<y_width) + (y_size-1)) ) |
---|
| 84 | |
---|
| 85 | assert( ((boot_cxy >> y_width) < x_size) and ((boot_cxy & ((1<<y_width)-1)) < y_size) ) |
---|
[1050] | 86 | |
---|
| 87 | assert( (cache_line == 16) or (cache_line == 32) or (cache_line == 64) ) |
---|
[1044] | 88 | |
---|
| 89 | ### define platform name |
---|
| 90 | |
---|
| 91 | platform_name = 'tsar_iob_%d_%d_%d' % ( x_size, y_size , nb_cores ) |
---|
| 92 | |
---|
| 93 | ### define physical segments replicated in all clusters |
---|
| 94 | |
---|
| 95 | ram_base = 0x0000000000 |
---|
[1050] | 96 | ram_size = 0x800000 # 8 Mbytes |
---|
[1044] | 97 | |
---|
| 98 | xcu_base = 0x00B0000000 |
---|
| 99 | xcu_size = 0x1000 # 4 Kbytes |
---|
| 100 | |
---|
[1051] | 101 | dma_base = 0x00B1000000 |
---|
| 102 | dma_size = 0x1000 # 4 Kbytes |
---|
[1044] | 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 |
---|
[1050] | 117 | nic_size = 0x4000 # 16 kbytes |
---|
[1044] | 118 | |
---|
| 119 | fbf_base = 0x00B7000000 |
---|
| 120 | fbf_size = fbf_width * fbf_width # fbf_width * fbf_width bytes |
---|
| 121 | |
---|
| 122 | pic_base = 0x00B8000000 |
---|
| 123 | pic_size = 0x1000 # 4 Kbytes |
---|
| 124 | |
---|
| 125 | iob_base = 0x00BE000000 |
---|
| 126 | iob_size = 0x1000 # 4 bytes |
---|
| 127 | |
---|
| 128 | rom_base = 0x00BFC00000 |
---|
| 129 | rom_size = 0x4000 # 16 Kbytes |
---|
| 130 | |
---|
| 131 | ############################ |
---|
| 132 | ### call Header constructor |
---|
| 133 | ############################ |
---|
| 134 | |
---|
[1045] | 135 | archi = Archinfo( name = platform_name, |
---|
| 136 | x_size = x_size, |
---|
| 137 | y_size = y_size, |
---|
| 138 | cores_max = nb_cores, |
---|
| 139 | devices_max = devices_max, |
---|
| 140 | paddr_width = paddr_width, |
---|
| 141 | x_width = x_width, |
---|
| 142 | y_width = y_width, |
---|
| 143 | irqs_per_core = irqs_per_core, |
---|
| 144 | io_cxy = io_cxy, |
---|
| 145 | boot_cxy = boot_cxy, |
---|
[1050] | 146 | cache_line = cache_line, |
---|
[1046] | 147 | reset_address = rom_base, |
---|
| 148 | p_width = p_width ) |
---|
[1044] | 149 | |
---|
[1045] | 150 | #################################################### |
---|
| 151 | ### construct hardware components for each cluster |
---|
| 152 | #################################################### |
---|
[1044] | 153 | |
---|
| 154 | for x in xrange( x_size ): |
---|
| 155 | for y in xrange( y_size ): |
---|
[1045] | 156 | cxy = (x << y_width) + y; |
---|
| 157 | offset = cxy << (paddr_width - x_width - y_width) |
---|
[1044] | 158 | |
---|
[1050] | 159 | # define internal devices |
---|
| 160 | ram = archi.addDevice( ptype = 'RAM_SCL' , |
---|
[1044] | 161 | base = ram_base + offset, |
---|
| 162 | size = ram_size ) |
---|
| 163 | |
---|
[1050] | 164 | xcu = archi.addDevice( ptype = 'ICU_XCU', |
---|
[1044] | 165 | base = xcu_base + offset, |
---|
| 166 | size = xcu_size, |
---|
[1050] | 167 | channels = 1, |
---|
[1051] | 168 | arg0 = 16, # number of HWIs |
---|
| 169 | arg1 = 16, # number of WTIs |
---|
| 170 | arg2 = 16, # number of PTIs |
---|
| 171 | arg3 = 16 ) # number of output IRQs |
---|
[1044] | 172 | |
---|
[1050] | 173 | mmc = archi.addDevice( ptype = 'MMC_TSR', |
---|
[1044] | 174 | base = mmc_base + offset, |
---|
| 175 | size = mmc_size ) |
---|
| 176 | |
---|
[1050] | 177 | archi.addIrq( dstdev = xcu, port = 0, srcdev = mmc ) |
---|
| 178 | |
---|
[1051] | 179 | dma = archi.addDevice( ptype = 'DMA_SCL', |
---|
| 180 | base = dma_base + offset, |
---|
| 181 | size = dma_size, |
---|
| 182 | channels = nb_cores ) |
---|
[1044] | 183 | |
---|
[1051] | 184 | archi.addIrq( dstdev = xcu, port = 1, srcdev = dma, channel = 0 ) |
---|
| 185 | archi.addIrq( dstdev = xcu, port = 2, srcdev = dma, channel = 1 ) |
---|
| 186 | archi.addIrq( dstdev = xcu, port = 3, srcdev = dma, channel = 2 ) |
---|
| 187 | archi.addIrq( dstdev = xcu, port = 4, srcdev = dma, channel = 3 ) |
---|
[1044] | 188 | |
---|
[1050] | 189 | # define external devices |
---|
[1045] | 190 | if( cxy == io_cxy ): |
---|
[1044] | 191 | |
---|
[1051] | 192 | pic = archi.addDevice( ptype ='PIC_TSR', |
---|
| 193 | base = pic_base + offset, |
---|
| 194 | size = pic_size, |
---|
| 195 | arg0 = 32 ) # number of input IRQs |
---|
| 196 | |
---|
[1050] | 197 | iob = archi.addDevice( ptype = 'IOB_TSR', |
---|
[1045] | 198 | base = iob_base + offset, |
---|
| 199 | size = iob_size ) |
---|
[1044] | 200 | |
---|
[1045] | 201 | ioc = archi.addDevice( ptype = ioc_type, |
---|
| 202 | base = ioc_base + offset, |
---|
| 203 | size = ioc_size ) |
---|
[1044] | 204 | |
---|
[1050] | 205 | tty = archi.addDevice( ptype = 'TXT_TTY', |
---|
[1045] | 206 | base = tty_base + offset, |
---|
| 207 | size = tty_size, |
---|
| 208 | channels = nb_ttys ) |
---|
[1044] | 209 | |
---|
[1050] | 210 | nic = archi.addDevice( ptype = 'NIC_CBF', |
---|
[1045] | 211 | base = nic_base + offset, |
---|
| 212 | size = nic_size, |
---|
| 213 | channels = nb_nics ) |
---|
[1044] | 214 | |
---|
[1050] | 215 | fbf = archi.addDevice( ptype = 'FBF_SCL', |
---|
[1045] | 216 | base = fbf_base + offset, |
---|
| 217 | size = fbf_size, |
---|
| 218 | arg0 = fbf_width, |
---|
| 219 | arg1 = fbf_width ) |
---|
[1044] | 220 | |
---|
[1050] | 221 | rom = archi.addDevice( ptype = 'ROM_SCL', |
---|
[1045] | 222 | base = rom_base + offset, |
---|
| 223 | size = rom_size ) |
---|
[1044] | 224 | |
---|
[1050] | 225 | archi.addIrq( dstdev = pic, port = 0 , srcdev = nic, channel = 0 , is_rx = True ) |
---|
| 226 | archi.addIrq( dstdev = pic, port = 1 , srcdev = nic, channel = 1 , is_rx = True ) |
---|
| 227 | archi.addIrq( dstdev = pic, port = 2 , srcdev = nic, channel = 2 , is_rx = True ) |
---|
| 228 | archi.addIrq( dstdev = pic, port = 3 , srcdev = nic, channel = 3 , is_rx = True ) |
---|
[1044] | 229 | |
---|
[1050] | 230 | archi.addIrq( dstdev = pic, port = 4 , srcdev = nic, channel = 0 , is_rx = False ) |
---|
| 231 | archi.addIrq( dstdev = pic, port = 5 , srcdev = nic, channel = 1 , is_rx = False ) |
---|
| 232 | archi.addIrq( dstdev = pic, port = 6 , srcdev = nic, channel = 2 , is_rx = False ) |
---|
| 233 | archi.addIrq( dstdev = pic, port = 7 , srcdev = nic, channel = 3 , is_rx = False ) |
---|
[1044] | 234 | |
---|
[1050] | 235 | archi.addIrq( dstdev = pic, port = 12, srcdev = ioc ) |
---|
| 236 | |
---|
| 237 | archi.addIrq( dstdev = pic, port = 16, srcdev = tty, channel = 0 , is_rx = True ) |
---|
| 238 | archi.addIrq( dstdev = pic, port = 17, srcdev = tty, channel = 1 , is_rx = True ) |
---|
| 239 | archi.addIrq( dstdev = pic, port = 18, srcdev = tty, channel = 2 , is_rx = True ) |
---|
| 240 | archi.addIrq( dstdev = pic, port = 19, srcdev = tty, channel = 3 , is_rx = True ) |
---|
| 241 | archi.addIrq( dstdev = pic, port = 20, srcdev = tty, channel = 4 , is_rx = True ) |
---|
| 242 | archi.addIrq( dstdev = pic, port = 21, srcdev = tty, channel = 5 , is_rx = True ) |
---|
| 243 | archi.addIrq( dstdev = pic, port = 22, srcdev = tty, channel = 6 , is_rx = True ) |
---|
| 244 | archi.addIrq( dstdev = pic, port = 23, srcdev = tty, channel = 7 , is_rx = True ) |
---|
| 245 | |
---|
| 246 | # define cores |
---|
[1045] | 247 | for p in xrange ( nb_cores ): |
---|
[1050] | 248 | core = archi.addCore( (x<<(y_width+p_width)) + (y<<p_width) + p, # hardware id |
---|
| 249 | (x<<y_width) + y, # cluster |
---|
[1045] | 250 | p ) # local index |
---|
[1044] | 251 | |
---|
| 252 | return archi |
---|
| 253 | |
---|
| 254 | ################################# platform test #################################### |
---|
| 255 | |
---|
| 256 | if __name__ == '__main__': |
---|
| 257 | |
---|
| 258 | archi = arch() |
---|
| 259 | |
---|
| 260 | print archi.xml() |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | # Local Variables: |
---|
| 264 | # tab-width: 4; |
---|
| 265 | # c-basic-offset: 4; |
---|
| 266 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 267 | # indent-tabs-mode: nil; |
---|
| 268 | # End: |
---|
| 269 | # |
---|
| 270 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 271 | |
---|