Index: soft/giet_vm/giet_python/genmap
===================================================================
--- soft/giet_vm/giet_python/genmap	(revision 537)
+++ soft/giet_vm/giet_python/genmap	(revision 539)
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
 
-#######################################################################################
+###################################################################################
 #   file   : genmap
 #   date   : april 2014
 #   author : Alain Greiner
-#######################################################################################
+###################################################################################
 # This generic script maps one or several applications on a specific 
 # instance of the multi-processors/multi-clusters TSAR architecture. 
 # It generates the files required for hardware and software compilation:
 # 1) The "hard_config.h" file is used to generate the top.cpp file (hardware),
-#    and to compile the tsar_preloader.elf, the GietVM boot.elf and kernel.elf files.
+#    and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files.
 # 2) The optionals "map.bin" and vsegs.ld" files are used to configure the GietVM.
 # 3) The optional "netbsd.dts" file can be used to configure NetBSD.
@@ -16,5 +16,5 @@
 # 5) The optional "arch.bib" file can be used to configure ALMOS.
 # 6) An optional "map.xml" file can be generated for debug. 
-#######################################################################################
+###################################################################################
 # The hardware parameters  are:
 #  - x_size    : number of clusters in a row
@@ -23,10 +23,10 @@
 #  - nb_ttys   : number of TTY channels 
 #  - fbf_size  : frame buffer width & heigth
-#######################################################################################
+###################################################################################
 # The supported platforms are:
 # - tsar_generic_iob
 # - tsar_generic_leti
 # - tsar_geberic_mwmr
-#######################################################################################
+###################################################################################
 # The supported applications are:
 # - sort 
@@ -38,5 +38,5 @@
 # - gameoflife
 # - coproc
-#######################################################################################
+###################################################################################
 
 from optparse import OptionParser
@@ -45,7 +45,7 @@
 import sys
 
-######################################################################################
+###################################################################################
 #   define command line arguments   
-######################################################################################
+###################################################################################
 
 parser = OptionParser()
@@ -96,5 +96,5 @@
                    help = 'define pathname for the map.xml file' )
 
-############  supported applications   ###############################################
+############  supported applications   ############################################
 
 parser.add_option( '--transpose', action = 'store_true', dest = 'transpose',
@@ -130,7 +130,7 @@
                    help = 'map the "coproc" application for the GietVM' )
 
-######################################################################################
+###################################################################################
 #   Get command line arguments
-######################################################################################
+###################################################################################
 
 (options,args) = parser.parse_args()
@@ -163,7 +163,7 @@
 map_coproc     = options.coproc      # map "coproc" application if True
 
-######################################################################################
+###################################################################################
 #   build empty platform (no applications yet)
-######################################################################################
+###################################################################################
 
 if   ( arch_path == None  ):  
@@ -181,7 +181,7 @@
 print '[genmap] platform %s build' % mapping.name 
 
-######################################################################################
+###################################################################################
 #   complete mapping with application(s) as required
-######################################################################################
+###################################################################################
 
 if ( map_transpose ):
@@ -225,8 +225,8 @@
     print '[genmap] application "coproc" will be loaded'
 
-######################################################################################
+###################################################################################
 #   Generate xml file if required.
 #   It can be used for debug.
-######################################################################################
+###################################################################################
 
 if ( xml_path != None ):
@@ -236,8 +236,8 @@
     print '[genmap] %s generated for debug' % pathname
 
-######################################################################################
+###################################################################################
 #   Generate netbsd.dts file if required.
 #   It is used for NetBSD configuration.
-######################################################################################
+###################################################################################
 
 if ( (netbsd_path != None) and (arch_path != None) ):
@@ -247,8 +247,8 @@
     print '[genmap] %s generated' % pathname
 
-######################################################################################
+###################################################################################
 #   Generate linux.dts file if required.
 #   It is used for LINUX configuration.
-######################################################################################
+###################################################################################
 
 if ( (linux_path != None) and (arch_path != None) ):
@@ -258,8 +258,8 @@
     print '[genmap] %s generated' % pathname
 
-######################################################################################
+###################################################################################
 #   Generate arch.bib file if required.
 #   It is used for ALMOS configuration.
-######################################################################################
+###################################################################################
 
 if ( (almos_path != None) and (arch_path != None) ):
@@ -269,8 +269,8 @@
     print '[genmap] %s generated for almos' % pathname
 
-######################################################################################
+###################################################################################
 #   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
 #   They are used for GietVM compilation and configuration.
