[1012] | 1 | #-------------------------------------------------------------------- |
---|
[1023] | 2 | # File : gen_arch_info.py |
---|
[1012] | 3 | #-------------------------------------------------------------------- |
---|
| 4 | |
---|
| 5 | import getpass |
---|
| 6 | import socket |
---|
| 7 | import time |
---|
| 8 | import sys |
---|
| 9 | |
---|
| 10 | |
---|
[1023] | 11 | exec(file("hard_params.py")) |
---|
[1012] | 12 | |
---|
[1023] | 13 | def 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 | |
---|
| 22 | def 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 " " |
---|
[1012] | 33 | |
---|
| 34 | |
---|
[1023] | 35 | def 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]" |
---|
[1012] | 43 | |
---|
[1023] | 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 " " |
---|
[1012] | 56 | |
---|
| 57 | |
---|
[1023] | 58 | def 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) |
---|
[1012] | 61 | |
---|
[1023] | 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 " " |
---|
[1012] | 90 | |
---|
[1023] | 91 | def 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 |
---|
[1012] | 95 | |
---|
[1023] | 96 | x_io = get_x_io(x_width, y_width) |
---|
| 97 | y_io = get_y_io(x_width, y_width) |
---|
[1012] | 98 | |
---|
[1023] | 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 |
---|
[1012] | 122 | yi = 0 |
---|
[1023] | 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() |
---|
[1012] | 142 | |
---|