source: trunk/platforms/dsx/v1_1cluster_phys_dma/cluster.py @ 93

Last change on this file since 93 was 93, checked in by choichil, 14 years ago

Platform with DMA

File size: 5.2 KB
Line 
1
2__doc__ = '''
3This file is a Cluster library. It contains classes implementing the
4netlist of a cluster, for different tsar versions.
5'''
6
7class Cluster:
8    '''
9    A generic netlist of a cluster, which must be subclassed to
10    implement caches&dma instanciation
11    '''
12   
13    def __init__(self, pf, ringp, ringc, mtp, mtc, mtx, proc_count, cluster_no, cluster_base):
14        self.pf = pf
15        self.ringp = ringp
16        self.ringc = ringc
17        self.mtp = mtp
18        self.mtc = mtc
19        self.mtx = mtx
20        self.cluster_no = cluster_no
21
22        self.generate(proc_count, cluster_base)
23
24    def generate(self, proc_count, cluster_base):
25        '''
26        The core netlist, where caches and components are created
27        '''
28        self.cpu = []
29        for i in range(proc_count):
30            c = self.create_cpu(i,
31                                cluster_base
32                                + 0x01200000
33                                + 0x01000000 * i
34                                )
35            self.cpu.append(c)
36
37        memc, xram = self.create_memcache( segments = [
38            ('reset', 0xbfc00000, 0x00010000),
39            ('excep', 0x80000000, 0x00010000),
40            ('text', 0x00400000, 0x00050000),
41            ('data', 0x10000000, 0x00100000),
42            ] )
43        tty  = self.create_tty( addr = 0xc0200000, tty_count = 1 )
44        xicu = self.create_xicu( addr = 0xd2200000, pti_count = 1, 
45                                                    hwi_count = 3,
46                                                    wti_count = 4, 
47                                                    irq_count = 4)
48        dma = self.create_dma( addr = 0xd1200000, burst_size = 16)
49
50        tty.irq[0] // xicu.hwi[0]
51        for i in range(proc_count):
52            self.cpu[i].irq[0] // xicu.irq[i]
53        dma.irq // xicu.hwi[1]
54
55    def create_dma(self, addr, burst_size):
56        name = 'dma%d'%self.cluster_no
57        dma = self.pf.create('caba:vci_dma_vhdl', name, burst_size = burst_size)
58        self.ringp.to_target.new() // dma.vci_target
59        self.ringp.to_initiator.new() // dma.vci_initiator
60        dma.addSegment(name, address = addr, size = 0x1000, cacheable = False)
61        return dma
62
63
64    def create_tty(self, addr, tty_count = 1):
65        names = map(lambda x:'tty%d'%x, range(tty_count))
66        name = 'tty%d'%self.cluster_no
67        tty = self.pf.create('caba:vci_multi_tty', name, names = names)
68        self.ringp.to_target.new() // tty.vci
69        tty.addSegment(name, address = addr, size = 0x1000, cacheable = False)
70        return tty
71   
72    def create_xicu(self, addr, pti_count, hwi_count, wti_count, irq_count):
73        name = 'xicu'
74        xicu = self.pf.create('caba:vci_xicu', name, pti_count = pti_count,
75                                                          hwi_count = hwi_count,
76                                                          wti_count = wti_count,
77                                                          irq_count = irq_count)
78        self.ringp.to_target.new() // xicu.vci
79        xicu.addSegment(name, address = addr, size = 0x1000, cacheable = False)
80        return xicu
81
82
83class ClusterV3(Cluster):
84    '''
85    A TsarV3 implementation, using vci_cc_vcache_wrapper2_v1,
86    vci_mem_cache_v3 and vci_dma_tsar_v2.
87    '''
88
89    def create_cpu(self, cpuid, addr):
90            c = self.pf.create(
91                'caba:vci_cc_xcache_wrapper_v1',
92                'proc_%d_%d' % (self.cluster_no, cpuid),
93                iss_t = "common:mips32el",
94                proc_id = cpuid,
95                icache_ways = 4,
96                icache_sets = 64,
97                icache_words = 16,
98                dcache_ways = 4,
99                dcache_sets = 64,
100                dcache_words = 16,
101                write_buf_size = 16,
102                )
103            self.ringc.to_initiator.new() // c.vci_ini_c
104            self.ringc.to_target.new() // c.vci_tgt
105            self.ringp.to_initiator.new() // c.vci_ini_rw
106
107            c.addSegment('proc_%d_%d' % (self.cluster_no, cpuid),
108                         address = addr,
109                         size = 0x10,
110                         cacheable = False,
111                         )
112
113            return c
114
115    def create_memcache(self, segments):
116        memc = self.pf.create('caba:vci_mem_cache_v1', 'memc',
117                              mtx = self.mtx,
118                              vci_ixr_index = (self.cluster_no,),
119                              nways = 16,
120                              nsets = 256,
121                              nwords = 16,
122                              )
123        self.ringc.to_target.new() // memc.vci_tgt_cleanup
124        self.ringp.to_target.new() // memc.vci_tgt
125        self.ringc.to_initiator.new() // memc.vci_ini
126
127        xram = self.pf.create('caba:vci_simple_ram', 'xram',
128                              mt = self.mtx,
129                              ident = (self.cluster_no,),
130                              latency = 1,
131                 )
132        memc.vci_ixr // xram.vci
133
134        for name, addr, size in segments:
135            # Here DSX knows the only way to address xram is through its
136            # vci port. It also knows the only associated mapping_table.
137            xram.addSegment('ram_x_'+name, address = addr, size = size, cacheable = True)
138
139            # For these segments, there is ambiguity for the mapping_table
140            # we are talking about, so we specify mt = ...
141            memc.addSegment('ram_p_'+name, address = addr, size = size, cacheable = True, mt = self.mtp)
142            memc.addSegment('ram_c_'+name, address = addr, size = size, cacheable = True, mt = self.mtc)
143        return memc, xram
Note: See TracBrowser for help on using the repository browser.