30 | | We may define a basic architecture with no parameters: |
31 | | |
32 | | {{{ |
33 | | class OneLevel(GenericArchitecture): |
34 | | def architecture(self): |
35 | | vgmn = Vgmn( ’vgmn’ ) |
36 | | |
37 | | mips0 = Mips( ’mips0’ ) |
38 | | cache0 = Xcache( ’cache0’ ) |
39 | | |
40 | | # Cache ports connexion |
41 | | cache0.cache // mips0.cache |
42 | | vgmn.getTarget() // cache0.vci |
43 | | |
44 | | reset = Segment( ’reset’, |
45 | | address = 0xbfc00000, |
46 | | type = Cached ) |
47 | | excep = Segment( ’excep’, |
48 | | address = 0x80000080, |
49 | | type = Cached ) |
50 | | code = Segment( ’code’, type = Cached ) |
51 | | data = Segment( ’data’, type = Uncached ) |
52 | | ram = MultiRam( ’ram’, reset, excep, code, data ) |
53 | | |
54 | | # Connections |
55 | | vgmn.getInit() // ram.vci |
56 | | |
57 | | # Declare base component |
58 | | self.setBase(vgmn) |
59 | | |
60 | | # Add configuration utilities |
61 | | self.setTimeBase() |
62 | | self.setConfig(’mapping_table’, MappingTable()) |
63 | | }}} |
64 | | |
65 | | As you may want to refer to some objects later on, you may set attributes to self: |
66 | | |
67 | | {{{ |
68 | | ... |
69 | | self.ram = MultiRam( ’ram’, reset, code, data ) |
70 | | }}} |
71 | | |
72 | | === Parametrized example === |
73 | | |
74 | | We will define a one-level architecture using a Vgmn, with two parameters: number of Cpus (`ncpu`) and number of Ram components (`nram`). |
75 | | We will set `nram` default value to 1. |
76 | | |
77 | | We'll add in `ram0` (which always exists) two more segments: `excep` and `reset`. |
78 | | |
79 | | We'll those attributes in instance objet (accessible through `object.name`): |
80 | | * `vgmn`: the interconnect |
81 | | * `cpu`: a list of all the cpus |
82 | | * `ram`: a list of all the ram chips |
83 | | * `cram`: a list of all the cached ram segments |
84 | | * `uram`: a list of all the uncached ram segments |
85 | | |
86 | | This way, we'll be able to refer to `platform.ram[2]` or `platform.cpu[0]`. |
87 | | |
88 | | {{{ |
89 | | class Parametrized(GenericArchitecture): |
90 | | defaults = { |
91 | | 'nram': 1, |
92 | | } |
93 | | def architecture(self): |
94 | | self.vgmn = Vgmn( ’vgmn’ ) |
95 | | |
96 | | self.cpu = [] |
97 | | for i in range(self.getParam('ncpu')): |
98 | | cpu = Mips( ’mips%d’%i ) |
99 | | cache = Xcache( ’cache%d’%i ) |
100 | | |
101 | | # Cache ports connexion |
102 | | cache.cache // cpu.cache |
103 | | vgmn.getTarget() // cache.vci |
104 | | self.cpu.append( cpu ) |
105 | | |
106 | | self.ram = [] |
107 | | self.cram = [] |
108 | | self.uram = [] |
109 | | for i in range(self.getParam('nram')): |
110 | | cram = Segment( ’cram%d’%i, type = Cached ) |
111 | | uram = Segment( ’uram%d’%i, type = Uncached ) |
112 | | ram = MultiRam( ’ram%d’%i, cram, uram) |
113 | | |
114 | | vgmn.getInit() // ram.vci |
115 | | self.ram.append( ram ) |
116 | | self.cram.append( cram ) |
117 | | self.uram.append( uram ) |
118 | | |
119 | | self.reset = Segment( ’reset', type = Cached ) |
120 | | self.excep = Segment( ’excep', type = Cached ) |
121 | | self.ram[0].addSegment( self.reset, self.excep ) |
122 | | |
123 | | self.setBase( self.vgmn ) |
124 | | |
125 | | self.setTimeBase() |
126 | | self.setConfig(’mapping_table’, MappingTable()) |
127 | | }}} |
128 | | |
129 | | In this platform |
130 | | * argument `nram` is optional with default value being 1 |
131 | | * arguments `ncpu` is mandatory |
| 28 | In your design, there may be some [MacroComponent MacroComponent]s you would like to define on their own. |