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