-######################################################################################
+###################################################################################
 
 if ( (giet_path != None) and (arch_path != None) ):
@@ -291,7 +291,7 @@
     print '[genmap] %s generated for giet_vm' % pathname
 
-######################################################################################
+###################################################################################
 #   Generate hard_config.h file if required.
-######################################################################################
+###################################################################################
 
 if ( hard_path != None ):
Index: soft/giet_vm/giet_python/mapping.py
===================================================================
--- soft/giet_vm/giet_python/mapping.py	(revision 537)
+++ soft/giet_vm/giet_python/mapping.py	(revision 539)
@@ -3,9 +3,9 @@
 import sys
 
-########################################################################################
+###################################################################################
 #   file   : giet_mapping.py
 #   date   : april 2014
 #   author : Alain Greiner
-########################################################################################
+###################################################################################
 #  This file contains the classes required to define a mapping for the GIET_VM.
 # - A 'Mapping' contains a set of 'Cluster'   (hardware architecture)
@@ -18,5 +18,5 @@
 #                        a set of 'Task'      (user parallel tasks)
 # - A 'Periph' contains  a set of 'Irq'       (only for XCU and PIC types )
-########################################################################################
+###################################################################################
 # Implementation Note
 # The objects used to describe a mapping are distributed in the PYTHON structure:
@@ -25,12 +25,12 @@
 # In the C binary data structure used by the giet_vm, all objects of same type
 # are stored in a linear array (one single array for all psegs for example).
-# For all objects, we compute and store in the  PYTHON object itself a "global index"
+# For all objects, we compute and store in the PYTHON object  a "global index"
 # corresponding to the index in this global array, and this index can be used as
 # a pseudo-pointer to identify a specific object of a given type.
-########################################################################################
-
-########################################################################################
+###################################################################################
+
+###################################################################################
 # Various constants 
-########################################################################################
+###################################################################################
 
 PADDR_WIDTH       = 40            # number of bits for physical address
@@ -38,14 +38,14 @@
 Y_WIDTH           = 4             # number of bits encoding y coordinate
 P_WIDTH           = 4             # number of bits encoding local proc_id
-VPN_ANTI_MASK     = 0x00000FFF    # mask virtual address to get offset in a small page 
-BPN_MASK          = 0xFFE00000    # mask virtual address to get the BPN (big page)
-PERI_INCREMENT    = 0x10000       # virtual address increment for replicated l vsegs
+VPN_ANTI_MASK     = 0x00000FFF    # mask vaddr to get offset in small page 
+BPN_MASK          = 0xFFE00000    # mask vaddr to get the BPN in big page
+PERI_INCREMENT    = 0x10000       # virtual address increment for replicated vsegs
 RESET_ADDRESS     = 0xBFC00000    # Processor wired boot_address
-MAPPING_SIGNATURE = 0xDACE2014    # Magic number indicating a valid C binary struture
-
-########################################################################################
+MAPPING_SIGNATURE = 0xDACE2014    # Magic number indicating a valid C BLOB
+
+###################################################################################
 # These lists must be consistent with values defined in
 # mapping_info.h / xml_driver.c /xml_parser.c
-########################################################################################
+###################################################################################
 PERIPHTYPES =    [
                   'CMA',
@@ -78,8 +78,8 @@
                  ]
    
-######################################################################################
+###################################################################################
 # These lists must be consistent with values defined in 
 # irq_handler.c / irq_handler.h / xml_driver.c / xml_parser.c
-######################################################################################
+###################################################################################
 IRQTYPES =       [
                   'HWI',
@@ -145,7 +145,7 @@
                  ]
 
-#######################################################################################
+###################################################################################
 class Mapping( object ):
-#######################################################################################
+###################################################################################
     def __init__( self,
                   name,                            # mapping name 
@@ -165,5 +165,5 @@
                   reset_address  = RESET_ADDRESS,  # Processor wired boot_address
                   ram_base       = 0,              # RAM physical base in cluster[0,0]
-                  ram_size       = 0 ):            # RAM size in each cluster (bytes)
+                  ram_size       = 0 ):            # RAM size per cluster (bytes)
 
         assert ( x_size <= (1<<X_WIDTH) )
@@ -606,6 +606,6 @@
     # end of cbin()
 
-    ##################################################################################
-    def giet_vsegs( self ):      # compute string for giet_vsegs.ld file generation
+    #######################################################################
+    def giet_vsegs( self ):      # compute string for giet_vsegs.ld file
                                  # required by giet_vm compilation
 
@@ -619,25 +619,25 @@
         for vseg in self.globs:
 
