| 1 | {{{ |
| 2 | #!/usr/bin/env python |
| 3 | |
| 4 | from dsx.hardware import * |
| 5 | from soclib import * |
| 6 | |
| 7 | class ClusteredNoirqMulti(SoclibGenericArchitecture): |
| 8 | """ |
| 9 | Parameters: |
| 10 | - min_latency: Vgmn's latency |
| 11 | - cpus: Cpus per cluster in a list |
| 12 | - rams: Rams per cluster in a list |
| 13 | |
| 14 | Exports: |
| 15 | - vgmn: global vgmn interconnect |
| 16 | - clust[]: cluster's interconnect; contains: |
| 17 | - cpu[]: cpu list for cluster |
| 18 | - cram[]: cached ram list for cluster |
| 19 | - uram[]: uncached ram list for cluster |
| 20 | - locks: ramlocks |
| 21 | - cpu[]: global cpu list |
| 22 | - cram[]: global cached ram list |
| 23 | - uram[]: global uncached ram list |
| 24 | - locks: global ramlocks list |
| 25 | """ |
| 26 | def cluster(self, clustno, ncpu, nram): |
| 27 | ic = LocalCrossbar('lc%d'%clustno) |
| 28 | |
| 29 | cpu = [] |
| 30 | cache = [] |
| 31 | for n in range(ncpu): |
| 32 | c = Mips('mips%d_%d'%(clustno,n)) |
| 33 | xc = Xcache('cache%d_%d'%(clustno,n)) |
| 34 | c.cache // xc.cache |
| 35 | |
| 36 | cpu.append(c) |
| 37 | cache.append(xc) |
| 38 | |
| 39 | xc.vci // ic.getTarget() |
| 40 | |
| 41 | ic.cpu = cpu |
| 42 | ic.cache = cache |
| 43 | |
| 44 | ram = [] |
| 45 | uram = [] |
| 46 | cram = [] |
| 47 | for n in range(nram): |
| 48 | cr = Segment('cram%d'%clustno, __remplir__) |
| 49 | ur = Segment('uram%d'%clustno, __remplir__) |
| 50 | uram.append(ur) |
| 51 | cram.append(cr) |
| 52 | r = MultiRam('ram%d'%clustno, cr, ur) |
| 53 | |
| 54 | r.vci // ic.getInit() |
| 55 | ram.append(r) |
| 56 | ic.ram = ram |
| 57 | ic.uram = uram |
| 58 | ic.cram = cram |
| 59 | |
| 60 | ic.locks = Locks('locks%d'%clustno) |
| 61 | ic.locks.vci // ic.getInit() |
| 62 | |
| 63 | return ic |
| 64 | |
| 65 | def architecture(self): |
| 66 | self.vgmn = Vgmn('vgmn', self.getParam(__remplir__)) |
| 67 | self.setBase(self.vgmn) |
| 68 | |
| 69 | nram = self.getParam('rams') |
| 70 | ncpu = self.getParam('cpus') |
| 71 | assert(len(nram) == len(ncpu)) |
| 72 | |
| 73 | ncluster = len(nram) |
| 74 | |
| 75 | self.clust = [] |
| 76 | for n, nc, nr in zip(range(ncluster), ncpu, nram): |
| 77 | ic = self.cluster(n, nc, nr) |
| 78 | self.clust.append(ic) |
| 79 | ic.__remplir__ // self.vgmn.getBoth() |
| 80 | |
| 81 | self.clust[0].ram[0].addSegment( |
| 82 | Segment('reset', Cached, addr=0xbfc00000), |
| 83 | Segment('excep', Cached, addr=0x80000080)) |
| 84 | |
| 85 | # export global lists |
| 86 | add = lambda x,y: x+y |
| 87 | self.ram = reduce(add, [self.clust[i].ram for i in range(ncluster)]) |
| 88 | self.uram = reduce(add, [self.clust[i].uram for i in range(ncluster)]) |
| 89 | self.cram = reduce(add, [self.clust[i].cram for i in range(ncluster)]) |
| 90 | self.cpu = reduce(add, [self.clust[i].cpu for i in range(ncluster)]) |
| 91 | self.locks = [self.clust[i].locks for i in range(ncluster)] |
| 92 | |
| 93 | # Ceci permet de tester l'architecture: |
| 94 | # Le bout de code dans le if ne sera exécuté que si vous faites ./clustered_noirq_multi.py |
| 95 | # et pas si vous importez clustered_noirq_multi depuis une autre description. |
| 96 | |
| 97 | if __name__ == '__main__': |
| 98 | hard = ClusteredNoirqMulti( cpus = [1, 2, 2, 1], |
| 99 | rams = [1, 1, 1, 1], |
| 100 | min_latency = 10 ) |
| 101 | hard.dispTree() |
| 102 | print hard.cpu |
| 103 | print hard.ram |
| 104 | print hard.cram |
| 105 | print hard.uram |
| 106 | print hard.locks |
| 107 | hard.generate(Caba()) |
| 108 | }}} |