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 = 32, |
---|
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_bits = [8], srcid_bits = [14], |
---|
24 | cacheability_mask = 0x00F0000000) |
---|
25 | # create self.mt[pcx] |
---|
26 | setattr(self, name, mt) |
---|
27 | |
---|
28 | # create a dictionary containing |
---|
29 | # loader = x, loader2 = y, ... |
---|
30 | bins = {} |
---|
31 | for i, bin in enumerate(binaries): |
---|
32 | k = 'binary' |
---|
33 | if i: |
---|
34 | k += str(i+1) |
---|
35 | bins[k] = bin |
---|
36 | self.loader = self.pf.create('common:loader', 'loader', **bins) |
---|
37 | |
---|
38 | # self.ringc = self.pf.create( |
---|
39 | # 'caba:vci_simple_ring_network', 'ringc', |
---|
40 | # mt = mtc, |
---|
41 | # ringid = (), |
---|
42 | # wrapper_fifo_depth = 2, ) |
---|
43 | # self.ringp = self.pf.create( |
---|
44 | # 'caba:vci_simple_ring_network', 'ringp', |
---|
45 | # mt = mtp, |
---|
46 | # ringid = (), |
---|
47 | # wrapper_fifo_depth = 2, ) |
---|
48 | self.ringc = self.pf.create('caba:vci_vgmn', 'ringc', |
---|
49 | mt = self.mtc, |
---|
50 | min_latency = 1, |
---|
51 | fifo_depth = 8, ) |
---|
52 | self.ringp = self.pf.create('caba:vci_vgmn', 'ringp', |
---|
53 | mt = self.mtp, |
---|
54 | min_latency = 1, |
---|
55 | fifo_depth = 8, ) |
---|
56 | |
---|
57 | self.cluster = cluster_ctor(self.pf, |
---|
58 | self.ringp, self.ringc, |
---|
59 | self.mtp, self.mtc, self.mtx, |
---|
60 | proc_count = proc_count, |
---|
61 | cluster_no = 0, |
---|
62 | cluster_base = 0x00000000, |
---|
63 | ) |
---|
64 | |
---|
65 | def simulator(self): |
---|
66 | self.pf.generate(soclib.PfDriver()) |
---|
67 | |
---|
68 | def device_tree(self): |
---|
69 | from dsx.contrib.dts_platform.platform_to_dts import PlatformToDts |
---|
70 | import dsx.contrib.dts_platform.platform_handlers |
---|
71 | dtsgen = PlatformToDts(self.pf, self.mtp) |
---|
72 | return dtsgen.create_device_tree() |
---|
73 | |
---|
74 | def dts(self, output): |
---|
75 | from dsx.device_tree.dts import Driver |
---|
76 | dt = self.device_tree() |
---|
77 | dt.generate(Driver( |
---|
78 | outdir = '.', |
---|
79 | parent = None, |
---|
80 | output_file = output, |
---|
81 | ),) |
---|
82 | |
---|
83 | def dtb(self, output): |
---|
84 | from dsx.device_tree.dtb import Driver |
---|
85 | dt = self.device_tree() |
---|
86 | dt.generate(Driver( |
---|
87 | outdir = '.', |
---|
88 | parent = None, |
---|
89 | output_file = output, |
---|
90 | ),) |
---|
91 | |
---|
92 | def main(cpus): |
---|
93 | from cluster import ClusterV3 |
---|
94 | hard = Platform(ClusterV3, cpus, binaries = ["boot.bin", "kernel@0x00a00000:D"]) |
---|
95 | hard.simulator() |
---|
96 | hard.dts(os.path.basename(__file__)[:-2]+'dts') |
---|
97 | hard.dtb(os.path.basename(__file__)[:-2]+'dtb') |
---|
98 | |
---|
99 | if __name__ == '__main__': |
---|
100 | import sys |
---|
101 | cpus = 1 |
---|
102 | if len(sys.argv) > 1: |
---|
103 | cpus = int(sys.argv[1]) |
---|
104 | main(cpus) |
---|