-            if ( vseg.name == 'seg_boot_code' ):
+            if ( vseg.name[0:13] == 'seg_boot_code' ):
                 boot_code_vbase      = vseg.vbase
                 boot_code_size       = vseg.length
                 boot_code_found      = True
 
-            if ( vseg.name == 'seg_boot_data' ):
+            if ( vseg.name[0:13] == 'seg_boot_data' ):
                 boot_data_vbase      = vseg.vbase
                 boot_data_size       = vseg.length
                 boot_data_found      = True
 
-            if ( vseg.name == 'seg_kernel_data' ):
+            if ( vseg.name[0:15] == 'seg_kernel_data' ):
                 kernel_data_vbase    = vseg.vbase
                 kernel_data_size     = vseg.length
                 kernel_data_found    = True
 
-            if ( vseg.name == 'seg_kernel_code' ):
+            if ( vseg.name[0:15] == 'seg_kernel_code' ):
                 kernel_code_vbase    = vseg.vbase
                 kernel_code_size     = vseg.length
                 kernel_code_found    = True
 
-            if ( vseg.name == 'seg_kernel_init' ):
+            if ( vseg.name[0:15] == 'seg_kernel_init' ):
                 kernel_init_vbase    = vseg.vbase
                 kernel_init_size     = vseg.length
@@ -692,6 +692,6 @@
         return s
 
-    ###################################################################################
-    def hard_config( self ):     # compute string for hard_config.h file generation,
+    ######################################################################
+    def hard_config( self ):     # compute string for hard_config.h file 
                                  # required by
                                  # - top.cpp compilation
@@ -1117,6 +1117,6 @@
     # end of hard_config()
 
-    ################################################################################
-    def linux_dts( self ):     # compute string for linux.dts file generation
+    #################################################################
+    def linux_dts( self ):     # compute string for linux.dts file
                                # used for linux configuration
         # header
@@ -1233,5 +1233,5 @@
                 if ( periph.ptype == 'TTY' ):
 
-                    # get HWI index to XCU or PIC (only TTY channel 0 is used by Linux)
+                    # get HWI index to XCU or PIC (only TTY0 is used by Linux)
                     hwi_id = 0xFFFFFFFF
                     for irq in irq_ctrl.irqs:
@@ -1274,5 +1274,6 @@
 
                     else:
-                        print '[genmap warning] in linux_dts() : %s' % (periph.subtype),
+                        print '[genmap warning] in linux_dts() : '
+                        print ' %s' % (periph.subtype),
                         print 'peripheral not supported by LINUX'
 
@@ -1283,6 +1284,6 @@
                 # other peripherals
                 else:
-                    print '[genmap warning] in linux_dts()'
-                    print '    %s peripheral not supported by LINUX' % (periph.ptype)
+                    print '[genmap warning] in linux_dts() : '
+                    print ' %s peripheral not supported by LINUX' % (periph.ptype)
 
         # clocks
@@ -1305,6 +1306,6 @@
 
 
-    #############################################################################
-    def netbsd_dts( self ):    # compute string for netbsd.dts file generation,
+    #################################################################
+    def netbsd_dts( self ):    # compute string for netbsd.dts file
                                # used for netbsd configuration
         # header
@@ -1322,5 +1323,6 @@
         for cluster in self.clusters:
             for proc in cluster.procs:
-                proc_id = (((cluster.x << self.y_width) + cluster.y) << self.p_width) + proc.lpid
+                proc_id = (((cluster.x << self.y_width) + cluster.y)
+                              << self.p_width) + proc.lpid
 
                 s += '    Mips,32@0x%x {\n'                % proc_id
@@ -1346,5 +1348,5 @@
                     s += '    cached      = <1>;\n'
                     s += '    device_type = "memory";\n'
-                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb, lsb, size)
+                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb,lsb,size)
                     s += '  };\n'
 
@@ -1366,5 +1368,5 @@
                     s += '  %s@0x%x {\n'  % (periph.pseg.name, periph.pseg.base)
                     s += '    device_type = "soclib:xicu:root";\n'
-                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb, lsb, size)
+                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb,lsb,size)
                     s += '    input_lines = <%d>;\n'    % periph.arg
                     s += '    ipis        = <%d>;\n'    % periph.arg
@@ -1430,5 +1432,6 @@
                         hwi_id = 0xFFFFFFFF
                         for irq in xcu.irqs:
