Changeset 520 for soft/giet_vm
- Timestamp:
- Mar 10, 2015, 3:12:37 PM (10 years ago)
- Location:
- soft/giet_vm/giet_python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_python/genmap
r500 r520 6 6 # author : Alain Greiner 7 7 ####################################################################################### 8 # This generic script maps one or several multi-tasksapplications on a specific8 # This generic script maps one or several applications on a specific 9 9 # instance of the multi-processors/multi-clusters TSAR architecture. 10 10 # It generates the files required for hardware and software compilation: 11 # 1) The "hard_config.h" file is used to generate the top.cpp netbsdfile (hardware),11 # 1) The "hard_config.h" file is used to generate the top.cpp file (hardware), 12 12 # and to compile the tsar_preloader.elf, the GietVM boot.elf and kernel.elf files. 13 13 # 2) The optionals "map.bin" and vsegs.ld" files are used to configure the GietVM. … … 27 27 # - tsar_generic_iob 28 28 # - tsar_generic_leti 29 # - tsar_geberic_mwmr 29 30 ####################################################################################### 30 31 # The supported applications are: … … 36 37 # - display 37 38 # - gameoflife 39 # - coproc 38 40 ####################################################################################### 39 41 … … 123 125 default = False, 124 126 help = 'map the "gameoflife" application for the GietVM' ) 127 128 parser.add_option( '--coproc', action = 'store_true', dest = 'coproc', 129 default = False, 130 help = 'map the "coproc" application for the GietVM' ) 125 131 126 132 ###################################################################################### … … 155 161 map_classif = options.classif # map "classif" application if True 156 162 map_gameoflife = options.gameoflife # map "gameoflife" application if True 163 map_coproc = options.coproc # map "coproc" application if True 157 164 158 165 ###################################################################################### … … 213 220 print '[genmap] application "gameoflife" will be loaded' 214 221 222 if ( map_coproc ): 223 app = __import__( 'coproc' ) 224 app.coproc( mapping ) 225 print '[genmap] application "coproc" will be loaded' 226 215 227 ###################################################################################### 216 228 # Generate xml file if required. -
soft/giet_vm/giet_python/mapping.py
r517 r520 10 10 # This file contains the classes required to define a mapping for the GIET_VM. 11 11 # - A 'Mapping' contains a set of 'Cluster' (hardware architecture) 12 # a set of 'Vseg' (kernel virtual segments, called globals)13 # a set of 'Vspace' (one or several user applications) .12 # a set of 'Vseg' (kernel glogals virtual segments) 13 # a set of 'Vspace' (one or several user applications) 14 14 # - A 'Cluster' contains a set of 'Pseg' (physical segments in cluster) 15 15 # a set of 'Proc' (processors in cluster) 16 16 # a set of 'Periph' (peripherals in cluster) 17 # a set of 'Coproc' (coprocessors in cluster)18 17 # - A 'Vspace' contains a set of 'Vseg' (user virtual segments) 19 18 # a set of 'Task' (user parallel tasks) 20 19 # - A 'Periph' contains a set of 'Irq' (only for XCU and PIC types ) 21 # - A 'Coproc' contains a set of 'Cpports' (one port per MWMR channel)22 20 ######################################################################################## 23 21 # Implementation Note … … 42 40 VPN_ANTI_MASK = 0x00000FFF # mask virtual address to get offset in a small page 43 41 BPN_MASK = 0xFFE00000 # mask virtual address to get the BPN (big page) 44 PERI_INCREMENT = 0x10000 # virtual address increment for replicated global vsegs42 PERI_INCREMENT = 0x10000 # virtual address increment for replicated l vsegs 45 43 RESET_ADDRESS = 0xBFC00000 # Processor wired boot_address 46 44 MAPPING_SIGNATURE = 0xDACE2014 # Magic number indicating a valid C binary struture 47 45 48 46 ######################################################################################## 49 # These global lists must be consistent with enums in mapping_info.h or irq_handler. 47 # These lists must be consistent with values defined in 48 # mapping_info.h / xml_driver.c /xml_parser.c 50 49 ######################################################################################## 51 50 PERIPHTYPES = [ … … 67 66 ] 68 67 69 PERIPHSUBTYPES =[68 IOCSUBTYPES = [ 70 69 'BDV', 71 70 'HBA', … … 74 73 ] 75 74 75 MWRSUBTYPES = [ 76 'GCD', 77 'DCT', 78 ] 79 80 ###################################################################################### 81 # These lists must be consistent with values defined in 82 # irq_handler.c / irq_handler.h / xml_driver.c / xml_parser.c 83 ###################################################################################### 76 84 IRQTYPES = [ 77 85 'HWI', … … 94 102 'ISR_DMA', 95 103 'ISR_SPI', 104 'ISR_MWR' 96 105 ] 97 106 … … 132 141 PSEGTYPES = [ 133 142 'RAM', 134 'ROM', # deprecated => use PERI135 143 'PERI', 136 ]137 138 CP_PORT_DIRS = [139 'TO_COPROC',140 'FROM_COPROC',141 144 ] 142 145 … … 194 197 self.total_procs = 0 195 198 self.total_irqs = 0 196 self.total_coprocs = 0197 self.total_cpports = 0198 199 self.total_periphs = 0 199 200 … … 247 248 subtype = 'NONE', # peripheral subtype 248 249 channels = 1, # number of channels 249 arg = 0 ): # optional argument (semantic depends on ptype) 250 arg0 = 0, # optional argument (semantic depends on ptype) 251 arg1 = 0, # optional argument (semantic depends on ptype) 252 arg2 = 0, # optional argument (semantic depends on ptype) 253 arg3 = 0 ): # optional argument (semantic depends on ptype) 250 254 251 255 # computes cluster index and coordinates from the base address … … 261 265 assert ptype in PERIPHTYPES 262 266 263 assert subtype in PERIPHSUBTYPES 267 if (ptype == 'IOC'): assert subtype in IOCSUBTYPES 268 if (ptype == 'MWR'): assert subtype in MWRSUBTYPES 264 269 265 270 # add one pseg into mapping … … 270 275 271 276 # add one periph into mapping 272 periph = Periph( pseg, ptype, subtype, channels, arg )277 periph = Periph( pseg, ptype, subtype, channels, arg0, arg1, arg2, arg3 ) 273 278 self.clusters[cluster_id].periphs.append( periph ) 274 279 periph.index = self.total_periphs … … 300 305 x, # cluster x coordinate 301 306 y, # cluster y coordinate 302 p ):# processor local index307 lpid ): # processor local index 303 308 304 309 assert (x < self.x_size) and (y < self.y_size) … … 307 312 308 313 # add one proc into mapping 309 proc = Processor( x, y, p)314 proc = Processor( x, y, lpid ) 310 315 self.clusters[cluster_id].procs.append( proc ) 311 316 proc.index = self.total_procs … … 313 318 314 319 return proc 315 316 ############################## add a coprocessor in a cluster317 def addCoproc( self,318 name, # associated pseg name319 base, # associated pseg base address320 size ): # associated pseg length321 322 # check cluster coordinates (obtained from the base address)323 cluster_xy = base >> (self.paddr_width - self.x_width - self.y_width)324 x = cluster_xy >> (self.y_width);325 y = cluster_xy & ((1 << self.y_width) - 1)326 327 assert (x < self.x_size) and (y < self.y_size)328 329 cluster_id = (x * self.y_size) + y330 331 # add one pseg into mapping332 pseg = Pseg( name, base, size, x, y, 'PERI' )333 self.clusters[cluster_id].psegs.append( pseg )334 pseg.index = self.total_psegs335 self.total_psegs += 1336 337 # add one coproc into mapping338 periph = Coproc( pseg )339 self.clusters[cluster_id].coprocs.append( coproc )340 periph.index = self.total_coprocs341 self.total_coprocs += 1342 343 return coproc344 345 ################################## add a port in a coprocessor346 def addPort( self,347 coproc, # coprocessor containing the port348 direction, # direction (TO_COPROC / FROM_COPROC)349 vspacename, # name of vspace using the coproc350 mwmrname ): # name of the vseg containing the MWMR channel351 352 assert direction in CP_PORT_DIRS353 354 # add one cpport into mapping355 port = Cpport( direction, vspacename, mwmrname )356 coproc.ports.append( port )357 port.index = self.total_cpports358 self.total_cpports += 1359 360 return port361 320 362 321 ############################ add one global vseg into mapping … … 547 506 byte_stream += self.int2bytes(4, self.total_procs) 548 507 byte_stream += self.int2bytes(4, self.total_irqs) 549 byte_stream += self.int2bytes(4, self.total_coprocs)550 byte_stream += self.int2bytes(4, self.total_cpports)551 508 byte_stream += self.int2bytes(4, self.total_periphs) 552 509 byte_stream += self.str2bytes(32, self.name) … … 570 527 print 'total_procs = %d' % self.total_procs 571 528 print 'total_irqs = %d' % self.total_irqs 572 print 'total_coprocs = %d' % self.total_coprocs573 print 'total_cpports = %d' % self.total_cpports574 529 print 'total_periphs = %d' % self.total_periphs 575 530 print '\n' … … 640 595 if ( verbose ): print '\n' 641 596 642 # coprocs array643 index = 0644 for cluster in self.clusters:645 for coproc in cluster.coprocs:646 byte_stream += coproc.cbin( self, verbose, index )647 index += 1648 649 if ( verbose ): print '\n'650 651 # cpports array652 index = 0653 for cluster in self.clusters:654 for coproc in cluster.coprocs:655 for port in coproc.ports:656 byte_stream += port.cbin( self, verbose, index )657 index += 1658 659 if ( verbose ): print '\n'660 661 597 # periphs array 662 598 index = 0 … … 778 714 nb_fbf = 0 779 715 fbf_channels = 0 780 fbf_arg = 0781 716 seg_fbf_base = 0xFFFFFFFF 782 717 seg_fbf_size = 0 718 fbf_arg0 = 0 719 fbf_arg1 = 0 783 720 784 721 nb_iob = 0 … … 801 738 seg_mwr_base = 0xFFFFFFFF 802 739 seg_mwr_size = 0 740 mwr_arg0 = 0 741 mwr_arg1 = 0 742 mwr_arg2 = 0 743 mwr_arg3 = 0 803 744 804 745 nb_nic = 0 … … 834 775 nb_xcu = 0 835 776 xcu_channels = 0 836 xcu_arg = 0837 777 seg_xcu_base = 0xFFFFFFFF 838 778 seg_xcu_size = 0 779 xcu_arg0 = 0 839 780 840 781 nb_drom = 0 … … 866 807 seg_fbf_size = periph.pseg.size 867 808 fbf_channels = periph.channels 868 fbf_arg = periph.arg 809 fbf_arg0 = periph.arg0 810 fbf_arg1 = periph.arg1 869 811 nb_fbf +=1 870 812 … … 895 837 elif ( periph.ptype == 'MWR' ): 896 838 seg_mwr_base = periph.pseg.base & 0xFFFFFFFF 897 seg_ wmr_size = periph.pseg.size839 seg_mwr_size = periph.pseg.size 898 840 mwr_channels = periph.channels 841 mwr_arg0 = periph.arg0 842 mwr_arg1 = periph.arg1 843 mwr_arg2 = periph.arg2 844 mwr_arg3 = periph.arg3 899 845 nb_mwr +=1 900 846 … … 945 891 seg_xcu_size = periph.pseg.size 946 892 xcu_channels = periph.channels 947 xcu_arg = periph.arg893 xcu_arg0 = periph.arg0 948 894 nb_xcu +=1 949 895 … … 1078 1024 s += '#define USE_IOC_RDK %d\n' % self.use_ramdisk 1079 1025 s += '\n' 1080 s += '#define FBUF_X_SIZE %d\n' % fbf_arg 1081 s += '#define FBUF_Y_SIZE %d\n' % fbf_arg 1082 s += '\n' 1083 s += '#define XCU_NB_INPUTS %d\n' % xcu_arg 1026 s += '#define FBUF_X_SIZE %d\n' % fbf_arg0 1027 s += '#define FBUF_Y_SIZE %d\n' % fbf_arg1 1028 s += '\n' 1029 s += '#define XCU_NB_INPUTS %d\n' % xcu_arg0 1030 s += '\n' 1031 s += '#define MWR_TO_COPROC %d\n' % mwr_arg0 1032 s += '#define MWR_FROM_COPROC %d\n' % mwr_arg1 1033 s += '#define MWR_CONFIG %d\n' % mwr_arg2 1034 s += '#define MWR_STATUS %d\n' % mwr_arg3 1084 1035 s += '\n' 1085 1036 … … 1764 1715 nb_cpus = len( cluster.procs ) 1765 1716 nb_devs = len( cluster.periphs ) 1766 if ( len( cluster.coprocs ) != 0 ):1767 print 'Error in almos_archinfo() coprocessors not supported yet'1768 sys.exit(1)1769 1717 1770 1718 # search a RAM … … 1873 1821 self.psegs = [] # filled by addRam() or addPeriph() 1874 1822 self.procs = [] # filled by addProc() 1875 self.coprocs = [] # filled by addCoproc()1876 1823 self.periphs = [] # filled by addPeriph() 1877 1824 … … 1884 1831 for pseg in self.psegs: s += pseg.xml() 1885 1832 for proc in self.procs: s += proc.xml() 1886 for copr in self.coprocs: s += copr.xml()1887 1833 for peri in self.periphs: s += peri.xml() 1888 1834 s += ' </cluster>\n' … … 1913 1859 else: 1914 1860 proc_id = 0 1915 1916 # compute global index for first coproc1917 if ( len(self.coprocs) > 0 ):1918 coproc_id = self.coprocs[0].index1919 else:1920 coproc_id = 01921 1861 1922 1862 # compute global index for first periph … … 1933 1873 byte_stream += mapping.int2bytes( 4 , len( self.procs ) ) # number procs in cluster 1934 1874 byte_stream += mapping.int2bytes( 4 , proc_id ) # first proc global index 1935 byte_stream += mapping.int2bytes( 4 , len( self.coprocs ) ) # number coprocs in cluster1936 byte_stream += mapping.int2bytes( 4 , coproc_id ) # first coproc global index1937 1875 byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster 1938 1876 byte_stream += mapping.int2bytes( 4 , periph_id ) # first periph global index … … 1943 1881 print 'nb_procs = %d' % len( self.procs ) 1944 1882 print 'proc_id = %d' % proc_id 1945 print 'nb_coprocs = %d' % len( self.coprocs )1946 print 'coproc_id = %d' % coproc_id1947 1883 print 'nb_periphs = %d' % len( self.periphs ) 1948 1884 print 'periph_id = %d' % periph_id … … 2370 2306 subtype = 'NONE', # peripheral subtype 2371 2307 channels = 1, # for multi-channels peripherals 2372 arg = 0 ): # optional argument (semantic depends on ptype) 2373 2374 assert ptype in PERIPHTYPES 2375 2376 assert subtype in PERIPHSUBTYPES 2308 arg0 = 0, # optional argument (semantic depends on ptype) 2309 arg1 = 0, # optional argument (semantic depends on ptype) 2310 arg2 = 0, # optional argument (semantic depends on ptype) 2311 arg3 = 0 ): # optional argument (semantic depends on ptype) 2377 2312 2378 2313 self.index = 0 # global index ( set by addPeriph() ) … … 2380 2315 self.ptype = ptype 2381 2316 self.subtype = subtype 2382 self.arg = arg 2317 self.arg0 = arg0 2318 self.arg1 = arg1 2319 self.arg2 = arg2 2320 self.arg3 = arg3 2383 2321 self.pseg = pseg 2384 2322 self.irqs = [] … … 2392 2330 s += ' psegname="%s"' % self.pseg.name 2393 2331 s += ' channels="%d"' % self.channels 2394 s += ' arg="%d" >\n' % self.arg 2332 s += ' arg0="%d"' % self.arg0 2333 s += ' arg1="%d"' % self.arg1 2334 s += ' arg2="%d"' % self.arg2 2335 s += ' arg3="%d"' % self.arg3 2395 2336 if ( (self.ptype == 'PIC') or (self.ptype == 'XCU') ): 2337 s += ' >\n' 2396 2338 for irq in self.irqs: s += irq.xml() 2397 s += ' </periph>\n' 2398 2339 s += ' </periph>\n' 2340 else: 2341 s += ' />\n' 2399 2342 return s 2400 2343 … … 2433 2376 # compute numerical value for subtype 2434 2377 subtype_id = 0xFFFFFFFF 2435 for x in xrange( len(PERIPHSUBTYPES) ): 2436 if ( self.subtype == PERIPHSUBTYPES[x] ): subtype_id = x 2437 2438 # compute 2378 if (self.ptype == 'IOC'): 2379 for x in xrange( len(IOCSUBTYPES) ): 2380 if ( self.subtype == IOCSUBTYPES[x] ): subtype_id = x 2381 if (self.ptype == 'MWR'): 2382 for x in xrange( len(MWRSUBTYPES) ): 2383 if ( self.subtype == MWRSUBTYPES[x] ): subtype_id = x 2384 2439 2385 byte_stream = bytearray() 2440 2386 byte_stream += mapping.int2bytes( 4 , ptype_id ) # peripheral type … … 2442 2388 byte_stream += mapping.int2bytes( 4 , pseg_id ) # pseg global index 2443 2389 byte_stream += mapping.int2bytes( 4 , self.channels ) # number of channels 2444 byte_stream += mapping.int2bytes( 4 , self.arg ) # optionnal argument 2390 byte_stream += mapping.int2bytes( 4 , self.arg0 ) # optionnal arg0 2391 byte_stream += mapping.int2bytes( 4 , self.arg1 ) # optionnal arg1 2392 byte_stream += mapping.int2bytes( 4 , self.arg2 ) # optionnal arg2 2393 byte_stream += mapping.int2bytes( 4 , self.arg3 ) # optionnal arg3 2445 2394 byte_stream += mapping.int2bytes( 4 , len( self.irqs ) ) # number of input irqs 2446 2395 byte_stream += mapping.int2bytes( 4 , irq_id ) # first irq global index … … 2448 2397 if ( verbose ): 2449 2398 print 'ptype = %d' % ptype_id 2399 print 'subtype = %d' % subtype_id 2450 2400 print 'pseg_id = %d' % pseg_id 2451 2401 print 'nb_irqs = %d' % len( self.irqs ) … … 2527 2477 return byte_stream 2528 2478 2529 ######################################################################################2530 class Coproc ( object ):2531 ######################################################################################2532 def __init__( self,2533 pseg ): # associated pseg2534 2535 self.index = 0 # global index value set by addCoproc()2536 self.pseg = pseg2537 self.ports = []2538 2539 return2540 2541 ################2542 def xml( self ): # xml for Coproc2543 2544 print '[genmap error] in Coproc.xml() : not defined yet'2545 sys.exit(1)2546 2547 return2548 2549 #############################################2550 def cbin( self, mapping, verbose, expected ): # C binary structure for Coproc2551 2552 if ( verbose ):2553 print '*** cbin for coproc in cluster (%d,%d)' % (self.pseg.x, self.pseg.y)2554 2555 # check index2556 if (self.index != expected):2557 print '[genmap error] in Coproc.cbin()'2558 print ' coproc global index = %d / expected = %d' % (self.index,expected)2559 sys.exit(1)2560 2561 # compute pseg global index2562 pseg_id = self.pseg.index2563 2564 # compute first port global index2565 port_id = self.ports[0].index2566 2567 byte_stream = bytearray()2568 byte_stream += mapping.str2bytes( 32, self.pseg.name ) # probablement inutile (AG)2569 byte_stream += mapping.int2bytes( 4 , pseg_id ) # pseg global index2570 byte_stream += mapping.int2bytes( 4 , len( self.ports ) ) # number of input irqs2571 byte_stream += mapping.int2bytes( 4 , port_id ) # first port global index2572 2573 if ( verbose ):2574 print 'irqtype = %s' % self.irqtype2575 print 'pseg_id = %d' % pseg_id2576 print 'nb_ports = %d' % len( self.ports )2577 print 'port_id %d' % port_id2578 2579 return byte_stream2580 2581 ######################################################################################2582 class Cpport ( object ):2583 ######################################################################################2584 def __init__( self,2585 direction,2586 vspacename,2587 mwmrname ):2588 2589 self.index = 0 # global index ( set by addCpport() )2590 self.direction = direction # TO_COPROC / FROM_COPROC2591 self.vspacename = vspacename # name of vspace containing mwmr channel2592 self.mwmrname = mwmrname # name of vseg defining mwmr channel2593 2594 return2595 2596 ################2597 def xml( self ): # xml for Cpport2598 2599 print '[genmap error] in Cpport.xml() : not defined yet'2600 sys.exit(1)2601 2602 return2603 2604 #############################################2605 def cbin( self, mapping, verbose, expected ): # C binary structure for Cpport2606 2607 if ( verbose ):2608 print '*** cbin for cpport[%d]' % (self.index)2609 2610 # check index2611 if ( self.index != expected ):2612 print '[genmap error] in Cpport.cbin()'2613 print ' port global index = %d / expected = %d' % (self.index,expected)2614 sys.exit(1)2615 2616 # compute numerical value for direction2617 if ( self.direction == 'TO_COPROC' ):2618 dir_int = 02619 else:2620 dir_int = 12621 2622 # compute vspace global index2623 vspace_id = 0xFFFFFFFF2624 for vspace in mapping.vspaces:2625 if ( self.vspacename == vspace.name ): vspace_id = vspace.index2626 2627 if (vspace_id == 0xFFFFFFFF):2628 print '[genmap error] in Cpport.cbin()'2629 print ' vspace name %s not found' % ( self.vspacename )2630 sys.exit(1)2631 2632 # compute mwmr vseg global index2633 mwmr_id = 0xFFFFFFFF2634 for vseg in mapping.vspace[vspace_id].vsegs:2635 if (self.mwmrname == vseg.name): mwmr_id = vseg.index2636 2637 if (mwmr_id == 0xFFFFFFFF):2638 print '[genmap error] in Cpport.cbin()'2639 print ' mwmr vseg name %s not found in vspace %s' \2640 % ( self.mwmrname, self.vspacename )2641 sys.exit(1)2642 2643 byte_stream = bytearray()2644 byte_stream += mapping.int2bytes( 4 , dir_int ) # pseg global index2645 byte_stream += mapping.int2bytes( 4 , vspace_id ) # vspace global index2646 byte_stream += mapping.int2bytes( 4 , mwmr_id ) # mwmr vseg global index2647 2648 if ( verbose ):2649 print 'direction = %s' % self.direction2650 print 'vspace_id = %d' % vspace_id2651 print 'mwmr_id = %d' % mwmr_id2652 2653 return byte_stream2654 2655 2656 2479 # Local Variables: 2657 2480 # tab-width: 4;
Note: See TracChangeset
for help on using the changeset viewer.