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     LFXO, Generated on : 2023-07-20 14:29:26.453417
11     LFXO, ID Version : b9968dcd7222434089d09cfd6373a3ec.1 */
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_LFXO_1
29     {
30         public EFR32xG2_LFXO_1(Machine machine) : base(machine)
31         {
32             EFR32xG2_LFXO_1_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_LFXO_1 : BasicDoubleWordPeripheral, IKnownSize
51     {
EFR32xG2_LFXO_1(Machine machine)52         public EFR32xG2_LFXO_1(Machine machine) : base(machine)
53         {
54             Define_Registers();
55             EFR32xG2_LFXO_1_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.Cfg, GenerateCfgRegister()},
65                 {(long)Registers.Cfg1, GenerateCfg1Register()},
66                 {(long)Registers.Status, GenerateStatusRegister()},
67                 {(long)Registers.Cal, GenerateCalRegister()},
68                 {(long)Registers.If, GenerateIfRegister()},
69                 {(long)Registers.Ien, GenerateIenRegister()},
70                 {(long)Registers.Syncbusy, GenerateSyncbusyRegister()},
71                 {(long)Registers.Lock, GenerateLockRegister()},
72             };
73             registers = new DoubleWordRegisterCollection(this, registersMap);
74         }
75 
Reset()76         public override void Reset()
77         {
78             base.Reset();
79             LFXO_Reset();
80         }
81 
82         protected enum CFG_MODE
83         {
84             XTAL = 0, // A 32768Hz crystal should be connected to the LF crystal pads. Voltage must not exceed VDDIO.
85             BUFEXTCLK = 1, // An external sine source with minimum amplitude 100mv (zero-to-peak) and maximum amplitude 500mV (zero-to-peak) should be connected in series with LFXTAL_I pin. Minimum voltage should be larger than ground and maximum voltage smaller than VDDIO. The sine source does not need to be ac coupled externally as it is ac couples inside LFXO. LFXTAL_O is free to be used as a general purpose GPIO.
86             DIGEXTCLK = 2, // An external 32KHz CMOS clock should be provided on LFXTAL_I. LFXTAL_O is free to be used as a general purpose GPIO.
87         }
88 
89         protected enum CFG_TIMEOUT
90         {
91             CYCLES2 = 0, // Timeout period of 2 cycles
92             CYCLES256 = 1, // Timeout period of 256 cycles
93             CYCLES1K = 2, // Timeout period of 1024 cycles
94             CYCLES2K = 3, // Timeout period of 2048 cycles
95             CYCLES4K = 4, // Timeout period of 4096 cycles
96             CYCLES8K = 5, // Timeout period of 8192 cycles
97             CYCLES16K = 6, // Timeout period of 16384 cycles
98             CYCLES32K = 7, // Timeout period of 32768 cycles
99         }
100 
101         protected enum CFG1_XOAGCCURR
102         {
103             Currentx1p0 = 0, //
104             Currentx1p15 = 1, //
105             Currentx1p3 = 2, //
106             Currentx1p6 = 3, //
107         }
108 
109         protected enum CFG1_CURR
110         {
111             Biasx1p00 = 0, //
112             Biasx1p12 = 1, //
113             Biasx1p25 = 2, //
114             Biasx1p5 = 3, //
115         }
116 
117         protected enum STATUS_LOCK
118         {
119             UNLOCKED = 0, // LFXO lockable registers are not locked
120             LOCKED = 1, // LFXO lockable registers are locked
121         }
122 
123         // Ipversion - Offset : 0x0
GenerateIpversionRegister()124         protected DoubleWordRegister  GenerateIpversionRegister() => new DoubleWordRegister(this, 0x1)
125             .WithValueField(0, 32, out ipversion_ipversion_field, FieldMode.Read,
126                     valueProviderCallback: (_) => {
127                         Ipversion_Ipversion_ValueProvider(_);
128                         return ipversion_ipversion_field.Value;
129                     },
130                     readCallback: (_, __) => Ipversion_Ipversion_Read(_, __),
131                     name: "Ipversion")
132             .WithReadCallback((_, __) => Ipversion_Read(_, __))
133             .WithWriteCallback((_, __) => Ipversion_Write(_, __));
134 
135         // Ctrl - Offset : 0x4
GenerateCtrlRegister()136         protected DoubleWordRegister  GenerateCtrlRegister() => new DoubleWordRegister(this, 0x2)
137             .WithFlag(0, out ctrl_forceen_bit,
138                     valueProviderCallback: (_) => {
139                         Ctrl_Forceen_ValueProvider(_);
140                         return ctrl_forceen_bit.Value;
141                     },
142                     writeCallback: (_, __) => Ctrl_Forceen_Write(_, __),
143                     readCallback: (_, __) => Ctrl_Forceen_Read(_, __),
144                     name: "Forceen")
145             .WithFlag(1, out ctrl_disondemand_bit,
146                     valueProviderCallback: (_) => {
147                         Ctrl_Disondemand_ValueProvider(_);
148                         return ctrl_disondemand_bit.Value;
149                     },
150                     writeCallback: (_, __) => Ctrl_Disondemand_Write(_, __),
151                     readCallback: (_, __) => Ctrl_Disondemand_Read(_, __),
152                     name: "Disondemand")
153             .WithReservedBits(2, 2)
154             .WithFlag(4, out ctrl_faildeten_bit,
155                     valueProviderCallback: (_) => {
156                         Ctrl_Faildeten_ValueProvider(_);
157                         return ctrl_faildeten_bit.Value;
158                     },
159                     writeCallback: (_, __) => Ctrl_Faildeten_Write(_, __),
160                     readCallback: (_, __) => Ctrl_Faildeten_Read(_, __),
161                     name: "Faildeten")
162             .WithFlag(5, out ctrl_faildetem4wuen_bit,
163                     valueProviderCallback: (_) => {
164                         Ctrl_Faildetem4wuen_ValueProvider(_);
165                         return ctrl_faildetem4wuen_bit.Value;
166                     },
167                     writeCallback: (_, __) => Ctrl_Faildetem4wuen_Write(_, __),
168                     readCallback: (_, __) => Ctrl_Faildetem4wuen_Read(_, __),
169                     name: "Faildetem4wuen")
170             .WithReservedBits(6, 26)
171             .WithReadCallback((_, __) => Ctrl_Read(_, __))
172             .WithWriteCallback((_, __) => Ctrl_Write(_, __));
173 
174         // Cfg - Offset : 0x8
GenerateCfgRegister()175         protected DoubleWordRegister  GenerateCfgRegister() => new DoubleWordRegister(this, 0x701)
176             .WithFlag(0, out cfg_agc_bit,
177                     valueProviderCallback: (_) => {
178                         Cfg_Agc_ValueProvider(_);
179                         return cfg_agc_bit.Value;
180                     },
181                     writeCallback: (_, __) => Cfg_Agc_Write(_, __),
182                     readCallback: (_, __) => Cfg_Agc_Read(_, __),
183                     name: "Agc")
184             .WithFlag(1, out cfg_highampl_bit,
185                     valueProviderCallback: (_) => {
186                         Cfg_Highampl_ValueProvider(_);
187                         return cfg_highampl_bit.Value;
188                     },
189                     writeCallback: (_, __) => Cfg_Highampl_Write(_, __),
190                     readCallback: (_, __) => Cfg_Highampl_Read(_, __),
191                     name: "Highampl")
192             .WithReservedBits(2, 2)
193             .WithEnumField<DoubleWordRegister, CFG_MODE>(4, 2, out cfg_mode_field,
194                     valueProviderCallback: (_) => {
195                         Cfg_Mode_ValueProvider(_);
196                         return cfg_mode_field.Value;
197                     },
198                     writeCallback: (_, __) => Cfg_Mode_Write(_, __),
199                     readCallback: (_, __) => Cfg_Mode_Read(_, __),
200                     name: "Mode")
201             .WithReservedBits(6, 2)
202             .WithEnumField<DoubleWordRegister, CFG_TIMEOUT>(8, 3, out cfg_timeout_field,
203                     valueProviderCallback: (_) => {
204                         Cfg_Timeout_ValueProvider(_);
205                         return cfg_timeout_field.Value;
206                     },
207                     writeCallback: (_, __) => Cfg_Timeout_Write(_, __),
208                     readCallback: (_, __) => Cfg_Timeout_Read(_, __),
209                     name: "Timeout")
210             .WithReservedBits(11, 21)
211             .WithReadCallback((_, __) => Cfg_Read(_, __))
212             .WithWriteCallback((_, __) => Cfg_Write(_, __));
213 
214         // Cfg1 - Offset : 0xC
GenerateCfg1Register()215         protected DoubleWordRegister  GenerateCfg1Register() => new DoubleWordRegister(this, 0x2)
216             .WithEnumField<DoubleWordRegister, CFG1_XOAGCCURR>(0, 2, out cfg1_xoagccurr_field,
217                     valueProviderCallback: (_) => {
218                         Cfg1_Xoagccurr_ValueProvider(_);
219                         return cfg1_xoagccurr_field.Value;
220                     },
221                     writeCallback: (_, __) => Cfg1_Xoagccurr_Write(_, __),
222                     readCallback: (_, __) => Cfg1_Xoagccurr_Read(_, __),
223                     name: "Xoagccurr")
224             .WithReservedBits(2, 2)
225             .WithEnumField<DoubleWordRegister, CFG1_CURR>(4, 2, out cfg1_curr_field,
226                     valueProviderCallback: (_) => {
227                         Cfg1_Curr_ValueProvider(_);
228                         return cfg1_curr_field.Value;
229                     },
230                     writeCallback: (_, __) => Cfg1_Curr_Write(_, __),
231                     readCallback: (_, __) => Cfg1_Curr_Read(_, __),
232                     name: "Curr")
233             .WithReservedBits(6, 2)
234             .WithFlag(8, out cfg1_xpdcdis_bit,
235                     valueProviderCallback: (_) => {
236                         Cfg1_Xpdcdis_ValueProvider(_);
237                         return cfg1_xpdcdis_bit.Value;
238                     },
239                     writeCallback: (_, __) => Cfg1_Xpdcdis_Write(_, __),
240                     readCallback: (_, __) => Cfg1_Xpdcdis_Read(_, __),
241                     name: "Xpdcdis")
242             .WithFlag(9, out cfg1_buffcurr_bit,
243                     valueProviderCallback: (_) => {
244                         Cfg1_Buffcurr_ValueProvider(_);
245                         return cfg1_buffcurr_bit.Value;
246                     },
247                     writeCallback: (_, __) => Cfg1_Buffcurr_Write(_, __),
248                     readCallback: (_, __) => Cfg1_Buffcurr_Read(_, __),
249                     name: "Buffcurr")
250             .WithFlag(10, out cfg1_nclampdis_bit,
251                     valueProviderCallback: (_) => {
252                         Cfg1_Nclampdis_ValueProvider(_);
253                         return cfg1_nclampdis_bit.Value;
254                     },
255                     writeCallback: (_, __) => Cfg1_Nclampdis_Write(_, __),
256                     readCallback: (_, __) => Cfg1_Nclampdis_Read(_, __),
257                     name: "Nclampdis")
258             .WithFlag(11, out cfg1_pclampdis_bit,
259                     valueProviderCallback: (_) => {
260                         Cfg1_Pclampdis_ValueProvider(_);
261                         return cfg1_pclampdis_bit.Value;
262                     },
263                     writeCallback: (_, __) => Cfg1_Pclampdis_Write(_, __),
264                     readCallback: (_, __) => Cfg1_Pclampdis_Read(_, __),
265                     name: "Pclampdis")
266             .WithFlag(12, out cfg1_bleederdis_bit,
267                     valueProviderCallback: (_) => {
268                         Cfg1_Bleederdis_ValueProvider(_);
269                         return cfg1_bleederdis_bit.Value;
270                     },
271                     writeCallback: (_, __) => Cfg1_Bleederdis_Write(_, __),
272                     readCallback: (_, __) => Cfg1_Bleederdis_Read(_, __),
273                     name: "Bleederdis")
274             .WithReservedBits(13, 19)
275             .WithReadCallback((_, __) => Cfg1_Read(_, __))
276             .WithWriteCallback((_, __) => Cfg1_Write(_, __));
277 
278         // Status - Offset : 0x10
GenerateStatusRegister()279         protected DoubleWordRegister  GenerateStatusRegister() => new DoubleWordRegister(this, 0x0)
280             .WithFlag(0, out status_rdy_bit, FieldMode.Read,
281                     valueProviderCallback: (_) => {
282                         Status_Rdy_ValueProvider(_);
283                         return status_rdy_bit.Value;
284                     },
285                     readCallback: (_, __) => Status_Rdy_Read(_, __),
286                     name: "Rdy")
287             .WithReservedBits(1, 15)
288             .WithFlag(16, out status_ens_bit, FieldMode.Read,
289                     valueProviderCallback: (_) => {
290                         Status_Ens_ValueProvider(_);
291                         return status_ens_bit.Value;
292                     },
293                     readCallback: (_, __) => Status_Ens_Read(_, __),
294                     name: "Ens")
295             .WithReservedBits(17, 14)
296             .WithEnumField<DoubleWordRegister, STATUS_LOCK>(31, 1, out status_lock_bit, FieldMode.Read,
297                     valueProviderCallback: (_) => {
298                         Status_Lock_ValueProvider(_);
299                         return status_lock_bit.Value;
300                     },
301                     readCallback: (_, __) => Status_Lock_Read(_, __),
302                     name: "Lock")
303             .WithReadCallback((_, __) => Status_Read(_, __))
304             .WithWriteCallback((_, __) => Status_Write(_, __));
305 
306         // Cal - Offset : 0x14
GenerateCalRegister()307         protected DoubleWordRegister  GenerateCalRegister() => new DoubleWordRegister(this, 0x100)
308             .WithValueField(0, 7, out cal_captune_field,
309                     valueProviderCallback: (_) => {
310                         Cal_Captune_ValueProvider(_);
311                         return cal_captune_field.Value;
312                     },
313                     writeCallback: (_, __) => Cal_Captune_Write(_, __),
314                     readCallback: (_, __) => Cal_Captune_Read(_, __),
315                     name: "Captune")
316             .WithReservedBits(7, 1)
317             .WithValueField(8, 2, out cal_gain_field,
318                     valueProviderCallback: (_) => {
319                         Cal_Gain_ValueProvider(_);
320                         return cal_gain_field.Value;
321                     },
322                     writeCallback: (_, __) => Cal_Gain_Write(_, __),
323                     readCallback: (_, __) => Cal_Gain_Read(_, __),
324                     name: "Gain")
325             .WithReservedBits(10, 22)
326             .WithReadCallback((_, __) => Cal_Read(_, __))
327             .WithWriteCallback((_, __) => Cal_Write(_, __));
328 
329         // If - Offset : 0x18
GenerateIfRegister()330         protected DoubleWordRegister  GenerateIfRegister() => new DoubleWordRegister(this, 0x0)
331             .WithFlag(0, out if_rdy_bit,
332                     valueProviderCallback: (_) => {
333                         If_Rdy_ValueProvider(_);
334                         return if_rdy_bit.Value;
335                     },
336                     writeCallback: (_, __) => If_Rdy_Write(_, __),
337                     readCallback: (_, __) => If_Rdy_Read(_, __),
338                     name: "Rdy")
339             .WithFlag(1, out if_posedge_bit,
340                     valueProviderCallback: (_) => {
341                         If_Posedge_ValueProvider(_);
342                         return if_posedge_bit.Value;
343                     },
344                     writeCallback: (_, __) => If_Posedge_Write(_, __),
345                     readCallback: (_, __) => If_Posedge_Read(_, __),
346                     name: "Posedge")
347             .WithFlag(2, out if_negedge_bit,
348                     valueProviderCallback: (_) => {
349                         If_Negedge_ValueProvider(_);
350                         return if_negedge_bit.Value;
351                     },
352                     writeCallback: (_, __) => If_Negedge_Write(_, __),
353                     readCallback: (_, __) => If_Negedge_Read(_, __),
354                     name: "Negedge")
355             .WithFlag(3, out if_fail_bit,
356                     valueProviderCallback: (_) => {
357                         If_Fail_ValueProvider(_);
358                         return if_fail_bit.Value;
359                     },
360                     writeCallback: (_, __) => If_Fail_Write(_, __),
361                     readCallback: (_, __) => If_Fail_Read(_, __),
362                     name: "Fail")
363             .WithReservedBits(4, 28)
364             .WithReadCallback((_, __) => If_Read(_, __))
365             .WithWriteCallback((_, __) => If_Write(_, __));
366 
367         // Ien - Offset : 0x1C
GenerateIenRegister()368         protected DoubleWordRegister  GenerateIenRegister() => new DoubleWordRegister(this, 0x0)
369             .WithFlag(0, out ien_rdy_bit,
370                     valueProviderCallback: (_) => {
371                         Ien_Rdy_ValueProvider(_);
372                         return ien_rdy_bit.Value;
373                     },
374                     writeCallback: (_, __) => Ien_Rdy_Write(_, __),
375                     readCallback: (_, __) => Ien_Rdy_Read(_, __),
376                     name: "Rdy")
377             .WithFlag(1, out ien_posedge_bit,
378                     valueProviderCallback: (_) => {
379                         Ien_Posedge_ValueProvider(_);
380                         return ien_posedge_bit.Value;
381                     },
382                     writeCallback: (_, __) => Ien_Posedge_Write(_, __),
383                     readCallback: (_, __) => Ien_Posedge_Read(_, __),
384                     name: "Posedge")
385             .WithFlag(2, out ien_negedge_bit,
386                     valueProviderCallback: (_) => {
387                         Ien_Negedge_ValueProvider(_);
388                         return ien_negedge_bit.Value;
389                     },
390                     writeCallback: (_, __) => Ien_Negedge_Write(_, __),
391                     readCallback: (_, __) => Ien_Negedge_Read(_, __),
392                     name: "Negedge")
393             .WithFlag(3, out ien_fail_bit,
394                     valueProviderCallback: (_) => {
395                         Ien_Fail_ValueProvider(_);
396                         return ien_fail_bit.Value;
397                     },
398                     writeCallback: (_, __) => Ien_Fail_Write(_, __),
399                     readCallback: (_, __) => Ien_Fail_Read(_, __),
400                     name: "Fail")
401             .WithReservedBits(4, 28)
402             .WithReadCallback((_, __) => Ien_Read(_, __))
403             .WithWriteCallback((_, __) => Ien_Write(_, __));
404 
405         // Syncbusy - Offset : 0x20
GenerateSyncbusyRegister()406         protected DoubleWordRegister  GenerateSyncbusyRegister() => new DoubleWordRegister(this, 0x0)
407             .WithFlag(0, out syncbusy_cal_bit, FieldMode.Read,
408                     valueProviderCallback: (_) => {
409                         Syncbusy_Cal_ValueProvider(_);
410                         return syncbusy_cal_bit.Value;
411                     },
412                     readCallback: (_, __) => Syncbusy_Cal_Read(_, __),
413                     name: "Cal")
414             .WithReservedBits(1, 31)
415             .WithReadCallback((_, __) => Syncbusy_Read(_, __))
416             .WithWriteCallback((_, __) => Syncbusy_Write(_, __));
417 
418         // Lock - Offset : 0x24
GenerateLockRegister()419         protected DoubleWordRegister  GenerateLockRegister() => new DoubleWordRegister(this, 0x1A20)
420             .WithValueField(0, 16, out lock_lockkey_field, FieldMode.Write,
421                     writeCallback: (_, __) => Lock_Lockkey_Write(_, __),
422                     name: "Lockkey")
423             .WithReservedBits(16, 16)
424             .WithReadCallback((_, __) => Lock_Read(_, __))
425             .WithWriteCallback((_, __) => Lock_Write(_, __));
426 
427 
ReadWFIFO()428         private uint ReadWFIFO()
429         {
430             this.Log(LogLevel.Warning, "Reading from a WFIFO Field, value returned will always be 0");
431             return 0x0;
432         }
433 
ReadLFWSYNC()434         private uint ReadLFWSYNC()
435         {
436             this.Log(LogLevel.Warning, "Reading from a LFWSYNC/HVLFWSYNC Field, value returned will always be 0");
437             return 0x0;
438         }
439 
ReadRFIFO()440         private uint ReadRFIFO()
441         {
442             this.Log(LogLevel.Warning, "Reading from a RFIFO Field, value returned will always be 0");
443             return 0x0;
444         }
445 
446 
447 
448 
449 
450         // Ipversion - Offset : 0x0
451         protected IValueRegisterField ipversion_ipversion_field;
Ipversion_Ipversion_Read(ulong a, ulong b)452         partial void Ipversion_Ipversion_Read(ulong a, ulong b);
Ipversion_Ipversion_ValueProvider(ulong a)453         partial void Ipversion_Ipversion_ValueProvider(ulong a);
454 
Ipversion_Write(uint a, uint b)455         partial void Ipversion_Write(uint a, uint b);
Ipversion_Read(uint a, uint b)456         partial void Ipversion_Read(uint a, uint b);
457 
458         // Ctrl - Offset : 0x4
459         protected IFlagRegisterField ctrl_forceen_bit;
Ctrl_Forceen_Write(bool a, bool b)460         partial void Ctrl_Forceen_Write(bool a, bool b);
Ctrl_Forceen_Read(bool a, bool b)461         partial void Ctrl_Forceen_Read(bool a, bool b);
Ctrl_Forceen_ValueProvider(bool a)462         partial void Ctrl_Forceen_ValueProvider(bool a);
463         protected IFlagRegisterField ctrl_disondemand_bit;
Ctrl_Disondemand_Write(bool a, bool b)464         partial void Ctrl_Disondemand_Write(bool a, bool b);
Ctrl_Disondemand_Read(bool a, bool b)465         partial void Ctrl_Disondemand_Read(bool a, bool b);
Ctrl_Disondemand_ValueProvider(bool a)466         partial void Ctrl_Disondemand_ValueProvider(bool a);
467         protected IFlagRegisterField ctrl_faildeten_bit;
Ctrl_Faildeten_Write(bool a, bool b)468         partial void Ctrl_Faildeten_Write(bool a, bool b);
Ctrl_Faildeten_Read(bool a, bool b)469         partial void Ctrl_Faildeten_Read(bool a, bool b);
Ctrl_Faildeten_ValueProvider(bool a)470         partial void Ctrl_Faildeten_ValueProvider(bool a);
471         protected IFlagRegisterField ctrl_faildetem4wuen_bit;
Ctrl_Faildetem4wuen_Write(bool a, bool b)472         partial void Ctrl_Faildetem4wuen_Write(bool a, bool b);
Ctrl_Faildetem4wuen_Read(bool a, bool b)473         partial void Ctrl_Faildetem4wuen_Read(bool a, bool b);
Ctrl_Faildetem4wuen_ValueProvider(bool a)474         partial void Ctrl_Faildetem4wuen_ValueProvider(bool a);
475 
Ctrl_Write(uint a, uint b)476         partial void Ctrl_Write(uint a, uint b);
Ctrl_Read(uint a, uint b)477         partial void Ctrl_Read(uint a, uint b);
478 
479         // Cfg - Offset : 0x8
480         protected IFlagRegisterField cfg_agc_bit;
Cfg_Agc_Write(bool a, bool b)481         partial void Cfg_Agc_Write(bool a, bool b);
Cfg_Agc_Read(bool a, bool b)482         partial void Cfg_Agc_Read(bool a, bool b);
Cfg_Agc_ValueProvider(bool a)483         partial void Cfg_Agc_ValueProvider(bool a);
484         protected IFlagRegisterField cfg_highampl_bit;
Cfg_Highampl_Write(bool a, bool b)485         partial void Cfg_Highampl_Write(bool a, bool b);
Cfg_Highampl_Read(bool a, bool b)486         partial void Cfg_Highampl_Read(bool a, bool b);
Cfg_Highampl_ValueProvider(bool a)487         partial void Cfg_Highampl_ValueProvider(bool a);
488         protected IEnumRegisterField<CFG_MODE> cfg_mode_field;
Cfg_Mode_Write(CFG_MODE a, CFG_MODE b)489         partial void Cfg_Mode_Write(CFG_MODE a, CFG_MODE b);
Cfg_Mode_Read(CFG_MODE a, CFG_MODE b)490         partial void Cfg_Mode_Read(CFG_MODE a, CFG_MODE b);
Cfg_Mode_ValueProvider(CFG_MODE a)491         partial void Cfg_Mode_ValueProvider(CFG_MODE a);
492         protected IEnumRegisterField<CFG_TIMEOUT> cfg_timeout_field;
Cfg_Timeout_Write(CFG_TIMEOUT a, CFG_TIMEOUT b)493         partial void Cfg_Timeout_Write(CFG_TIMEOUT a, CFG_TIMEOUT b);
Cfg_Timeout_Read(CFG_TIMEOUT a, CFG_TIMEOUT b)494         partial void Cfg_Timeout_Read(CFG_TIMEOUT a, CFG_TIMEOUT b);
Cfg_Timeout_ValueProvider(CFG_TIMEOUT a)495         partial void Cfg_Timeout_ValueProvider(CFG_TIMEOUT a);
496 
Cfg_Write(uint a, uint b)497         partial void Cfg_Write(uint a, uint b);
Cfg_Read(uint a, uint b)498         partial void Cfg_Read(uint a, uint b);
499 
500         // Cfg1 - Offset : 0xC
501         protected IEnumRegisterField<CFG1_XOAGCCURR> cfg1_xoagccurr_field;
Cfg1_Xoagccurr_Write(CFG1_XOAGCCURR a, CFG1_XOAGCCURR b)502         partial void Cfg1_Xoagccurr_Write(CFG1_XOAGCCURR a, CFG1_XOAGCCURR b);
Cfg1_Xoagccurr_Read(CFG1_XOAGCCURR a, CFG1_XOAGCCURR b)503         partial void Cfg1_Xoagccurr_Read(CFG1_XOAGCCURR a, CFG1_XOAGCCURR b);
Cfg1_Xoagccurr_ValueProvider(CFG1_XOAGCCURR a)504         partial void Cfg1_Xoagccurr_ValueProvider(CFG1_XOAGCCURR a);
505         protected IEnumRegisterField<CFG1_CURR> cfg1_curr_field;
Cfg1_Curr_Write(CFG1_CURR a, CFG1_CURR b)506         partial void Cfg1_Curr_Write(CFG1_CURR a, CFG1_CURR b);
Cfg1_Curr_Read(CFG1_CURR a, CFG1_CURR b)507         partial void Cfg1_Curr_Read(CFG1_CURR a, CFG1_CURR b);
Cfg1_Curr_ValueProvider(CFG1_CURR a)508         partial void Cfg1_Curr_ValueProvider(CFG1_CURR a);
509         protected IFlagRegisterField cfg1_xpdcdis_bit;
Cfg1_Xpdcdis_Write(bool a, bool b)510         partial void Cfg1_Xpdcdis_Write(bool a, bool b);
Cfg1_Xpdcdis_Read(bool a, bool b)511         partial void Cfg1_Xpdcdis_Read(bool a, bool b);
Cfg1_Xpdcdis_ValueProvider(bool a)512         partial void Cfg1_Xpdcdis_ValueProvider(bool a);
513         protected IFlagRegisterField cfg1_buffcurr_bit;
Cfg1_Buffcurr_Write(bool a, bool b)514         partial void Cfg1_Buffcurr_Write(bool a, bool b);
Cfg1_Buffcurr_Read(bool a, bool b)515         partial void Cfg1_Buffcurr_Read(bool a, bool b);
Cfg1_Buffcurr_ValueProvider(bool a)516         partial void Cfg1_Buffcurr_ValueProvider(bool a);
517         protected IFlagRegisterField cfg1_nclampdis_bit;
Cfg1_Nclampdis_Write(bool a, bool b)518         partial void Cfg1_Nclampdis_Write(bool a, bool b);
Cfg1_Nclampdis_Read(bool a, bool b)519         partial void Cfg1_Nclampdis_Read(bool a, bool b);
Cfg1_Nclampdis_ValueProvider(bool a)520         partial void Cfg1_Nclampdis_ValueProvider(bool a);
521         protected IFlagRegisterField cfg1_pclampdis_bit;
Cfg1_Pclampdis_Write(bool a, bool b)522         partial void Cfg1_Pclampdis_Write(bool a, bool b);
Cfg1_Pclampdis_Read(bool a, bool b)523         partial void Cfg1_Pclampdis_Read(bool a, bool b);
Cfg1_Pclampdis_ValueProvider(bool a)524         partial void Cfg1_Pclampdis_ValueProvider(bool a);
525         protected IFlagRegisterField cfg1_bleederdis_bit;
Cfg1_Bleederdis_Write(bool a, bool b)526         partial void Cfg1_Bleederdis_Write(bool a, bool b);
Cfg1_Bleederdis_Read(bool a, bool b)527         partial void Cfg1_Bleederdis_Read(bool a, bool b);
Cfg1_Bleederdis_ValueProvider(bool a)528         partial void Cfg1_Bleederdis_ValueProvider(bool a);
529 
Cfg1_Write(uint a, uint b)530         partial void Cfg1_Write(uint a, uint b);
Cfg1_Read(uint a, uint b)531         partial void Cfg1_Read(uint a, uint b);
532 
533         // Status - Offset : 0x10
534         protected IFlagRegisterField status_rdy_bit;
Status_Rdy_Read(bool a, bool b)535         partial void Status_Rdy_Read(bool a, bool b);
Status_Rdy_ValueProvider(bool a)536         partial void Status_Rdy_ValueProvider(bool a);
537         protected IFlagRegisterField status_ens_bit;
Status_Ens_Read(bool a, bool b)538         partial void Status_Ens_Read(bool a, bool b);
Status_Ens_ValueProvider(bool a)539         partial void Status_Ens_ValueProvider(bool a);
540         protected IEnumRegisterField<STATUS_LOCK> status_lock_bit;
Status_Lock_Read(STATUS_LOCK a, STATUS_LOCK b)541         partial void Status_Lock_Read(STATUS_LOCK a, STATUS_LOCK b);
Status_Lock_ValueProvider(STATUS_LOCK a)542         partial void Status_Lock_ValueProvider(STATUS_LOCK a);
543 
Status_Write(uint a, uint b)544         partial void Status_Write(uint a, uint b);
Status_Read(uint a, uint b)545         partial void Status_Read(uint a, uint b);
546 
547         // Cal - Offset : 0x14
548         protected IValueRegisterField cal_captune_field;
Cal_Captune_Write(ulong a, ulong b)549         partial void Cal_Captune_Write(ulong a, ulong b);
Cal_Captune_Read(ulong a, ulong b)550         partial void Cal_Captune_Read(ulong a, ulong b);
Cal_Captune_ValueProvider(ulong a)551         partial void Cal_Captune_ValueProvider(ulong a);
552         protected IValueRegisterField cal_gain_field;
Cal_Gain_Write(ulong a, ulong b)553         partial void Cal_Gain_Write(ulong a, ulong b);
Cal_Gain_Read(ulong a, ulong b)554         partial void Cal_Gain_Read(ulong a, ulong b);
Cal_Gain_ValueProvider(ulong a)555         partial void Cal_Gain_ValueProvider(ulong a);
556 
Cal_Write(uint a, uint b)557         partial void Cal_Write(uint a, uint b);
Cal_Read(uint a, uint b)558         partial void Cal_Read(uint a, uint b);
559 
560         // If - Offset : 0x18
561         protected IFlagRegisterField if_rdy_bit;
If_Rdy_Write(bool a, bool b)562         partial void If_Rdy_Write(bool a, bool b);
If_Rdy_Read(bool a, bool b)563         partial void If_Rdy_Read(bool a, bool b);
If_Rdy_ValueProvider(bool a)564         partial void If_Rdy_ValueProvider(bool a);
565         protected IFlagRegisterField if_posedge_bit;
If_Posedge_Write(bool a, bool b)566         partial void If_Posedge_Write(bool a, bool b);
If_Posedge_Read(bool a, bool b)567         partial void If_Posedge_Read(bool a, bool b);
If_Posedge_ValueProvider(bool a)568         partial void If_Posedge_ValueProvider(bool a);
569         protected IFlagRegisterField if_negedge_bit;
If_Negedge_Write(bool a, bool b)570         partial void If_Negedge_Write(bool a, bool b);
If_Negedge_Read(bool a, bool b)571         partial void If_Negedge_Read(bool a, bool b);
If_Negedge_ValueProvider(bool a)572         partial void If_Negedge_ValueProvider(bool a);
573         protected IFlagRegisterField if_fail_bit;
If_Fail_Write(bool a, bool b)574         partial void If_Fail_Write(bool a, bool b);
If_Fail_Read(bool a, bool b)575         partial void If_Fail_Read(bool a, bool b);
If_Fail_ValueProvider(bool a)576         partial void If_Fail_ValueProvider(bool a);
577 
If_Write(uint a, uint b)578         partial void If_Write(uint a, uint b);
If_Read(uint a, uint b)579         partial void If_Read(uint a, uint b);
580 
581         // Ien - Offset : 0x1C
582         protected IFlagRegisterField ien_rdy_bit;
Ien_Rdy_Write(bool a, bool b)583         partial void Ien_Rdy_Write(bool a, bool b);
Ien_Rdy_Read(bool a, bool b)584         partial void Ien_Rdy_Read(bool a, bool b);
Ien_Rdy_ValueProvider(bool a)585         partial void Ien_Rdy_ValueProvider(bool a);
586         protected IFlagRegisterField ien_posedge_bit;
Ien_Posedge_Write(bool a, bool b)587         partial void Ien_Posedge_Write(bool a, bool b);
Ien_Posedge_Read(bool a, bool b)588         partial void Ien_Posedge_Read(bool a, bool b);
Ien_Posedge_ValueProvider(bool a)589         partial void Ien_Posedge_ValueProvider(bool a);
590         protected IFlagRegisterField ien_negedge_bit;
Ien_Negedge_Write(bool a, bool b)591         partial void Ien_Negedge_Write(bool a, bool b);
Ien_Negedge_Read(bool a, bool b)592         partial void Ien_Negedge_Read(bool a, bool b);
Ien_Negedge_ValueProvider(bool a)593         partial void Ien_Negedge_ValueProvider(bool a);
594         protected IFlagRegisterField ien_fail_bit;
Ien_Fail_Write(bool a, bool b)595         partial void Ien_Fail_Write(bool a, bool b);
Ien_Fail_Read(bool a, bool b)596         partial void Ien_Fail_Read(bool a, bool b);
Ien_Fail_ValueProvider(bool a)597         partial void Ien_Fail_ValueProvider(bool a);
598 
Ien_Write(uint a, uint b)599         partial void Ien_Write(uint a, uint b);
Ien_Read(uint a, uint b)600         partial void Ien_Read(uint a, uint b);
601 
602         // Syncbusy - Offset : 0x20
603         protected IFlagRegisterField syncbusy_cal_bit;
Syncbusy_Cal_Read(bool a, bool b)604         partial void Syncbusy_Cal_Read(bool a, bool b);
Syncbusy_Cal_ValueProvider(bool a)605         partial void Syncbusy_Cal_ValueProvider(bool a);
606 
Syncbusy_Write(uint a, uint b)607         partial void Syncbusy_Write(uint a, uint b);
Syncbusy_Read(uint a, uint b)608         partial void Syncbusy_Read(uint a, uint b);
609 
610         // Lock - Offset : 0x24
611         protected IValueRegisterField lock_lockkey_field;
Lock_Lockkey_Write(ulong a, ulong b)612         partial void Lock_Lockkey_Write(ulong a, ulong b);
Lock_Lockkey_ValueProvider(ulong a)613         partial void Lock_Lockkey_ValueProvider(ulong a);
614 
Lock_Write(uint a, uint b)615         partial void Lock_Write(uint a, uint b);
Lock_Read(uint a, uint b)616         partial void Lock_Read(uint a, uint b);
617 
LFXO_Reset()618         partial void LFXO_Reset();
619 
EFR32xG2_LFXO_1_Constructor()620         partial void EFR32xG2_LFXO_1_Constructor();
621 
622         public bool Enabled = true;
623 
624         private ICMU_EFR32xG2 _cmu;
625         private ICMU_EFR32xG2 cmu
626         {
627             get
628             {
629                 if (Object.ReferenceEquals(_cmu, null))
630                 {
631                     foreach(var cmu in machine.GetPeripheralsOfType<ICMU_EFR32xG2>())
632                     {
633                         _cmu = cmu;
634                     }
635                 }
636                 return _cmu;
637             }
638             set
639             {
640                 _cmu = value;
641             }
642         }
643 
ReadDoubleWord(long offset)644         public override uint ReadDoubleWord(long offset)
645         {
646             long temp = offset & 0x0FFF;
647             switch(offset & 0x3000){
648                 case 0x0000:
649                     return registers.Read(offset);
650                 default:
651                     this.Log(LogLevel.Warning, "Reading from Set/Clr/Tgl is not supported.");
652                     return registers.Read(temp);
653             }
654         }
655 
WriteDoubleWord(long address, uint value)656         public override void WriteDoubleWord(long address, uint value)
657         {
658             long temp = address & 0x0FFF;
659             switch(address & 0x3000){
660                 case 0x0000:
661                     registers.Write(address, value);
662                     break;
663                 case 0x1000:
664                     registers.Write(temp, registers.Read(temp) | value);
665                     break;
666                 case 0x2000:
667                     registers.Write(temp, registers.Read(temp) & ~value);
668                     break;
669                 case 0x3000:
670                     registers.Write(temp, registers.Read(temp) ^ value);
671                     break;
672                 default:
673                     this.Log(LogLevel.Error, "writing doubleWord to non existing offset {0:X}, case : {1:X}", address, address & 0x3000);
674                     break;
675             }
676         }
677 
678         protected enum Registers
679         {
680             Ipversion = 0x0,
681             Ctrl = 0x4,
682             Cfg = 0x8,
683             Cfg1 = 0xC,
684             Status = 0x10,
685             Cal = 0x14,
686             If = 0x18,
687             Ien = 0x1C,
688             Syncbusy = 0x20,
689             Lock = 0x24,
690 
691             Ipversion_SET = 0x1000,
692             Ctrl_SET = 0x1004,
693             Cfg_SET = 0x1008,
694             Cfg1_SET = 0x100C,
695             Status_SET = 0x1010,
696             Cal_SET = 0x1014,
697             If_SET = 0x1018,
698             Ien_SET = 0x101C,
699             Syncbusy_SET = 0x1020,
700             Lock_SET = 0x1024,
701 
702             Ipversion_CLR = 0x2000,
703             Ctrl_CLR = 0x2004,
704             Cfg_CLR = 0x2008,
705             Cfg1_CLR = 0x200C,
706             Status_CLR = 0x2010,
707             Cal_CLR = 0x2014,
708             If_CLR = 0x2018,
709             Ien_CLR = 0x201C,
710             Syncbusy_CLR = 0x2020,
711             Lock_CLR = 0x2024,
712 
713             Ipversion_TGL = 0x3000,
714             Ctrl_TGL = 0x3004,
715             Cfg_TGL = 0x3008,
716             Cfg1_TGL = 0x300C,
717             Status_TGL = 0x3010,
718             Cal_TGL = 0x3014,
719             If_TGL = 0x3018,
720             Ien_TGL = 0x301C,
721             Syncbusy_TGL = 0x3020,
722             Lock_TGL = 0x3024,
723         }
724 
725         public long Size => 0x4000;
726 
727         protected DoubleWordRegisterCollection registers;
728     }
729 }