-                            if ( (irq.isrtype == 'ISR_DMA') and (irq.channel == channel) ):
+                            if ( (irq.isrtype == 'ISR_DMA') and
+                                 (irq.channel == channel) ):
                                 hwi_id = irq.srcid
 
@@ -1472,5 +1475,5 @@
                     s += '  %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base)
                     s += '    device_type = "soclib:framebuffer";\n'
-                    s += '    mode        = <32>;\n'                    # bits par pixel
+                    s += '    mode        = <32>;\n'            # bits par pixel
                     s += '    width       = <%d>;\n'    % periph.arg
                     s += '    height      = <%d>;\n'    % periph.arg
@@ -1692,6 +1695,6 @@
         # end netbsd_dts()
 
-    ###########################
-    def almos_archinfo( self ):    # compute string for arch.info file generation,
+    ######################################################################
+    def almos_archinfo( self ):    # compute string for arch.info file 
                                    # used for almos configuration
         # header
@@ -1730,12 +1733,12 @@
                         # scan irqs
                         for irq in periph.irqs:
-                            if ( irq.isrtype == 'ISR_TTY_RX' ) : tty_irq_id = irq.srcid
-                            if ( irq.isrtype == 'ISR_BDV'    ) : bdv_irq_id = irq.srcid
-                            if ( irq.isrtype == 'ISR_DMA'    ) : dma_irq_id = irq.srcid
+                            if (irq.isrtype=='ISR_TTY_RX'): tty_irq_id = irq.srcid
+                            if (irq.isrtype=='ISR_BDV'   ): bdv_irq_id = irq.srcid
+                            if (irq.isrtype=='ISR_DMA'   ): dma_irq_id = irq.srcid
 
             # Build the cluster description
             s += '[CLUSTER]\n'
             s += '         CID=%d\n'        % cluster_id
-            s += '         ARCH_CID=0x%x\n' % ((cluster.x << self.y_width) + cluster.y)
+            s += '         ARCH_CID=0x%x\n' % ((cluster.x<<self.y_width)+cluster.y)
             s += '         CPU_NR=%d\n'     % nb_cpus
             s += '         DEV_NR=%d\n'     % nb_devs
@@ -1748,5 +1751,5 @@
                 irqid = -1
                 s += '         DEVID=RAM'
-                s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
+                s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % (base,size)
 
             # Handling peripherals
@@ -1758,5 +1761,5 @@
 
                     s += '         DEVID=XICU'
-                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size)
 
                 elif ( (periph.ptype == 'TTY')
@@ -1764,5 +1767,5 @@
 
                     s += '         DEVID=TTY'
-                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, tty_irq_id )
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,tty_irq_id)
 
                 elif ( (periph.ptype == 'DMA')
@@ -1770,10 +1773,10 @@
 
                     s += '         DEVID=DMA'
-                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, dma_irq_id )
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,dma_irq_id)
 
                 elif ( periph.ptype == 'FBF' ):
 
                     s += '         DEVID=FB'
-                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size )
 
                 elif ( (periph.ptype == 'IOC') and (periph.subtype == 'BDV')
@@ -1781,10 +1784,10 @@
 
                     s += '         DEVID=BLKDEV'
-                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, bdv_irq_id )
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,bdv_irq_id)
 
                 elif ( periph.ptype == 'PIC' ):
 
-                        s += '         DEVID=IOPIC'
-                        s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
+                    s += '         DEVID=IOPIC'
+                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size)
 
                 else:
@@ -1807,17 +1810,17 @@
 
 
-###########################################################################################
+###################################################################################
 class Cluster ( object ):
-###########################################################################################
+###################################################################################
     def __init__( self,
                   x,
                   y ):
 
-        self.index       = 0             # global index (set by Mapping constructor)
-        self.x           = x             # x coordinate
-        self.y           = y             # y coordinate
-        self.psegs       = []            # filled by addRam() or addPeriph()
-        self.procs       = []            # filled by addProc()
-        self.periphs     = []            # filled by addPeriph()
+        self.index       = 0           # global index (set by Mapping constructor)
+        self.x           = x           # x coordinate
+        self.y           = y           # y coordinate
+        self.psegs       = []          # filled by addRam() or addPeriph()
+        self.procs       = []          # filled by addProc()
+        self.periphs     = []          # filled by addPeriph()
 
         return
@@ -1835,5 +1838,5 @@
 
     #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Cluster
+    def cbin( self, mapping, verbose, expected ):  # C binary structure for Cluster
 
         if ( verbose ):
@@ -1843,5 +1846,6 @@
         if (self.index != expected):
             print '[genmap error] in Cluster.cbin()'
