source: trunk/platforms/tsar_generic_xbar/scripts/gen_arch_info.py @ 1048

Last change on this file since 1048 was 1048, checked in by meunier, 7 years ago
  • Update of tsar_xbar_cluster (scripts and openmp support)
  • Property svn:executable set to *
File size: 5.4 KB
Line 
1#--------------------------------------------------------------------
2# File      : gen_arch_info.py
3#--------------------------------------------------------------------
4
5import getpass
6import socket
7import time
8import sys
9
10
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 "        BSHCRYPT=0" # Not supported
32    print " "
33    print " "
34
35
36def print_cluster(x, y, x_width, y_width, cpu_per_cluster):
37    mem_addr = ram_addr(x, y, x_width, y_width)
38    mem_size = ram_size(x_width, y_width)
39    xcu_base = replicated_periph_base_addr(x_width, y_width, XCU_TGTID)
40    dma_base = replicated_periph_base_addr(x_width, y_width, DMA_TGTID)
41    xcu_addr = replicated_periph_addr(x, y, x_width, y_width, xcu_base)
42    dma_addr = replicated_periph_addr(x, y, x_width, y_width, dma_base)
43    print "[CLUSTER]"
44
45    cid = x * (1 << y_width) + y
46    cpu_num = 0;
47    while (cpu_num != cpu_per_cluster):
48        gid = (cid << P_WIDTH) + cpu_num
49        print "        [CPU]    ID=%d    OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC)) 
50        cpu_num += 1
51   
52    print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_addr, mem_size)
53    print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_addr, DMA_SIZE)
54    print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_addr, XCU_SIZE)
55    print " "
56    print " "
57
58
59def print_io_cluster(x, y, x_width, y_width, cpu_per_cluster):
60    mem_addr = ram_addr(x, y, x_width, y_width)
61    mem_size = ram_size(x_width, y_width)
62
63    xcu_addr = periph_addr(x_width, y_width, XCU_TGTID)
64    dma_addr = periph_addr(x_width, y_width, DMA_TGTID)
65    ioc_addr = periph_addr(x_width, y_width, IOC_TGTID)
66    tty_base = periph_addr(x_width, y_width, TTY_TGTID)
67    fbf_addr = periph_addr(x_width, y_width, FBF_TGTID)
68   
69    print "[CLUSTER]"
70    cpu_num = 0
71    cid = x * (1 << y_width) + y
72    while (cpu_num != cpu_per_cluster):
73        gid = (cid << P_WIDTH) + cpu_num
74        print "        [CPU]    ID=%d    OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC)) 
75        cpu_num = cpu_num + 1
76   
77    print "        [DEV]    ID=RAM       BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (mem_addr, mem_size)
78    print "        [DEV]    ID=XICU      BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (xcu_addr, XCU_SIZE)
79    print "        [DEV]    ID=DMA       BASE=%#.8x    SIZE=%#.8x    IRQ=8     IRQTYPE=HWI"  % (dma_addr, DMA_SIZE)
80    print "        [DEV]    ID=BLKDEV    BASE=%#.8x    SIZE=%#.8x    IRQ=31    IRQTYPE=HWI"  % (ioc_addr, IOC_SIZE)
81    ntty = 0
82    irq = 16
83    while (ntty < NB_TTY_CHANNELS):
84        tty_base_i = tty_base + ntty * TTY_CHANNEL_SIZE
85        print "        [DEV]    ID=TTY       BASE=%#.8x    SIZE=%#.8x    IRQ=%d    IRQTYPE=HWI" % (tty_base_i, TTY_CHANNEL_SIZE, irq)
86        irq += 1
87        ntty += 1
88    print "        [DEV]    ID=FB        BASE=%#.8x    SIZE=%#.8x    IRQ=-1    IRQTYPE=NONE" % (fbf_addr, FBF_SIZE)
89    print " "
90    print " "
91
92def gen_arch_info(x, y, x_width, y_width, cpu_per_cluster, bscpu, arch_info_name):
93    fp = open(arch_info_name, 'w')
94    stdout = sys.stdout
95    sys.stdout = fp
96
97    x_io = get_x_io(x_width, y_width)
98    y_io = get_y_io(x_width, y_width)
99
100    ###########################################################################################
101    # we force io_cid to 0 because this is the only cluster we know which will be present
102    # in all platform where the number of clusters is independant of x_width and y_width values
103    # io_cid = 0
104    # @QM No.
105    ###########################################################################################
106
107    break_loop = 0
108    xi = 0
109    yi = 0
110    while (xi < x):
111        while (yi < y):
112            if xi == x_io and yi == y_io:
113                bsdma = periph_addr(x_width, y_width, DMA_TGTID)
114                bstty = periph_addr(x_width, y_width, TTY_TGTID)
115                break_loop = 1
116                break
117            else:
118                bsdma = "error"
119            yi = yi + 1
120
121        if break_loop == 1:
122            break
123        yi = 0
124        xi = xi + 1
125   
126    # Generate the description
127    print_comments(sys.argv[0], x, y, cpu_per_cluster, bscpu)
128    print_header(x, y, bscpu, bstty, bsdma)
129   
130    xi = 0
131    yi = 0
132    while (xi < x):
133        while (yi < y):
134            if xi == x_io and yi == y_io:
135                print_io_cluster(xi, yi, x_width, y_width, cpu_per_cluster)
136            else:
137                print_cluster(xi, yi, x_width, y_width, cpu_per_cluster)
138            yi = yi + 1
139        yi = 0
140        xi = xi + 1
141    sys.stdout = stdout
142    fp.close()
143
Note: See TracBrowser for help on using the repository browser.