[93] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import dsx |
---|
| 4 | import soclib |
---|
| 5 | import soclib.component |
---|
| 6 | import os |
---|
| 7 | |
---|
| 8 | #import platform_handlers |
---|
| 9 | |
---|
| 10 | class Platform: |
---|
| 11 | def __init__(self, cluster_ctor, proc_count, binaries): |
---|
| 12 | self.pf = soclib.Architecture(cell_size = 4, |
---|
| 13 | plen_size = 8, |
---|
[95] | 14 | addr_size = 32, |
---|
[93] | 15 | rerror_size = 1, |
---|
| 16 | clen_size = 1, |
---|
| 17 | rflag_size = 1, |
---|
| 18 | srcid_size = 14, |
---|
| 19 | pktid_size = 4, |
---|
| 20 | trdid_size = 4, |
---|
| 21 | wrplen_size = 1 |
---|
| 22 | ) |
---|
| 23 | for name in ['mtp', 'mtc', 'mtx']: |
---|
| 24 | mt = self.pf.create('common:mapping_table', name, |
---|
| 25 | addr_size = 40, |
---|
| 26 | addr_bits = [16], srcid_bits = [14], |
---|
| 27 | cacheability_mask = 0x0000300000) |
---|
| 28 | # create self.mt[pcx] |
---|
| 29 | setattr(self, name, mt) |
---|
| 30 | |
---|
| 31 | # create a dictionary containing |
---|
| 32 | # loader = x, loader2 = y, ... |
---|
| 33 | bins = {} |
---|
| 34 | for i, bin in enumerate(binaries): |
---|
| 35 | k = 'binary' |
---|
| 36 | if i: |
---|
| 37 | k += str(i+1) |
---|
| 38 | bins[k] = bin |
---|
| 39 | self.loader = self.pf.create('common:loader', 'loader', **bins) |
---|
| 40 | |
---|
| 41 | # self.ringc = self.pf.create( |
---|
| 42 | # 'caba:vci_simple_ring_network', 'ringc', |
---|
| 43 | # mt = mtc, |
---|
| 44 | # ringid = (), |
---|
| 45 | # wrapper_fifo_depth = 2, ) |
---|
| 46 | # self.ringp = self.pf.create( |
---|
| 47 | # 'caba:vci_simple_ring_network', 'ringp', |
---|
| 48 | # mt = mtp, |
---|
| 49 | # ringid = (), |
---|
| 50 | # wrapper_fifo_depth = 2, ) |
---|
| 51 | self.ringc = self.pf.create('caba:vci_simple_ring_network', 'ringc', |
---|
| 52 | mt = self.mtc, |
---|
| 53 | ringid = (), |
---|
| 54 | wrapper_fifo_depth = 2) |
---|
| 55 | self.ringp = self.pf.create('caba:vci_simple_ring_network', 'ringp', |
---|
| 56 | mt = self.mtp, |
---|
| 57 | ringid = (), |
---|
| 58 | wrapper_fifo_depth = 2) |
---|
| 59 | |
---|
| 60 | self.cluster = cluster_ctor(self.pf, |
---|
| 61 | self.ringp, self.ringc, |
---|
| 62 | self.mtp, self.mtc, self.mtx, |
---|
| 63 | proc_count = proc_count, |
---|
| 64 | cluster_no = 0, |
---|
| 65 | cluster_base = 0x00000000, |
---|
| 66 | ) |
---|
| 67 | |
---|
| 68 | def simulator(self, outdir = 'hard'): |
---|
| 69 | self.pf.generate(soclib.PfDriver(outdir = outdir)) |
---|
| 70 | |
---|
| 71 | def device_tree(self): |
---|
| 72 | from dsx.contrib.dts_platform.platform_to_dts import PlatformToDts |
---|
| 73 | import dsx.contrib.dts_platform.platform_handlers |
---|
| 74 | dtsgen = PlatformToDts(self.pf, self.mtp) |
---|
| 75 | return dtsgen.create_device_tree() |
---|
| 76 | |
---|
| 77 | def dts(self, output): |
---|
| 78 | from dsx.device_tree.dts import Driver |
---|
| 79 | dt = self.device_tree() |
---|
| 80 | dt.generate(Driver( |
---|
| 81 | outdir = '.', |
---|
| 82 | parent = None, |
---|
| 83 | output_file = output, |
---|
| 84 | ),) |
---|
| 85 | |
---|
| 86 | def dtb(self, output): |
---|
| 87 | from dsx.device_tree.dtb import Driver |
---|
| 88 | dt = self.device_tree() |
---|
| 89 | dt.generate(Driver( |
---|
| 90 | outdir = '.', |
---|
| 91 | parent = None, |
---|
| 92 | output_file = output, |
---|
| 93 | ),) |
---|
| 94 | |
---|
| 95 | def main(cpus): |
---|
| 96 | from cluster import ClusterV3 |
---|
| 97 | hard = Platform(ClusterV3, cpus, binaries = ["bin.soft"]) |
---|
| 98 | hard.simulator('.') |
---|
| 99 | hard.dts(os.path.basename(__file__)[:-2]+'dts') |
---|
| 100 | hard.dtb(os.path.basename(__file__)[:-2]+'dtb') |
---|
| 101 | |
---|
| 102 | if __name__ == '__main__': |
---|
| 103 | import sys |
---|
[95] | 104 | cpus = 1 |
---|
[93] | 105 | if len(sys.argv) > 1: |
---|
| 106 | cpus = int(sys.argv[1]) |
---|
| 107 | main(cpus) |
---|