-            print '    cluster global index = %d / expected = %d' % (self.index,expected)
+            print '    cluster global index = %d / expected = %d' \
+                       % (self.index,expected)
             sys.exit(1)
 
@@ -1865,12 +1869,12 @@
 
         byte_stream = bytearray()
-        byte_stream += mapping.int2bytes( 4 , self.x )              # x coordinate
-        byte_stream += mapping.int2bytes( 4 , self.y )              # x coordinate
-        byte_stream += mapping.int2bytes( 4 , len( self.psegs ) )   # number psegs in cluster
-        byte_stream += mapping.int2bytes( 4 , pseg_id )             # first pseg global index
-        byte_stream += mapping.int2bytes( 4 , len( self.procs ) )   # number procs in cluster
-        byte_stream += mapping.int2bytes( 4 , proc_id )             # first proc global index
-        byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster
-        byte_stream += mapping.int2bytes( 4 , periph_id )           # first periph global index
+        byte_stream += mapping.int2bytes(4,self.x)            # x coordinate
+        byte_stream += mapping.int2bytes(4,self.y)            # x coordinate
+        byte_stream += mapping.int2bytes(4,len(self.psegs))   # psegs in cluster
+        byte_stream += mapping.int2bytes(4,pseg_id )          # global index
+        byte_stream += mapping.int2bytes(4,len(self.procs))   # procs in cluster
+        byte_stream += mapping.int2bytes(4,proc_id )          # global index
+        byte_stream += mapping.int2bytes(4,len(self.periphs)) # periphs in cluster
+        byte_stream += mapping.int2bytes(4, periph_id )       # global index
 
         if ( verbose ):
@@ -1884,7 +1888,7 @@
         return byte_stream
 
-########################################################################################
+##################################################################################
 class Vspace( object ):
