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