Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | |
2 | ### N2_Model.py is automatically generated from | |
3 | ### ss/api/pfe/bin/Bl_Model.py, do not modify N2_Model.py, | |
4 | ### make necessary changes in ss/api/pfe/bin/Bl_Model.py instead. | |
5 | ||
6 | import Pfe_Tlb | |
7 | import Pfe_Model | |
8 | ||
9 | from SS_Break import * | |
10 | from Pfe_Tlb import Tte | |
11 | from Pfe_Conversion import * | |
12 | from Pfe_Assembler import asm | |
13 | ||
14 | import N2_Python | |
15 | import SS_Strand | |
16 | from SS_Strand import AsiState | |
17 | ||
18 | dis = N2_Python.dis | |
19 | ||
20 | SS_Strand.__asi_va__ = {} | |
21 | for i in range(0,8): | |
22 | SS_Strand.__asi_va__['scratch'+chr(i+ord('0'))] = AsiState(0x20,i*8) | |
23 | SS_Strand.__asi_va__['hscratch'+chr(i+ord('0'))] = AsiState(0x4f,i*8) | |
24 | ||
25 | SS_Strand.__asi_va__['strand_available'] = AsiState(0x41,0x00) | |
26 | SS_Strand.__asi_va__['strand_enable_status'] = AsiState(0x41,0x10) | |
27 | SS_Strand.__asi_va__['strand_enable'] = AsiState(0x41,0x20) | |
28 | SS_Strand.__asi_va__['strand_running'] = AsiState(0x41,0x50) | |
29 | SS_Strand.__asi_va__['strand_running_status'] = AsiState(0x41,0x58) | |
30 | SS_Strand.__asi_va__['strand_running_w1s'] = AsiState(0x41,0x60) | |
31 | SS_Strand.__asi_va__['strand_running_w1c'] = AsiState(0x41,0x68) | |
32 | SS_Strand.__asi_va__['xir_steering'] = AsiState(0x41,0x30) | |
33 | SS_Strand.__asi_va__['tick_enable'] = AsiState(0x41,0x38) | |
34 | ||
35 | SS_Strand.__asi_va__['intr_w'] = AsiState(0x73,0x0) | |
36 | ||
37 | SS_Strand.__asi_va__['pri_ctx0'] = AsiState(0x21,0x008) | |
38 | SS_Strand.__asi_va__['pri_ctx1'] = AsiState(0x21,0x010) | |
39 | SS_Strand.__asi_va__['sec_ctx0'] = AsiState(0x21,0x108) | |
40 | SS_Strand.__asi_va__['sec_ctx1'] = AsiState(0x21,0x110) | |
41 | ||
42 | SS_Strand.__asi_va__['lsu_ctr'] = AsiState(0x45,0x0) | |
43 | ||
44 | SS_Strand.__asi_va__['inst_tag_target'] = AsiState(0x50,0x00) | |
45 | SS_Strand.__asi_va__['inst_sfsr'] = AsiState(0x50,0x18) | |
46 | SS_Strand.__asi_va__['inst_tag_access'] = AsiState(0x50,0x30) | |
47 | SS_Strand.__asi_va__['inst_tlb_data_in_v'] = AsiState(0x54,0x000) | |
48 | SS_Strand.__asi_va__['inst_tlb_data_in_r'] = AsiState(0x54,0x400) | |
49 | ||
50 | SS_Strand.__asi_va__['data_tag_target'] = AsiState(0x58,0x00) | |
51 | SS_Strand.__asi_va__['data_sfsr'] = AsiState(0x58,0x18) | |
52 | SS_Strand.__asi_va__['data_sfar'] = AsiState(0x58,0x20) | |
53 | SS_Strand.__asi_va__['data_tag_access'] = AsiState(0x58,0x30) | |
54 | SS_Strand.__asi_va__['data_tlb_data_in_v'] = AsiState(0x5c,0x000) | |
55 | SS_Strand.__asi_va__['data_tlb_data_in_r'] = AsiState(0x5c,0x400) | |
56 | ||
57 | SS_Strand.__asi_va__['partition_id'] = AsiState(0x58,0x80) | |
58 | ||
59 | SS_Strand.__asi_va__['real_range0'] = AsiState(0x52,0x108) | |
60 | SS_Strand.__asi_va__['real_range1'] = AsiState(0x52,0x110) | |
61 | SS_Strand.__asi_va__['real_range2'] = AsiState(0x52,0x118) | |
62 | SS_Strand.__asi_va__['real_range3'] = AsiState(0x52,0x120) | |
63 | ||
64 | SS_Strand.__asi_va__['phys_offset0'] = AsiState(0x52,0x208) | |
65 | SS_Strand.__asi_va__['phys_offset1'] = AsiState(0x52,0x210) | |
66 | SS_Strand.__asi_va__['phys_offset2'] = AsiState(0x52,0x218) | |
67 | SS_Strand.__asi_va__['phys_offset3'] = AsiState(0x52,0x220) | |
68 | ||
69 | SS_Strand.__asi_va__['nuc_tsb_cfg0'] = AsiState(0x54,0x010) | |
70 | SS_Strand.__asi_va__['nuc_tsb_cfg1'] = AsiState(0x54,0x018) | |
71 | SS_Strand.__asi_va__['nuc_tsb_cfg2'] = AsiState(0x54,0x020) | |
72 | SS_Strand.__asi_va__['nuc_tsb_cfg3'] = AsiState(0x54,0x028) | |
73 | ||
74 | SS_Strand.__asi_va__['non_nuc_tsb_cfg0'] = AsiState(0x54,0x030) | |
75 | SS_Strand.__asi_va__['non_nuc_tsb_cfg1'] = AsiState(0x54,0x038) | |
76 | SS_Strand.__asi_va__['non_nuc_tsb_cfg2'] = AsiState(0x54,0x040) | |
77 | SS_Strand.__asi_va__['non_nuc_tsb_cfg3'] = AsiState(0x54,0x048) | |
78 | ||
79 | SS_Strand.__asi_va__['inst_tsb_ptr0'] = AsiState(0x54,0x050) | |
80 | SS_Strand.__asi_va__['inst_tsb_ptr1'] = AsiState(0x54,0x058) | |
81 | SS_Strand.__asi_va__['inst_tsb_ptr2'] = AsiState(0x54,0x060) | |
82 | SS_Strand.__asi_va__['inst_tsb_ptr3'] = AsiState(0x54,0x068) | |
83 | ||
84 | SS_Strand.__asi_va__['data_tsb_ptr0'] = AsiState(0x54,0x070) | |
85 | SS_Strand.__asi_va__['data_tsb_ptr1'] = AsiState(0x54,0x078) | |
86 | SS_Strand.__asi_va__['data_tsb_ptr2'] = AsiState(0x54,0x080) | |
87 | SS_Strand.__asi_va__['data_tsb_ptr3'] = AsiState(0x54,0x088) | |
88 | ||
89 | ||
90 | def __tte_getvalid__(tte): return bool(tte.valid_bit()) | |
91 | def __tte_setvalid__(tte,val): tte.valid_bit(val) | |
92 | def __tte_getreal__(tte): return bool(tte.real_bit()) | |
93 | def __tte_setreal__(tte,val): tte.real_bit(val) | |
94 | def __tte_getpid__(tte): return tte.pid() | |
95 | def __tte_setpid__(tte,val): tte.pid(val) | |
96 | def __tte_getctx__(tte): return tte.context() | |
97 | def __tte_setctx__(tte,val): tte.context(val) | |
98 | def __tte_gettag__(tte): return tte.tag() | |
99 | def __tte_settag__(tte,val): tte.tag(val) | |
100 | def __tte_getsize__(tte): return tte.page_size() | |
101 | def __tte_setsize__(tte,val): tte.page_size(val) | |
102 | def __tte_getnfo__(tte): return bool(tte.nfo()) | |
103 | def __tte_setnfo__(tte,val): tte.nfo(val) | |
104 | def __tte_getie__(tte): return bool(tte.ie()) | |
105 | def __tte_setie__(tte,val): tte.ie(val) | |
106 | def __tte_getw__(tte): return bool(tte.w()) | |
107 | def __tte_setw__(tte,val): tte.w(val) | |
108 | def __tte_getx__(tte): return bool(tte.x()) | |
109 | def __tte_setx__(tte,val): tte.x(val) | |
110 | def __tte_getp__(tte): return bool(tte.p()) | |
111 | def __tte_setp__(tte,val): tte.p(val) | |
112 | def __tte_gete__(tte): return bool(tte.e()) | |
113 | def __tte_sete__(tte,val): tte.e(val) | |
114 | def __tte_getaddr__(tte): return tte.taddr() | |
115 | def __tte_setaddr__(tte,val): tte.taddr(val) | |
116 | ||
117 | # for unused fields in the TTE | |
118 | ||
119 | def __tte_getfalse__(tte): return False | |
120 | def __tte_setpass__(tte,val): pass | |
121 | ||
122 | class __tte_xlate__: | |
123 | def __init__(self,tte): | |
124 | self.tte = tte | |
125 | def __call__(self,addr): | |
126 | return self.tte.trans(addr) | |
127 | ||
128 | class __tte_match__: | |
129 | def __init__(self,tte): | |
130 | self.tte = tte | |
131 | def __call__(self,addr,ctx=0,pid=0,real=False,page_size_mask=0xff): | |
132 | if real: | |
133 | self.tte.match_real(addr,pid,page_size_mask) | |
134 | else: | |
135 | self.tte.match_virt(addr,ctx,pid,page_size_mask) | |
136 | ||
137 | Pfe_Tlb.TlbTte.__getfun__['xlate'] = __tte_xlate__ | |
138 | Pfe_Tlb.TlbTte.__getfun__['match'] = __tte_match__ | |
139 | ||
140 | Pfe_Tlb.TlbTte.__getfun__['valid'] = __tte_getvalid__ | |
141 | Pfe_Tlb.TlbTte.__setfun__['valid'] = __tte_setvalid__ | |
142 | Pfe_Tlb.TlbTte.__getfun__['real'] = __tte_getreal__ | |
143 | Pfe_Tlb.TlbTte.__setfun__['real'] = __tte_setreal__ | |
144 | Pfe_Tlb.TlbTte.__getfun__['pid'] = __tte_getpid__ | |
145 | Pfe_Tlb.TlbTte.__setfun__['pid'] = __tte_setpid__ | |
146 | Pfe_Tlb.TlbTte.__getfun__['ctx'] = __tte_getctx__ | |
147 | Pfe_Tlb.TlbTte.__setfun__['ctx'] = __tte_setctx__ | |
148 | Pfe_Tlb.TlbTte.__getfun__['size'] = __tte_getsize__ | |
149 | Pfe_Tlb.TlbTte.__setfun__['size'] = __tte_setsize__ | |
150 | Pfe_Tlb.TlbTte.__getfun__['tag'] = __tte_gettag__ | |
151 | Pfe_Tlb.TlbTte.__setfun__['tag'] = __tte_settag__ | |
152 | Pfe_Tlb.TlbTte.__getfun__['ie'] = __tte_getie__ | |
153 | Pfe_Tlb.TlbTte.__setfun__['ie'] = __tte_setie__ | |
154 | Pfe_Tlb.TlbTte.__getfun__['nfo'] = __tte_getnfo__ | |
155 | Pfe_Tlb.TlbTte.__setfun__['nfo'] = __tte_setnfo__ | |
156 | Pfe_Tlb.TlbTte.__getfun__['x'] = __tte_getx__ | |
157 | Pfe_Tlb.TlbTte.__setfun__['x'] = __tte_setx__ | |
158 | Pfe_Tlb.TlbTte.__getfun__['p'] = __tte_getp__ | |
159 | Pfe_Tlb.TlbTte.__setfun__['p'] = __tte_setp__ | |
160 | Pfe_Tlb.TlbTte.__getfun__['w'] = __tte_getw__ | |
161 | Pfe_Tlb.TlbTte.__setfun__['w'] = __tte_setw__ | |
162 | Pfe_Tlb.TlbTte.__getfun__['e'] = __tte_gete__ | |
163 | Pfe_Tlb.TlbTte.__setfun__['e'] = __tte_sete__ | |
164 | Pfe_Tlb.TlbTte.__getfun__['addr'] = __tte_getaddr__ | |
165 | Pfe_Tlb.TlbTte.__setfun__['addr'] = __tte_setaddr__ | |
166 | ||
167 | Pfe_Tlb.TlbTte.__getfun__['cv'] = __tte_getfalse__ | |
168 | Pfe_Tlb.TlbTte.__setfun__['cv'] = __tte_setpass__ | |
169 | Pfe_Tlb.TlbTte.__getfun__['cp'] = __tte_getfalse__ | |
170 | Pfe_Tlb.TlbTte.__setfun__['cp'] = __tte_setpass__ | |
171 | Pfe_Tlb.TlbTte.__getfun__['lock'] = __tte_getfalse__ | |
172 | Pfe_Tlb.TlbTte.__setfun__['lock'] = __tte_setpass__ | |
173 | ||
174 | ||
175 | class Tlb(Pfe_Tlb.Tlb): | |
176 | def __init__(self,tlb): | |
177 | Pfe_Tlb.Tlb.__init__(self,tlb) | |
178 | ||
179 | def size(self): | |
180 | return self.__tlb__.size() | |
181 | ||
182 | def index(self,index): | |
183 | if index < 0 or index >= self.size(): | |
184 | raise IndexError | |
185 | else: | |
186 | return self.__tlb__.get(index) | |
187 | ||
188 | def insert(self,tte): | |
189 | if isinstance(tte,Tte): | |
190 | ss_tte = N2_Python.SS_Tte() | |
191 | __tte_setr__(ss_tte,tte.r) | |
192 | __tte_setvalid__(ss_tte,tte.valid) | |
193 | __tte_setctx__(ss_tte,tte.ctx) | |
194 | __tte_setpid__(ss_tte,tte.pid) | |
195 | __tte_settag__(ss_tte,tte.tag) | |
196 | __tte_setsize__(ss_tte,tte.size) | |
197 | __tte_setie__(ss_tte,tte.ie) | |
198 | __tte_setnfo__(ss_tte,tte.nfo) | |
199 | __tte_setx__(ss_tte,tte.x) | |
200 | __tte_setp__(ss_tte,tte.p) | |
201 | __tte_setw__(ss_tte,tte.w) | |
202 | __tte_setaddr__(ss_tte,tte.addr) | |
203 | self.__tlb__.insert(ss_tte) | |
204 | else: | |
205 | raise TypeError | |
206 | ||
207 | ||
208 | class Core(Pfe_Model.Core): | |
209 | def __init__(self,core,ref): | |
210 | Pfe_Model.Core.__init__(self) | |
211 | self.inst_tlb = Tlb(core.inst_tlb) | |
212 | self.data_tlb = Tlb(core.data_tlb) | |
213 | for i in range(0,core.strand_cnt()): | |
214 | strand_ref = 's'+str(i) | |
215 | strand_ptr = core.strand_ptr(i) | |
216 | strand = SS_Strand.Strand(strand_ptr,ref+'.'+strand_ref,N2_Python) | |
217 | self.__dict__[strand_ref] = strand | |
218 | self.s.append(strand) | |
219 | strand.__dict__['inst_tlb'] = self.inst_tlb | |
220 | strand.__dict__['data_tlb'] = self.data_tlb | |
221 | ||
222 | ||
223 | class Cpu(Pfe_Model.Cpu): | |
224 | def __init__(self,cpu,ref): | |
225 | Pfe_Model.Cpu.__init__(self) | |
226 | self.hard_reset = cpu.hard_reset | |
227 | for i in range(0,cpu.core_cnt()): | |
228 | core_ref = 'c'+str(i) | |
229 | core_ptr = cpu.core_ptr(i) | |
230 | core = Core(core_ptr,ref+'.'+core_ref) | |
231 | self.__dict__[core_ref] = core | |
232 | self.c.append(core) | |
233 | ||
234 | ||
235 | class Model(Pfe_Model.Model): | |
236 | def __init__(self,mem,io,model=None): | |
237 | Pfe_Model.Model.__init__(self) | |
238 | self.mem = mem | |
239 | self.io = io | |
240 | self.__model__ = model | |
241 | mem.__flush__ = model.flush | |
242 | if model: | |
243 | for i in range(0,model.cpu_cnt()): | |
244 | cpu_ref = 'p'+str(i) | |
245 | cpu_ptr = model.cpu_ptr(i) | |
246 | cpu = Cpu(cpu_ptr,cpu_ref) | |
247 | self.p.append(cpu) | |
248 | self.__dict__[cpu_ref] = cpu | |
249 | self.__populate__() | |
250 | ||
251 | def __create_cpu__(self,count,cpu_lst=[]): | |
252 | for i in range(0,count): | |
253 | cpu_ref = 'p'+str(i) | |
254 | if i < len(cpu_lst): | |
255 | cpu_ptr = cpu_lst[i] | |
256 | else: | |
257 | cpu_ptr = N2_Python.N2_Cpu(cpu_ref) | |
258 | cpu = Cpu(cpu_ptr,cpu_ref) | |
259 | self.p.append(cpu) | |
260 | self.__dict__[cpu_ref] = cpu | |
261 | self.__populate__() | |
262 | return True | |
263 | ||
264 | def ras_enable(self): | |
265 | return self.__model__.ras_enable() |