-########################################################################################
+##################################################################################
     def __init__( self,
                   name,
@@ -1910,5 +1914,5 @@
 
     #############################################
-    def cbin( self, mapping, verbose, expected ):   # C binary structure for Vspace
+    def cbin( self, mapping, verbose, expected ):   # C binary for Vspace
 
         if ( verbose ):
@@ -1918,5 +1922,6 @@
         if (self.index != expected):
             print '[genmap error] in Vspace.cbin()'
-            print '    vspace global index = %d / expected = %d' %(self.index,expected)
+            print '    vspace global index = %d / expected = %d' \
+                        %(self.index,expected)
             sys.exit(1)
 
@@ -1928,5 +1933,6 @@
         if ( vseg_start_id == 0xFFFFFFFF ):
             print '[genmap error] in Vspace.cbin()'
-            print '    startname %s not found for vspace %s' %(self.startname,self.name)
+            print '    startname %s not found for vspace %s' \
+                        %(self.startname,self.name)
             sys.exit(1)
 
@@ -1940,10 +1946,10 @@
 
         byte_stream = bytearray()
-        byte_stream += mapping.str2bytes( 32, self.name )         # vspace name
-        byte_stream += mapping.int2bytes( 4,  vseg_start_id )     # vseg start_vector
-        byte_stream += mapping.int2bytes( 4,  nb_vsegs )          # number of vsegs
-        byte_stream += mapping.int2bytes( 4,  nb_tasks )          # number of tasks
-        byte_stream += mapping.int2bytes( 4,  first_vseg_id )     # first vseg global index
-        byte_stream += mapping.int2bytes( 4,  first_task_id )     # first task global index
+        byte_stream += mapping.str2bytes(32,self.name)         # vspace name
+        byte_stream += mapping.int2bytes(4, vseg_start_id)     # vseg start_vector
+        byte_stream += mapping.int2bytes(4, nb_vsegs)          # number of vsegs
+        byte_stream += mapping.int2bytes(4, nb_tasks)          # number of tasks
+        byte_stream += mapping.int2bytes(4, first_vseg_id)     # global index
+        byte_stream += mapping.int2bytes(4, first_task_id)     # global index
 
         if ( verbose ):
@@ -1956,7 +1962,7 @@
         return byte_stream
 
-########################################################################################
+##################################################################################
 class Task( object ):
-########################################################################################
+##################################################################################
     def __init__( self,
                   name,
@@ -1980,5 +1986,5 @@
         return
 
-    ################
+    ######################################
     def xml( self ):    # xml for one task
 
@@ -1996,14 +2002,16 @@
         return s
 
-    #####################################################
-    def cbin( self, mapping, verbose, expected, vspace ):  # C binary data structure for Task
+    ##########################################################################
+    def cbin( self, mapping, verbose, expected, vspace ):  # C binary for Task
 
         if ( verbose ):
-            print '*** cbin for task %s in vspace %s' % (self.name, vspace.name)
+            print '*** cbin for task %s in vspace %s' \
+                     % (self.name, vspace.name)
 
         # check index
         if (self.index != expected):
             print '[genmap error] in Task.cbin()'
-            print '    task global index = %d / expected = %d' %(self.index,expected)
+            print '    task global index = %d / expected = %d' \
+                        %(self.index,expected)
             sys.exit(1)
 
@@ -2037,11 +2045,11 @@
 
         byte_stream = bytearray()
-        byte_stream += mapping.str2bytes( 32, self.name )       # task name in vspace
-        byte_stream += mapping.int2bytes( 4,  cluster_id )      # cluster global index
-        byte_stream += mapping.int2bytes( 4,  self.p )          # processor local index 
-        byte_stream += mapping.int2bytes( 4,  self.trdid )      # thread local index in vspace
-        byte_stream += mapping.int2bytes( 4,  vseg_stack_id )   # stack vseg local index
-        byte_stream += mapping.int2bytes( 4,  vseg_heap_id )    # heap vseg local index
-        byte_stream += mapping.int2bytes( 4,  self.startid )    # index in start vector
+        byte_stream += mapping.str2bytes(32,self.name)     # task name in vspace
+        byte_stream += mapping.int2bytes(4, cluster_id)    # cluster global index
+        byte_stream += mapping.int2bytes(4, self.p)        # processor local index 
+        byte_stream += mapping.int2bytes(4, self.trdid)    # thread index in vspace
+        byte_stream += mapping.int2bytes(4, vseg_stack_id) # stack vseg local index
+        byte_stream += mapping.int2bytes(4, vseg_heap_id)  # heap vseg local index
+        byte_stream += mapping.int2bytes(4, self.startid)  # index in start vector
 
         if ( verbose ):
@@ -2055,7 +2063,7 @@
         return byte_stream
 
-########################################################################################
+##################################################################################
 class Vseg( object ):
-########################################################################################
+##################################################################################
     def __init__( self,
                   name,
@@ -2094,10 +2102,10 @@
         self.local    = local               # only mapped in local PTAB when true
         self.big      = big                 # to be mapped in a big physical page
-        self.binpath  = binpath             # path name for binary file (ELF or BLOB)
+        self.binpath  = binpath             # pathname for binary file (ELF or BLOB)
 
         return
 
-    ################
-    def xml( self ):  # xml for one vseg
+    ##################################
+    def xml( self ):  # xml for a vseg
 
         s =  '            <vseg name="%s"' %(self.name)
@@ -2118,6 +2126,6 @@
         return s
 
-    #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Vseg
+    #####################################################################
+    def cbin( self, mapping, verbose, expected ):    # C binary for Vseg
 
         if ( verbose ):
@@ -2165,16 +2173,16 @@
 
         byte_stream = bytearray()
-        byte_stream += mapping.str2bytes( 32, self.name )       # vseg name
-        byte_stream += mapping.str2bytes( 64, self.binpath )    # binpath
-        byte_stream += mapping.int2bytes( 4,  self.vbase )      # virtual base address
-        byte_stream += mapping.int2bytes( 8,  0 )               # physical base address
-        byte_stream += mapping.int2bytes( 4,  self.length )     # vseg size (bytes)
-        byte_stream += mapping.int2bytes( 4,  pseg_id )         # pseg global index
-        byte_stream += mapping.int2bytes( 4,  mode_id )         # CXWU flags
-        byte_stream += mapping.int2bytes( 4,  vtype_id )        # vseg type
-        byte_stream += mapping.int2bytes( 1,  0 )               # mapped when non zero
-        byte_stream += mapping.int2bytes( 1,  self.identity )   # identity mapping 
-        byte_stream += mapping.int2bytes( 1,  self.local )      # only mapped in local PTAB 
-        byte_stream += mapping.int2bytes( 1,  self.big )        # to be mapped in BPP 
+        byte_stream += mapping.str2bytes(32,self.name )     # vseg name
+        byte_stream += mapping.str2bytes(64,self.binpath )  # binpath
+        byte_stream += mapping.int2bytes(4, self.vbase )    # virtual base address
+        byte_stream += mapping.int2bytes(8, 0 )             # physical base address
+        byte_stream += mapping.int2bytes(4, self.length )   # vseg size (bytes)
+        byte_stream += mapping.int2bytes(4, pseg_id )       # pseg global index
+        byte_stream += mapping.int2bytes(4, mode_id )       # CXWU flags
+        byte_stream += mapping.int2bytes(4, vtype_id )      # vseg type
+        byte_stream += mapping.int2bytes(1, 0 )             # mapped when non zero
+        byte_stream += mapping.int2bytes(1, self.identity ) # identity mapping 
+        byte_stream += mapping.int2bytes(1, self.local )    # only in local PTAB 
+        byte_stream += mapping.int2bytes(1,  self.big )     # to be mapped in BPP 
 
         if ( verbose ):
@@ -2193,7 +2201,7 @@
         return byte_stream
 
-######################################################################################
+##################################################################################
 class Processor ( object ):
-######################################################################################
+##################################################################################
     def __init__( self,
                   x,
@@ -2208,18 +2216,20 @@
         return
 
-    ################
+    ########################################
     def xml( self ):   # xml for a processor
         return '            <proc index="%d" />\n' % (self.lpid)
 
-    #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Proc
+    ####################################################################
+    def cbin( self, mapping, verbose, expected ):    # C binary for Proc
 
         if ( verbose ):
-            print '*** cbin for proc %d in cluster (%d,%d)' % (self.lpid, self.x, self.y)
+            print '*** cbin for proc %d in cluster (%d,%d)' \
+                  % (self.lpid, self.x, self.y)
 
         # check index
         if (self.index != expected):
             print '[genmap error] in Proc.cbin()'
-            print '    proc global index = %d / expected = %d' % (self.index,expected)
+            print '    proc global index = %d / expected = %d' \
+                       % (self.index,expected)
             sys.exit(1)
 
@@ -2229,7 +2239,7 @@
         return byte_stream
 
-######################################################################################
+##################################################################################
 class Pseg ( object ):
-######################################################################################
+##################################################################################
     def __init__( self,
                   name,
@@ -2252,12 +2262,13 @@
         return
 
-    ################
+    ###################################
     def xml( self ):   # xml for a pseg
 
-        return '            <pseg name="%s" type="%s" base="0x%x" length="0x%x" />\n' \
-                % (self.name, self.segtype, self.base, self.size)
-
-    ######################################################
-    def cbin( self, mapping, verbose, expected, cluster ):    # C binary structure for Pseg
+        s = '            <pseg name="%s" type="%s" base="0x%x" length="0x%x" />\n' \
+                         % (self.name, self.segtype, self.base, self.size)
+        return s
+
+    ###########################################################################
+    def cbin( self, mapping, verbose, expected, cluster ):  # C binary for Pseg
 
         if ( verbose ):
@@ -2268,5 +2279,6 @@
         if (self.index != expected):
             print '[genmap error] in Pseg.cbin()'
-            print '    pseg global index = %d / expected = %d' % (self.index,expected)
+            print '    pseg global index = %d / expected = %d' \
+                       % (self.index,expected)
             sys.exit(1)
 
@@ -2282,10 +2294,10 @@
 
         byte_stream = bytearray()
-        byte_stream += mapping.str2bytes( 32, self.name )      # pseg name
-        byte_stream += mapping.int2bytes( 8 , self.base )      # physical base address
-        byte_stream += mapping.int2bytes( 8 , self.size )      # segment length
-        byte_stream += mapping.int2bytes( 4 , segtype_int )    # segment type
-        byte_stream += mapping.int2bytes( 4 , cluster.index )  # cluster global index
-        byte_stream += mapping.int2bytes( 4 , 0 )              # linked list of vsegs
+        byte_stream += mapping.str2bytes(32,self.name)     # pseg name
+        byte_stream += mapping.int2bytes(8 ,self.base)     # physical base address
+        byte_stream += mapping.int2bytes(8 ,self.size)     # segment length
+        byte_stream += mapping.int2bytes(4 ,segtype_int)   # segment type
+        byte_stream += mapping.int2bytes(4 ,cluster.index) # cluster global index
+        byte_stream += mapping.int2bytes(4 ,0)             # linked list of vsegs
 
         if ( verbose ):
@@ -2296,7 +2308,7 @@
         return byte_stream
 
-######################################################################################
+##################################################################################
 class Periph ( object ):
-######################################################################################
+##################################################################################
     def __init__( self,
                   pseg,               # associated pseg
@@ -2304,8 +2316,8 @@
                   subtype  = 'NONE',  # peripheral subtype
                   channels = 1,       # for multi-channels peripherals
-                  arg0     = 0,       # optional argument (semantic depends on ptype)
-                  arg1     = 0,       # optional argument (semantic depends on ptype)
-                  arg2     = 0,       # optional argument (semantic depends on ptype)
-                  arg3     = 0 ):     # optional argument (semantic depends on ptype)
+                  arg0     = 0,       # optional (semantic depends on ptype)
+                  arg1     = 0,       # optional (semantic depends on ptype)
+                  arg2     = 0,       # optional (semantic depends on ptype)
+                  arg3     = 0 ):     # optional (semantic depends on ptype)
 
         self.index    = 0            # global index ( set by addPeriph() )
@@ -2321,5 +2333,5 @@
         return
 
-    ################
+    ######################################
     def xml( self ):    # xml for a periph
 
@@ -2340,6 +2352,6 @@
         return s
 
-    #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Periph
+    ######################################################################
+    def cbin( self, mapping, verbose, expected ):    # C binary for Periph
 
         if ( verbose ):
@@ -2350,5 +2362,6 @@
         if (self.index != expected):
             print '[genmap error] in Periph.cbin()'
-            print '    periph global index = %d / expected = %d' % (self.index,expected)
+            print '    periph global index = %d / expected = %d' \
+                       % (self.index,expected)
             sys.exit(1)
 
@@ -2382,14 +2395,14 @@
         
         byte_stream = bytearray()
-        byte_stream += mapping.int2bytes( 4 , ptype_id )         # peripheral type
-        byte_stream += mapping.int2bytes( 4 , subtype_id )       # peripheral subtype
-        byte_stream += mapping.int2bytes( 4 , pseg_id )          # pseg global index
-        byte_stream += mapping.int2bytes( 4 , self.channels )    # number of channels
-        byte_stream += mapping.int2bytes( 4 , self.arg0 )        # optionnal arg0
-        byte_stream += mapping.int2bytes( 4 , self.arg1 )        # optionnal arg1
-        byte_stream += mapping.int2bytes( 4 , self.arg2 )        # optionnal arg2
-        byte_stream += mapping.int2bytes( 4 , self.arg3 )        # optionnal arg3
-        byte_stream += mapping.int2bytes( 4 , len( self.irqs ) ) # number of input irqs
-        byte_stream += mapping.int2bytes( 4 , irq_id )           # first irq global index
+        byte_stream += mapping.int2bytes(4,ptype_id)       # peripheral type
+        byte_stream += mapping.int2bytes(4,subtype_id)     # peripheral subtype
+        byte_stream += mapping.int2bytes(4,pseg_id)        # pseg global index
+        byte_stream += mapping.int2bytes(4,self.channels)  # number of channels
+        byte_stream += mapping.int2bytes(4,self.arg0)      # optionnal arg0
+        byte_stream += mapping.int2bytes(4,self.arg1)      # optionnal arg1
+        byte_stream += mapping.int2bytes(4,self.arg2)      # optionnal arg2
+        byte_stream += mapping.int2bytes(4,self.arg3)      # optionnal arg3
+        byte_stream += mapping.int2bytes(4,len(self.irqs)) # number of input irqs
+        byte_stream += mapping.int2bytes( 4 , irq_id )     # global index
 
         if ( verbose ):
@@ -2401,7 +2414,7 @@
         return byte_stream
 
-######################################################################################
+##################################################################################
 class Irq ( object ):
-######################################################################################
+##################################################################################
     def __init__( self,
                   irqtype,         # input IRQ type : HWI / WTI / PTI (for XCU only)
@@ -2421,12 +2434,13 @@
         return
 
-    ################
+    ################################
     def xml( self ):   # xml for Irq
 
-        return '                <irq srctype="%s" srcid="%d" isr="%s" channel="%d" />\n' \
+        s = '                <irq srctype="%s" srcid="%d" isr="%s" channel="%d" />\n' \
                 % ( self.irqtype, self.srcid, self.isrtype, self.channel )
-
-    #############################################
-    def cbin( self, mapping, verbose, expected ):     # C binary structure for Irq
+        return s
+
+    ####################################################################
+    def cbin( self, mapping, verbose, expected ):     # C binary for Irq
 
         if ( verbose ):
@@ -2436,5 +2450,6 @@
         if (self.index != expected):
             print '[genmap error] in Irq.cbin()'
-            print '    irq global index = %d / expected = %d' % (self.index,expected)
+            print '    irq global index = %d / expected = %d' \
+                       % (self.index,expected)
             sys.exit(1)
 
