Ignore:
Timestamp:
Oct 21, 2015, 11:48:40 AM (9 years ago)
Author:
meunier
Message:
  • Update the scripts to use a common file hard_params.py in both gen_arch_info and gen_hdd
  • Adding the P_WIDTH parameter in the topcell
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/platforms/tsar_generic_xbar/scripts/gen_arch_info.py

    r1012 r1023  
    11#--------------------------------------------------------------------
    2 # File      : gen_arch_info_large.sh
     2# File      : gen_arch_info.py
    33#--------------------------------------------------------------------
    44
     
    88import sys
    99
    10 X_MAX = 0
    11 Y_MAX = 0
    12 CPU_PER_CLUSTER = 0
    13 BSCPU = 0
    14 BSTTY = 0
    15 BSDMA = 0
    16 MEMC_SIZE = 0
    17 P_WDITH = 4
    18 NB_TTY = 4
    19 TTY_CHANNEL_SIZE = 0X00000010
    20 TTY_SIZE = 0X00001000
    21 OUTPUT_IRQ_PER_PROC = 4
    22 DMA_SIZE = 0X00001000
    23 XCU_SIZE = 0X00001000
    24 BDV_SIZE = 0X00001000
    25 FBF_SIZE = 0X00200000
    2610
    27 MEMC_TGTID = 0
    28 XICU_TGTID = 1
    29 MDMA_TGTID = 2
    30 MTTY_TGTID = 3
    31 BDEV_TGTID = 4
    32 MNIC_TGTID = 5
    33 BROM_TGTID = 6
    34 CDMA_TGTID = 7
    35 SIMH_TGTID = 8
    36 FBUF_TGTID = 9
     11exec(file("hard_params.py"))
     12
     13def print_comments(cmd, x, y, cpu_per_cluster, bscpu):
     14    print "# TSAR hardware description in BIB (Boot Information Block) format"
     15    print "# This file is autogenerated by the command: " + cmd +  " %d %d %d %d" % (x, y, cpu_per_cluster, bscpu)
     16    print "# It is ready to be passed to info2bib utility so the binary format can be generated"
     17    print " "
     18    print "# " + getpass.getuser() + " on " + socket.gethostname() + " " + time.strftime("%H:%M:%S")
     19    print " "
     20    print " "
     21       
     22def print_header(x, y, bscpu, bstty, bsdma):
     23    print "[HEADER]"
     24    print "        REVISION=1"
     25    print "        ARCH=SOCLIB-TSAR"
     26    print "        XMAX=%d" % x
     27    print "        YMAX=%d" % y
     28    print "        BSCPU=%d" % bscpu
     29    print "        BSTTY=0x%x" % bstty
     30    print "        BSDMA=0x%x" % bsdma
     31    print " "
     32    print " "
    3733
    3834
    39 # PHYSICAL ADDRESS WIDTH
    40 ADDR_WIDTH = 32
     35def print_cluster(x, y, x_width, y_width, cpu_per_cluster):
     36    mem_addr = ram_addr(x, y, x_width, y_width)
     37    mem_size = ram_size(x_width, y_width)
     38    xcu_base = replicated_periph_base_addr(x_width, y_width, XCU_TGTID)
     39    dma_base = replicated_periph_base_addr(x_width, y_width, DMA_TGTID)
     40    xcu_addr = replicated_periph_addr(x, y, x_width, y_width, xcu_base)
     41    dma_addr = replicated_periph_addr(x, y, x_width, y_width, dma_base)
     42    print "[CLUSTER]"
    4143
    42 # DEFAULT VALUES
    43 DEFAULT_X_MAX = 8
    44 DEFAULT_Y_MAX = 8
    45 DEFAULT_CPU_PER_CLUSTER = 4
    46 CLUSTER_INC = 0
     44    cid = x * (1 << y_width) + y
     45    cpu_num = 0;
     46    while (cpu_num != cpu_per_cluster):
     47        gid = (cid << P_WIDTH) + cpu_num
     48        print "        [CPU]    ID=%d    OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC))
     49        cpu_num += 1
     50   
     51    print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_addr, mem_size)
     52    print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_addr, DMA_SIZE)
     53    print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_addr, XCU_SIZE)
     54    print " "
     55    print " "
    4756
    48 def print_comments(cmd):
    49         print "# TSAR hardware description in BIB (Boot Information Block) format"
    50         print "# This file is autogenerated by the command: " + cmd +  " %d %d %d %d" % (X_MAX, Y_MAX, CPU_PER_CLUSTER, BSCPU)
    51         print "# It is ready to be passed to info2bib utility so the binary format can be generated"
    52         print " "
    53         print "# " + getpass.getuser() + " on " + socket.gethostname() + " " + time.strftime("%H:%M:%S")
    54         print " "
    55         print " "
    56        
    57 def print_header():
    58         print "[HEADER]"
    59         print "        REVISION=1"
    60         print "        ARCH=SOCLIB-TSAR"
    61         print "        XMAX=%d" % X_MAX
    62         print "        YMAX=%d" % Y_MAX
    63         print "        BSCPU=%d" % BSCPU
    64         print "        BSTTY=0x%x" % BSTTY
    65         print "        BSDMA=0x%x" % BSDMA
    66         print " "
    67         print " "
    6857
    69 def print_cluster(offset, cid):
    70         mem_base = offset
    71         mem_size = MEMC_SIZE
    72         xcu_base = (offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19))
    73         dma_base = (offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19))
    74         print "[CLUSTER]"
    75         cpu_num=0;
    76         while (cpu_num != CPU_PER_CLUSTER):
    77                 gid = (cid << CPU_PER_CLUSTER) + cpu_num
    78                 print "        [CPU]    ID=%d OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC))
    79                 cpu_num = cpu_num + 1
    80        
    81         print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_base, mem_size)
    82         print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_base, DMA_SIZE)
    83         print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_base, XCU_SIZE)
    84         print " "
    85         print " "
     58def print_io_cluster(x, y, x_width, y_width, cpu_per_cluster):
     59    mem_addr = ram_addr(x, y, x_width, y_width)
     60    mem_size = ram_size(x_width, y_width)
    8661
    87 def print_io_cluster(offset, cid):
    88         mem_base = offset
    89         mem_size = MEMC_SIZE
    90         xcu_base = (offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19))
    91         dma_base = (offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19))
    92         bdv_base = (offset + (CLUSTER_INC / 2) + (BDEV_TGTID << 19))
    93         tty_base = (offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19))
    94         fbf_base = (offset + (CLUSTER_INC / 2) + (FBUF_TGTID << 19))
    95        
    96         print "[CLUSTER]"
    97         cpu_num = 0
    98         while (cpu_num != CPU_PER_CLUSTER):
    99                 gid = (cid << CPU_PER_CLUSTER) + cpu_num
    100                 print "        [CPU]    ID=%d OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC))
    101                 cpu_num = cpu_num + 1
    102        
    103         print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_base, mem_size)
    104         print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_base, XCU_SIZE)
    105         print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_base, DMA_SIZE)
    106         print "        [DEV]    ID=BLKDEV    BASE=%#.8x    SIZE=%#.8x    IRQ=31    IRQTYPE=HWI"  % (bdv_base, BDV_SIZE)
    107         ntty = 0
    108         irq = 16
    109         while (ntty < NB_TTY):
    110                 tty_base_i = tty_base + ntty * TTY_CHANNEL_SIZE
    111                 print "        [DEV]    ID=TTY       BASE=%#.8x    SIZE=%#.8x    IRQ=%d    IRQTYPE=HWI" % (tty_base_i, TTY_CHANNEL_SIZE, irq)
    112                 irq = irq + 1
    113                 ntty = ntty + 1
    114         print "        [DEV]    ID=FB        BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (fbf_base, FBF_SIZE)
    115         print " "
    116         print " "
     62    xcu_addr = periph_addr(x_width, y_width, XCU_TGTID)
     63    dma_addr = periph_addr(x_width, y_width, DMA_TGTID)
     64    ioc_addr = periph_addr(x_width, y_width, IOC_TGTID)
     65    tty_base = periph_addr(x_width, y_width, TTY_TGTID)
     66    fbf_addr = periph_addr(x_width, y_width, FBF_TGTID)
     67   
     68    print "[CLUSTER]"
     69    cpu_num = 0
     70    cid = x * (1 << y_width) + y
     71    while (cpu_num != cpu_per_cluster):
     72        gid = (cid << P_WIDTH) + cpu_num
     73        print "        [CPU]    ID=%d    OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC))
     74        cpu_num = cpu_num + 1
     75   
     76    print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_addr, mem_size)
     77    print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_addr, XCU_SIZE)
     78    print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_addr, DMA_SIZE)
     79    print "        [DEV]    ID=BLKDEV    BASE=%#.8x    SIZE=%#.8x    IRQ=31    IRQTYPE=HWI"  % (ioc_addr, IOC_SIZE)
     80    ntty = 0
     81    irq = 16
     82    while (ntty < NB_TTY_CHANNELS):
     83        tty_base_i = tty_base + ntty * TTY_CHANNEL_SIZE
     84        print "        [DEV]    ID=TTY       BASE=%#.8x    SIZE=%#.8x    IRQ=%d    IRQTYPE=HWI" % (tty_base_i, TTY_CHANNEL_SIZE, irq)
     85        irq += 1
     86        ntty += 1
     87    print "        [DEV]    ID=FB        BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (fbf_addr, FBF_SIZE)
     88    print " "
     89    print " "
    11790
    118 def gen_arch_info(x, y, x_width, y_width, bscpu, arch_info_name):
    119         fp = open(arch_info_name, 'w')
    120         stdout = sys.stdout
    121         sys.stdout = fp
    122         global X_MAX
    123         global Y_MAX
    124         global CPU_PER_CLUSTER
    125         global CLUSTER_INC
    126         global MEMC_SIZE
    127         global BSCPU
    128         global BSDMA
    129         global BSTTY
    130        
    131         #------------------------
    132        
    133         X_MAX = x
    134         Y_MAX = y
    135         cpu_per_cluster = DEFAULT_CPU_PER_CLUSTER
    136         CPU_PER_CLUSTER = cpu_per_cluster
    137        
    138         #------------------------
    139         CLUSTER_INC = (0x80000000 >> (x_width + y_width)) * 2
    140         max_memc_size = 0x40000000 / (X_MAX * Y_MAX)
    141         size = min(max_memc_size, 0x10000000)
    142         MEMC_SIZE = size
     91def gen_arch_info(x, y, x_width, y_width, cpu_per_cluster, bscpu, arch_info_name):
     92    fp = open(arch_info_name, 'w')
     93    stdout = sys.stdout
     94    sys.stdout = fp
    14395
    144         ##########################################################################################
    145         #we force io_cid to 0 because this is the only cluster we know which will be present
    146         #in all platform where the number of clusters is independant of x_width and y_width values
    147         io_cid = 0
    148         ##########################################################################################
     96    x_io = get_x_io(x_width, y_width)
     97    y_io = get_y_io(x_width, y_width)
    14998
    150         BSCPU = bscpu
    151        
    152         break_loop = 0
    153         xi = 0
     99    ###########################################################################################
     100    # we force io_cid to 0 because this is the only cluster we know which will be present
     101    # in all platform where the number of clusters is independant of x_width and y_width values
     102    # io_cid = 0
     103    # @QM No.
     104    ###########################################################################################
     105
     106    break_loop = 0
     107    xi = 0
     108    yi = 0
     109    while (xi < x):
     110        while (yi < y):
     111            if xi == x_io and yi == y_io:
     112                bsdma = periph_addr(x_width, y_width, DMA_TGTID)
     113                bstty = periph_addr(x_width, y_width, TTY_TGTID)
     114                break_loop = 1
     115                break
     116            else:
     117                bsdma = "error"
     118            yi = yi + 1
     119
     120        if break_loop == 1:
     121            break
    154122        yi = 0
    155         while (xi < X_MAX):
    156                 while (yi < Y_MAX):
    157                         cid = xi * (1 << y_width) + yi
    158                         offset = cid << (ADDR_WIDTH - x_width - y_width)
    159                         if cid == io_cid:
    160                                 BSDMA = offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)
    161                                 BSTTY = offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19)
    162                                 break_loop = 1
    163                                 break
    164                         else:
    165                                 bsdma="error"
    166                         yi = yi + 1
     123        xi = xi + 1
     124   
     125    # Generate the description
     126    print_comments(sys.argv[0], x, y, cpu_per_cluster, bscpu)
     127    print_header(x, y, bscpu, bstty, bsdma)
     128   
     129    xi = 0
     130    yi = 0
     131    while (xi < x):
     132        while (yi < y):
     133            if xi == x_io and yi == y_io:
     134                print_io_cluster(xi, yi, x_width, y_width, cpu_per_cluster)
     135            else:
     136                print_cluster(xi, yi, x_width, y_width, cpu_per_cluster)
     137            yi = yi + 1
     138        yi = 0
     139        xi = xi + 1
     140    sys.stdout = stdout
     141    fp.close()
    167142
    168                 if break_loop == 1:
    169                         break
    170                 yi = 0
    171                 xi = xi + 1
    172        
    173         # Generate the description
    174         print_comments(sys.argv[0])
    175         print_header()
    176        
    177         xi = 0
    178         yi = 0
    179         while (xi < X_MAX):
    180                 while (yi < Y_MAX):
    181                         cid = xi * (1 << y_width) + yi
    182                         offset = cid  << (ADDR_WIDTH - (x_width + y_width))
    183                         if cid == io_cid:
    184                                 print_io_cluster(offset, cid)
    185                         else:
    186                                 print_cluster(offset, cid)
    187                         yi = yi + 1
    188                 yi = 0
    189                 xi = xi + 1
    190         sys.stdout = stdout
    191         fp.close()
    192 
Note: See TracChangeset for help on using the changeset viewer.