1 //
2 // Copyright (c) 2010-2025 Antmicro
3 // Copyright (c) 2022-2025 Silicon Labs
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 
9 /*  WARNING: Auto-Generated Peripheral  -  DO NOT EDIT
10     HFRCO, Generated on : 2023-07-20 14:23:50.603902
11     HFRCO, ID Version : 165adedf604742fda856a08648e115e5.2 */
12 
13 /* Here is the template for your defined by hand class. Don't forget to add your eventual constructor with extra parameter.
14 
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
16 using System;
17 using System.IO;
18 using System.Collections.Generic;
19 using Antmicro.Renode.Core;
20 using Antmicro.Renode.Core.Structure.Registers;
21 using Antmicro.Renode.Logging;
22 using Antmicro.Renode.Exceptions;
23 using Antmicro.Renode.Peripherals.CPU;
24 using Antmicro.Renode.Peripherals.Bus;
25 
26 namespace Antmicro.Renode.Peripherals.Miscellaneous.SiLabs
27 {
28     public partial class EFR32xG2_HFRCO_2
29     {
30         public EFR32xG2_HFRCO_2(Machine machine) : base(machine)
31         {
32             EFR32xG2_HFRCO_2_constructor();
33         }
34     }
35 }
36 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
37 
38 using System;
39 using System.IO;
40 using System.Collections.Generic;
41 using Antmicro.Renode.Core;
42 using Antmicro.Renode.Core.Structure.Registers;
43 using Antmicro.Renode.Logging;
44 using Antmicro.Renode.Exceptions;
45 using Antmicro.Renode.Peripherals.Bus;
46 
47 
48 namespace Antmicro.Renode.Peripherals.Miscellaneous.SiLabs
49 {
50     public partial class EFR32xG2_HFRCO_2 : BasicDoubleWordPeripheral, IKnownSize
51     {
EFR32xG2_HFRCO_2(Machine machine)52         public EFR32xG2_HFRCO_2(Machine machine) : base(machine)
53         {
54             Define_Registers();
55             EFR32xG2_HFRCO_2_Constructor();
56         }
57 
Define_Registers()58         private void Define_Registers()
59         {
60             var registersMap = new Dictionary<long, DoubleWordRegister>
61             {
62                 {(long)Registers.Ipversion, GenerateIpversionRegister()},
63                 {(long)Registers.Ctrl, GenerateCtrlRegister()},
64                 {(long)Registers.Cal, GenerateCalRegister()},
65                 {(long)Registers.Status, GenerateStatusRegister()},
66                 {(long)Registers.If, GenerateIfRegister()},
67                 {(long)Registers.Ien, GenerateIenRegister()},
68                 {(long)Registers.Lock, GenerateLockRegister()},
69                 {(long)Registers.Test, GenerateTestRegister()},
70                 {(long)Registers.Feature, GenerateFeatureRegister()},
71             };
72             registers = new DoubleWordRegisterCollection(this, registersMap);
73         }
74 
Reset()75         public override void Reset()
76         {
77             base.Reset();
78             HFRCO_Reset();
79         }
80 
81         protected enum CAL_CLKDIV
82         {
83             DIV1 = 0, // Divide by 1.
84             DIV2 = 1, // Divide by 2.
85             DIV4 = 2, // Divide by 4.
86         }
87 
88         protected enum STATUS_LOCK
89         {
90             UNLOCKED = 0, // HFRCO is unlocked
91             LOCKED = 1, // HFRCO is locked
92         }
93 
94         // Ipversion - Offset : 0x0
GenerateIpversionRegister()95         protected DoubleWordRegister  GenerateIpversionRegister() => new DoubleWordRegister(this, 0x2)
96             .WithValueField(0, 32, out ipversion_ipversion_field, FieldMode.Read,
97                     valueProviderCallback: (_) => {
98                         Ipversion_Ipversion_ValueProvider(_);
99                         return ipversion_ipversion_field.Value;
100                     },
101                     readCallback: (_, __) => Ipversion_Ipversion_Read(_, __),
102                     name: "Ipversion")
103             .WithReadCallback((_, __) => Ipversion_Read(_, __))
104             .WithWriteCallback((_, __) => Ipversion_Write(_, __));
105 
106         // Ctrl - Offset : 0x4
GenerateCtrlRegister()107         protected DoubleWordRegister  GenerateCtrlRegister() => new DoubleWordRegister(this, 0x0)
108             .WithFlag(0, out ctrl_forceen_bit,
109                     valueProviderCallback: (_) => {
110                         Ctrl_Forceen_ValueProvider(_);
111                         return ctrl_forceen_bit.Value;
112                     },
113                     writeCallback: (_, __) => Ctrl_Forceen_Write(_, __),
114                     readCallback: (_, __) => Ctrl_Forceen_Read(_, __),
115                     name: "Forceen")
116             .WithFlag(1, out ctrl_disondemand_bit,
117                     valueProviderCallback: (_) => {
118                         Ctrl_Disondemand_ValueProvider(_);
119                         return ctrl_disondemand_bit.Value;
120                     },
121                     writeCallback: (_, __) => Ctrl_Disondemand_Write(_, __),
122                     readCallback: (_, __) => Ctrl_Disondemand_Read(_, __),
123                     name: "Disondemand")
124             .WithFlag(2, out ctrl_em23ondemand_bit,
125                     valueProviderCallback: (_) => {
126                         Ctrl_Em23ondemand_ValueProvider(_);
127                         return ctrl_em23ondemand_bit.Value;
128                     },
129                     writeCallback: (_, __) => Ctrl_Em23ondemand_Write(_, __),
130                     readCallback: (_, __) => Ctrl_Em23ondemand_Read(_, __),
131                     name: "Em23ondemand")
132             .WithReservedBits(3, 29)
133             .WithReadCallback((_, __) => Ctrl_Read(_, __))
134             .WithWriteCallback((_, __) => Ctrl_Write(_, __));
135 
136         // Cal - Offset : 0x8
GenerateCalRegister()137         protected DoubleWordRegister  GenerateCalRegister() => new DoubleWordRegister(this, 0xA8689F7F)
138             .WithValueField(0, 7, out cal_tuning_field,
139                     valueProviderCallback: (_) => {
140                         Cal_Tuning_ValueProvider(_);
141                         return cal_tuning_field.Value;
142                     },
143                     writeCallback: (_, __) => {
144                         WriteRWSYNC();
145                         Cal_Tuning_Write(_, __);
146                     },
147                     readCallback: (_, __) => Cal_Tuning_Read(_, __),
148                     name: "Tuning")
149             .WithReservedBits(7, 1)
150             .WithValueField(8, 6, out cal_finetuning_field,
151                     valueProviderCallback: (_) => {
152                         Cal_Finetuning_ValueProvider(_);
153                         return cal_finetuning_field.Value;
154                     },
155                     writeCallback: (_, __) => {
156                         WriteRWSYNC();
157                         Cal_Finetuning_Write(_, __);
158                     },
159                     readCallback: (_, __) => Cal_Finetuning_Read(_, __),
160                     name: "Finetuning")
161             .WithReservedBits(14, 1)
162             .WithFlag(15, out cal_ldohp_bit,
163                     valueProviderCallback: (_) => {
164                         Cal_Ldohp_ValueProvider(_);
165                         return cal_ldohp_bit.Value;
166                     },
167                     writeCallback: (_, __) => {
168                         WriteRWSYNC();
169                         Cal_Ldohp_Write(_, __);
170                     },
171                     readCallback: (_, __) => Cal_Ldohp_Read(_, __),
172                     name: "Ldohp")
173             .WithValueField(16, 5, out cal_freqrange_field,
174                     valueProviderCallback: (_) => {
175                         Cal_Freqrange_ValueProvider(_);
176                         return cal_freqrange_field.Value;
177                     },
178                     writeCallback: (_, __) => {
179                         WriteRWSYNC();
180                         Cal_Freqrange_Write(_, __);
181                     },
182                     readCallback: (_, __) => Cal_Freqrange_Read(_, __),
183                     name: "Freqrange")
184             .WithValueField(21, 3, out cal_cmpbias_field,
185                     valueProviderCallback: (_) => {
186                         Cal_Cmpbias_ValueProvider(_);
187                         return cal_cmpbias_field.Value;
188                     },
189                     writeCallback: (_, __) => {
190                         WriteRWSYNC();
191                         Cal_Cmpbias_Write(_, __);
192                     },
193                     readCallback: (_, __) => Cal_Cmpbias_Read(_, __),
194                     name: "Cmpbias")
195             .WithEnumField<DoubleWordRegister, CAL_CLKDIV>(24, 2, out cal_clkdiv_field,
196                     valueProviderCallback: (_) => {
197                         Cal_Clkdiv_ValueProvider(_);
198                         return cal_clkdiv_field.Value;
199                     },
200                     writeCallback: (_, __) => {
201                         WriteRWSYNC();
202                         Cal_Clkdiv_Write(_, __);
203                     },
204                     readCallback: (_, __) => Cal_Clkdiv_Read(_, __),
205                     name: "Clkdiv")
206             .WithValueField(26, 2, out cal_cmpsel_field,
207                     valueProviderCallback: (_) => {
208                         Cal_Cmpsel_ValueProvider(_);
209                         return cal_cmpsel_field.Value;
210                     },
211                     writeCallback: (_, __) => {
212                         WriteRWSYNC();
213                         Cal_Cmpsel_Write(_, __);
214                     },
215                     readCallback: (_, __) => Cal_Cmpsel_Read(_, __),
216                     name: "Cmpsel")
217             .WithValueField(28, 4, out cal_ireftc_field,
218                     valueProviderCallback: (_) => {
219                         Cal_Ireftc_ValueProvider(_);
220                         return cal_ireftc_field.Value;
221                     },
222                     writeCallback: (_, __) => {
223                         WriteRWSYNC();
224                         Cal_Ireftc_Write(_, __);
225                     },
226                     readCallback: (_, __) => Cal_Ireftc_Read(_, __),
227                     name: "Ireftc")
228             .WithReadCallback((_, __) => Cal_Read(_, __))
229             .WithWriteCallback((_, __) => Cal_Write(_, __));
230 
231         // Status - Offset : 0xC
GenerateStatusRegister()232         protected DoubleWordRegister  GenerateStatusRegister() => new DoubleWordRegister(this, 0x0)
233             .WithFlag(0, out status_rdy_bit, FieldMode.Read,
234                     valueProviderCallback: (_) => {
235                         Status_Rdy_ValueProvider(_);
236                         return status_rdy_bit.Value;
237                     },
238                     readCallback: (_, __) => Status_Rdy_Read(_, __),
239                     name: "Rdy")
240             .WithFlag(1, out status_freqbsy_bit, FieldMode.Read,
241                     valueProviderCallback: (_) => {
242                         Status_Freqbsy_ValueProvider(_);
243                         return status_freqbsy_bit.Value;
244                     },
245                     readCallback: (_, __) => Status_Freqbsy_Read(_, __),
246                     name: "Freqbsy")
247             .WithFlag(2, out status_syncbusy_bit, FieldMode.Read,
248                     valueProviderCallback: (_) => {
249                         Status_Syncbusy_ValueProvider(_);
250                         return status_syncbusy_bit.Value;
251                     },
252                     readCallback: (_, __) => Status_Syncbusy_Read(_, __),
253                     name: "Syncbusy")
254             .WithReservedBits(3, 13)
255             .WithFlag(16, out status_ens_bit, FieldMode.Read,
256                     valueProviderCallback: (_) => {
257                         Status_Ens_ValueProvider(_);
258                         return status_ens_bit.Value;
259                     },
260                     readCallback: (_, __) => Status_Ens_Read(_, __),
261                     name: "Ens")
262             .WithReservedBits(17, 14)
263             .WithEnumField<DoubleWordRegister, STATUS_LOCK>(31, 1, out status_lock_bit, FieldMode.Read,
264                     valueProviderCallback: (_) => {
265                         Status_Lock_ValueProvider(_);
266                         return status_lock_bit.Value;
267                     },
268                     readCallback: (_, __) => Status_Lock_Read(_, __),
269                     name: "Lock")
270             .WithReadCallback((_, __) => Status_Read(_, __))
271             .WithWriteCallback((_, __) => Status_Write(_, __));
272 
273         // If - Offset : 0x10
GenerateIfRegister()274         protected DoubleWordRegister  GenerateIfRegister() => new DoubleWordRegister(this, 0x0)
275             .WithFlag(0, out if_rdy_bit,
276                     valueProviderCallback: (_) => {
277                         If_Rdy_ValueProvider(_);
278                         return if_rdy_bit.Value;
279                     },
280                     writeCallback: (_, __) => If_Rdy_Write(_, __),
281                     readCallback: (_, __) => If_Rdy_Read(_, __),
282                     name: "Rdy")
283             .WithReservedBits(1, 31)
284             .WithReadCallback((_, __) => If_Read(_, __))
285             .WithWriteCallback((_, __) => If_Write(_, __));
286 
287         // Ien - Offset : 0x14
GenerateIenRegister()288         protected DoubleWordRegister  GenerateIenRegister() => new DoubleWordRegister(this, 0x0)
289             .WithFlag(0, out ien_rdy_bit,
290                     valueProviderCallback: (_) => {
291                         Ien_Rdy_ValueProvider(_);
292                         return ien_rdy_bit.Value;
293                     },
294                     writeCallback: (_, __) => Ien_Rdy_Write(_, __),
295                     readCallback: (_, __) => Ien_Rdy_Read(_, __),
296                     name: "Rdy")
297             .WithReservedBits(1, 31)
298             .WithReadCallback((_, __) => Ien_Read(_, __))
299             .WithWriteCallback((_, __) => Ien_Write(_, __));
300 
301         // Lock - Offset : 0x1C
GenerateLockRegister()302         protected DoubleWordRegister  GenerateLockRegister() => new DoubleWordRegister(this, 0x8195)
303             .WithValueField(0, 16, out lock_lockkey_field, FieldMode.Write,
304                     writeCallback: (_, __) => Lock_Lockkey_Write(_, __),
305                     name: "Lockkey")
306             .WithReservedBits(16, 16)
307             .WithReadCallback((_, __) => Lock_Read(_, __))
308             .WithWriteCallback((_, __) => Lock_Write(_, __));
309 
310         // Test - Offset : 0x20
GenerateTestRegister()311         protected DoubleWordRegister  GenerateTestRegister() => new DoubleWordRegister(this, 0x4)
312             .WithFlag(0, out test_inv_bit,
313                     valueProviderCallback: (_) => {
314                         Test_Inv_ValueProvider(_);
315                         return test_inv_bit.Value;
316                     },
317                     writeCallback: (_, __) => Test_Inv_Write(_, __),
318                     readCallback: (_, __) => Test_Inv_Read(_, __),
319                     name: "Inv")
320             .WithFlag(1, out test_maxtoen_bit,
321                     valueProviderCallback: (_) => {
322                         Test_Maxtoen_ValueProvider(_);
323                         return test_maxtoen_bit.Value;
324                     },
325                     writeCallback: (_, __) => Test_Maxtoen_Write(_, __),
326                     readCallback: (_, __) => Test_Maxtoen_Read(_, __),
327                     name: "Maxtoen")
328             .WithFlag(2, out test_clkoutdis0_bit,
329                     valueProviderCallback: (_) => {
330                         Test_Clkoutdis0_ValueProvider(_);
331                         return test_clkoutdis0_bit.Value;
332                     },
333                     writeCallback: (_, __) => Test_Clkoutdis0_Write(_, __),
334                     readCallback: (_, __) => Test_Clkoutdis0_Read(_, __),
335                     name: "Clkoutdis0")
336             .WithFlag(3, out test_clkoutdis1_bit,
337                     valueProviderCallback: (_) => {
338                         Test_Clkoutdis1_ValueProvider(_);
339                         return test_clkoutdis1_bit.Value;
340                     },
341                     writeCallback: (_, __) => Test_Clkoutdis1_Write(_, __),
342                     readCallback: (_, __) => Test_Clkoutdis1_Read(_, __),
343                     name: "Clkoutdis1")
344             .WithReservedBits(4, 28)
345             .WithReadCallback((_, __) => Test_Read(_, __))
346             .WithWriteCallback((_, __) => Test_Write(_, __));
347 
348         // Feature - Offset : 0x24
GenerateFeatureRegister()349         protected DoubleWordRegister  GenerateFeatureRegister() => new DoubleWordRegister(this, 0x0)
350             .WithFlag(0, out feature_force40_bit,
351                     valueProviderCallback: (_) => {
352                         Feature_Force40_ValueProvider(_);
353                         return feature_force40_bit.Value;
354                     },
355                     writeCallback: (_, __) => Feature_Force40_Write(_, __),
356                     readCallback: (_, __) => Feature_Force40_Read(_, __),
357                     name: "Force40")
358             .WithReservedBits(1, 31)
359             .WithReadCallback((_, __) => Feature_Read(_, __))
360             .WithWriteCallback((_, __) => Feature_Write(_, __));
361 
362 
ReadWFIFO()363         private uint ReadWFIFO()
364         {
365             this.Log(LogLevel.Warning, "Reading from a WFIFO Field, value returned will always be 0");
366             return 0x0;
367         }
368 
ReadLFWSYNC()369         private uint ReadLFWSYNC()
370         {
371             this.Log(LogLevel.Warning, "Reading from a LFWSYNC/HVLFWSYNC Field, value returned will always be 0");
372             return 0x0;
373         }
374 
ReadRFIFO()375         private uint ReadRFIFO()
376         {
377             this.Log(LogLevel.Warning, "Reading from a RFIFO Field, value returned will always be 0");
378             return 0x0;
379         }
380 
381 
382 
383 
WriteRWSYNC()384         private void WriteRWSYNC()
385         {
386             if(!Enabled)
387             {
388                 this.Log(LogLevel.Error, "Trying to write to a RWSYNC register while peripheral is disabled EN = {0}", Enabled);
389             }
390         }
391 
392         // Ipversion - Offset : 0x0
393         protected IValueRegisterField ipversion_ipversion_field;
Ipversion_Ipversion_Read(ulong a, ulong b)394         partial void Ipversion_Ipversion_Read(ulong a, ulong b);
Ipversion_Ipversion_ValueProvider(ulong a)395         partial void Ipversion_Ipversion_ValueProvider(ulong a);
396 
Ipversion_Write(uint a, uint b)397         partial void Ipversion_Write(uint a, uint b);
Ipversion_Read(uint a, uint b)398         partial void Ipversion_Read(uint a, uint b);
399 
400         // Ctrl - Offset : 0x4
401         protected IFlagRegisterField ctrl_forceen_bit;
Ctrl_Forceen_Write(bool a, bool b)402         partial void Ctrl_Forceen_Write(bool a, bool b);
Ctrl_Forceen_Read(bool a, bool b)403         partial void Ctrl_Forceen_Read(bool a, bool b);
Ctrl_Forceen_ValueProvider(bool a)404         partial void Ctrl_Forceen_ValueProvider(bool a);
405         protected IFlagRegisterField ctrl_disondemand_bit;
Ctrl_Disondemand_Write(bool a, bool b)406         partial void Ctrl_Disondemand_Write(bool a, bool b);
Ctrl_Disondemand_Read(bool a, bool b)407         partial void Ctrl_Disondemand_Read(bool a, bool b);
Ctrl_Disondemand_ValueProvider(bool a)408         partial void Ctrl_Disondemand_ValueProvider(bool a);
409         protected IFlagRegisterField ctrl_em23ondemand_bit;
Ctrl_Em23ondemand_Write(bool a, bool b)410         partial void Ctrl_Em23ondemand_Write(bool a, bool b);
Ctrl_Em23ondemand_Read(bool a, bool b)411         partial void Ctrl_Em23ondemand_Read(bool a, bool b);
Ctrl_Em23ondemand_ValueProvider(bool a)412         partial void Ctrl_Em23ondemand_ValueProvider(bool a);
413 
Ctrl_Write(uint a, uint b)414         partial void Ctrl_Write(uint a, uint b);
Ctrl_Read(uint a, uint b)415         partial void Ctrl_Read(uint a, uint b);
416 
417         // Cal - Offset : 0x8
418         protected IValueRegisterField cal_tuning_field;
Cal_Tuning_Write(ulong a, ulong b)419         partial void Cal_Tuning_Write(ulong a, ulong b);
Cal_Tuning_Read(ulong a, ulong b)420         partial void Cal_Tuning_Read(ulong a, ulong b);
Cal_Tuning_ValueProvider(ulong a)421         partial void Cal_Tuning_ValueProvider(ulong a);
422         protected IValueRegisterField cal_finetuning_field;
Cal_Finetuning_Write(ulong a, ulong b)423         partial void Cal_Finetuning_Write(ulong a, ulong b);
Cal_Finetuning_Read(ulong a, ulong b)424         partial void Cal_Finetuning_Read(ulong a, ulong b);
Cal_Finetuning_ValueProvider(ulong a)425         partial void Cal_Finetuning_ValueProvider(ulong a);
426         protected IFlagRegisterField cal_ldohp_bit;
Cal_Ldohp_Write(bool a, bool b)427         partial void Cal_Ldohp_Write(bool a, bool b);
Cal_Ldohp_Read(bool a, bool b)428         partial void Cal_Ldohp_Read(bool a, bool b);
Cal_Ldohp_ValueProvider(bool a)429         partial void Cal_Ldohp_ValueProvider(bool a);
430         protected IValueRegisterField cal_freqrange_field;
Cal_Freqrange_Write(ulong a, ulong b)431         partial void Cal_Freqrange_Write(ulong a, ulong b);
Cal_Freqrange_Read(ulong a, ulong b)432         partial void Cal_Freqrange_Read(ulong a, ulong b);
Cal_Freqrange_ValueProvider(ulong a)433         partial void Cal_Freqrange_ValueProvider(ulong a);
434         protected IValueRegisterField cal_cmpbias_field;
Cal_Cmpbias_Write(ulong a, ulong b)435         partial void Cal_Cmpbias_Write(ulong a, ulong b);
Cal_Cmpbias_Read(ulong a, ulong b)436         partial void Cal_Cmpbias_Read(ulong a, ulong b);
Cal_Cmpbias_ValueProvider(ulong a)437         partial void Cal_Cmpbias_ValueProvider(ulong a);
438         protected IEnumRegisterField<CAL_CLKDIV> cal_clkdiv_field;
Cal_Clkdiv_Write(CAL_CLKDIV a, CAL_CLKDIV b)439         partial void Cal_Clkdiv_Write(CAL_CLKDIV a, CAL_CLKDIV b);
Cal_Clkdiv_Read(CAL_CLKDIV a, CAL_CLKDIV b)440         partial void Cal_Clkdiv_Read(CAL_CLKDIV a, CAL_CLKDIV b);
Cal_Clkdiv_ValueProvider(CAL_CLKDIV a)441         partial void Cal_Clkdiv_ValueProvider(CAL_CLKDIV a);
442         protected IValueRegisterField cal_cmpsel_field;
Cal_Cmpsel_Write(ulong a, ulong b)443         partial void Cal_Cmpsel_Write(ulong a, ulong b);
Cal_Cmpsel_Read(ulong a, ulong b)444         partial void Cal_Cmpsel_Read(ulong a, ulong b);
Cal_Cmpsel_ValueProvider(ulong a)445         partial void Cal_Cmpsel_ValueProvider(ulong a);
446         protected IValueRegisterField cal_ireftc_field;
Cal_Ireftc_Write(ulong a, ulong b)447         partial void Cal_Ireftc_Write(ulong a, ulong b);
Cal_Ireftc_Read(ulong a, ulong b)448         partial void Cal_Ireftc_Read(ulong a, ulong b);
Cal_Ireftc_ValueProvider(ulong a)449         partial void Cal_Ireftc_ValueProvider(ulong a);
450 
Cal_Write(uint a, uint b)451         partial void Cal_Write(uint a, uint b);
Cal_Read(uint a, uint b)452         partial void Cal_Read(uint a, uint b);
453 
454         // Status - Offset : 0xC
455         protected IFlagRegisterField status_rdy_bit;
Status_Rdy_Read(bool a, bool b)456         partial void Status_Rdy_Read(bool a, bool b);
Status_Rdy_ValueProvider(bool a)457         partial void Status_Rdy_ValueProvider(bool a);
458         protected IFlagRegisterField status_freqbsy_bit;
Status_Freqbsy_Read(bool a, bool b)459         partial void Status_Freqbsy_Read(bool a, bool b);
Status_Freqbsy_ValueProvider(bool a)460         partial void Status_Freqbsy_ValueProvider(bool a);
461         protected IFlagRegisterField status_syncbusy_bit;
Status_Syncbusy_Read(bool a, bool b)462         partial void Status_Syncbusy_Read(bool a, bool b);
Status_Syncbusy_ValueProvider(bool a)463         partial void Status_Syncbusy_ValueProvider(bool a);
464         protected IFlagRegisterField status_ens_bit;
Status_Ens_Read(bool a, bool b)465         partial void Status_Ens_Read(bool a, bool b);
Status_Ens_ValueProvider(bool a)466         partial void Status_Ens_ValueProvider(bool a);
467         protected IEnumRegisterField<STATUS_LOCK> status_lock_bit;
Status_Lock_Read(STATUS_LOCK a, STATUS_LOCK b)468         partial void Status_Lock_Read(STATUS_LOCK a, STATUS_LOCK b);
Status_Lock_ValueProvider(STATUS_LOCK a)469         partial void Status_Lock_ValueProvider(STATUS_LOCK a);
470 
Status_Write(uint a, uint b)471         partial void Status_Write(uint a, uint b);
Status_Read(uint a, uint b)472         partial void Status_Read(uint a, uint b);
473 
474         // If - Offset : 0x10
475         protected IFlagRegisterField if_rdy_bit;
If_Rdy_Write(bool a, bool b)476         partial void If_Rdy_Write(bool a, bool b);
If_Rdy_Read(bool a, bool b)477         partial void If_Rdy_Read(bool a, bool b);
If_Rdy_ValueProvider(bool a)478         partial void If_Rdy_ValueProvider(bool a);
479 
If_Write(uint a, uint b)480         partial void If_Write(uint a, uint b);
If_Read(uint a, uint b)481         partial void If_Read(uint a, uint b);
482 
483         // Ien - Offset : 0x14
484         protected IFlagRegisterField ien_rdy_bit;
Ien_Rdy_Write(bool a, bool b)485         partial void Ien_Rdy_Write(bool a, bool b);
Ien_Rdy_Read(bool a, bool b)486         partial void Ien_Rdy_Read(bool a, bool b);
Ien_Rdy_ValueProvider(bool a)487         partial void Ien_Rdy_ValueProvider(bool a);
488 
Ien_Write(uint a, uint b)489         partial void Ien_Write(uint a, uint b);
Ien_Read(uint a, uint b)490         partial void Ien_Read(uint a, uint b);
491 
492         // Lock - Offset : 0x1C
493         protected IValueRegisterField lock_lockkey_field;
Lock_Lockkey_Write(ulong a, ulong b)494         partial void Lock_Lockkey_Write(ulong a, ulong b);
Lock_Lockkey_ValueProvider(ulong a)495         partial void Lock_Lockkey_ValueProvider(ulong a);
496 
Lock_Write(uint a, uint b)497         partial void Lock_Write(uint a, uint b);
Lock_Read(uint a, uint b)498         partial void Lock_Read(uint a, uint b);
499 
500         // Test - Offset : 0x20
501         protected IFlagRegisterField test_inv_bit;
Test_Inv_Write(bool a, bool b)502         partial void Test_Inv_Write(bool a, bool b);
Test_Inv_Read(bool a, bool b)503         partial void Test_Inv_Read(bool a, bool b);
Test_Inv_ValueProvider(bool a)504         partial void Test_Inv_ValueProvider(bool a);
505         protected IFlagRegisterField test_maxtoen_bit;
Test_Maxtoen_Write(bool a, bool b)506         partial void Test_Maxtoen_Write(bool a, bool b);
Test_Maxtoen_Read(bool a, bool b)507         partial void Test_Maxtoen_Read(bool a, bool b);
Test_Maxtoen_ValueProvider(bool a)508         partial void Test_Maxtoen_ValueProvider(bool a);
509         protected IFlagRegisterField test_clkoutdis0_bit;
Test_Clkoutdis0_Write(bool a, bool b)510         partial void Test_Clkoutdis0_Write(bool a, bool b);
Test_Clkoutdis0_Read(bool a, bool b)511         partial void Test_Clkoutdis0_Read(bool a, bool b);
Test_Clkoutdis0_ValueProvider(bool a)512         partial void Test_Clkoutdis0_ValueProvider(bool a);
513         protected IFlagRegisterField test_clkoutdis1_bit;
Test_Clkoutdis1_Write(bool a, bool b)514         partial void Test_Clkoutdis1_Write(bool a, bool b);
Test_Clkoutdis1_Read(bool a, bool b)515         partial void Test_Clkoutdis1_Read(bool a, bool b);
Test_Clkoutdis1_ValueProvider(bool a)516         partial void Test_Clkoutdis1_ValueProvider(bool a);
517 
Test_Write(uint a, uint b)518         partial void Test_Write(uint a, uint b);
Test_Read(uint a, uint b)519         partial void Test_Read(uint a, uint b);
520 
521         // Feature - Offset : 0x24
522         protected IFlagRegisterField feature_force40_bit;
Feature_Force40_Write(bool a, bool b)523         partial void Feature_Force40_Write(bool a, bool b);
Feature_Force40_Read(bool a, bool b)524         partial void Feature_Force40_Read(bool a, bool b);
Feature_Force40_ValueProvider(bool a)525         partial void Feature_Force40_ValueProvider(bool a);
526 
Feature_Write(uint a, uint b)527         partial void Feature_Write(uint a, uint b);
Feature_Read(uint a, uint b)528         partial void Feature_Read(uint a, uint b);
529 
HFRCO_Reset()530         partial void HFRCO_Reset();
531 
EFR32xG2_HFRCO_2_Constructor()532         partial void EFR32xG2_HFRCO_2_Constructor();
533 
534         public bool Enabled
535         {
536             get
537             {
538                 // Your boolean which you have to define in your partial class file
539                 return isEnabled;
540             }
541         }
542 
543         private ICMU_EFR32xG2 _cmu;
544         private ICMU_EFR32xG2 cmu
545         {
546             get
547             {
548                 if (Object.ReferenceEquals(_cmu, null))
549                 {
550                     foreach(var cmu in machine.GetPeripheralsOfType<ICMU_EFR32xG2>())
551                     {
552                         _cmu = cmu;
553                     }
554                 }
555                 return _cmu;
556             }
557             set
558             {
559                 _cmu = value;
560             }
561         }
562 
ReadDoubleWord(long offset)563         public override uint ReadDoubleWord(long offset)
564         {
565             long temp = offset & 0x0FFF;
566             switch(offset & 0x3000){
567                 case 0x0000:
568                     return registers.Read(offset);
569                 default:
570                     this.Log(LogLevel.Warning, "Reading from Set/Clr/Tgl is not supported.");
571                     return registers.Read(temp);
572             }
573         }
574 
WriteDoubleWord(long address, uint value)575         public override void WriteDoubleWord(long address, uint value)
576         {
577             long temp = address & 0x0FFF;
578             switch(address & 0x3000){
579                 case 0x0000:
580                     registers.Write(address, value);
581                     break;
582                 case 0x1000:
583                     registers.Write(temp, registers.Read(temp) | value);
584                     break;
585                 case 0x2000:
586                     registers.Write(temp, registers.Read(temp) & ~value);
587                     break;
588                 case 0x3000:
589                     registers.Write(temp, registers.Read(temp) ^ value);
590                     break;
591                 default:
592                     this.Log(LogLevel.Error, "writing doubleWord to non existing offset {0:X}, case : {1:X}", address, address & 0x3000);
593                     break;
594             }
595         }
596 
597         protected enum Registers
598         {
599             Ipversion = 0x0,
600             Ctrl = 0x4,
601             Cal = 0x8,
602             Status = 0xC,
603             If = 0x10,
604             Ien = 0x14,
605             Lock = 0x1C,
606             Test = 0x20,
607             Feature = 0x24,
608 
609             Ipversion_SET = 0x1000,
610             Ctrl_SET = 0x1004,
611             Cal_SET = 0x1008,
612             Status_SET = 0x100C,
613             If_SET = 0x1010,
614             Ien_SET = 0x1014,
615             Lock_SET = 0x101C,
616             Test_SET = 0x1020,
617             Feature_SET = 0x1024,
618 
619             Ipversion_CLR = 0x2000,
620             Ctrl_CLR = 0x2004,
621             Cal_CLR = 0x2008,
622             Status_CLR = 0x200C,
623             If_CLR = 0x2010,
624             Ien_CLR = 0x2014,
625             Lock_CLR = 0x201C,
626             Test_CLR = 0x2020,
627             Feature_CLR = 0x2024,
628 
629             Ipversion_TGL = 0x3000,
630             Ctrl_TGL = 0x3004,
631             Cal_TGL = 0x3008,
632             Status_TGL = 0x300C,
633             If_TGL = 0x3010,
634             Ien_TGL = 0x3014,
635             Lock_TGL = 0x301C,
636             Test_TGL = 0x3020,
637             Feature_TGL = 0x3024,
638         }
639 
640         public long Size => 0x4000;
641 
642         protected DoubleWordRegisterCollection registers;
643     }
644 }