efm32jg12b500_pac/crypto1/
wac.rs

1#[doc = "Register `WAC` reader"]
2pub struct R(crate::R<WAC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<WAC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<WAC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<WAC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `WAC` writer"]
17pub struct W(crate::W<WAC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<WAC_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<WAC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<WAC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Modular Operation Modulus\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum MODULUS_A {
41    #[doc = "0: Generic modulus. p = 2^256"]
42    BIN256 = 0,
43    #[doc = "1: Generic modulus. p = 2^128"]
44    BIN128 = 1,
45    #[doc = "2: Modulus for B-233 and K-233 ECC curves. p(t) = t^233 + t^74 + 1"]
46    ECCBIN233P = 2,
47    #[doc = "3: Modulus for B-163 and K-163 ECC curves. p(t) = t^163 + t^7 + t^6 + t^3 + 1"]
48    ECCBIN163P = 3,
49    #[doc = "4: Modulus for GCM. P(t) = t^128 + t^7 + t^2 + t + 1"]
50    GCMBIN128 = 4,
51    #[doc = "5: Modulus for P-256 ECC curve. p = 2^256 - 2^224 + 2^192 + 2^96 - 1"]
52    ECCPRIME256P = 5,
53    #[doc = "6: Modulus for P-224 ECC curve. p = 2^224 - 2^96 - 1"]
54    ECCPRIME224P = 6,
55    #[doc = "7: Modulus for P-192 ECC curve. p = 2^192 - 2^64 - 1"]
56    ECCPRIME192P = 7,
57    #[doc = "8: P modulus for B-233 ECC curve"]
58    ECCBIN233N = 8,
59    #[doc = "9: P modulus for K-233 ECC curve"]
60    ECCBIN233KN = 9,
61    #[doc = "10: P modulus for B-163 ECC curve"]
62    ECCBIN163N = 10,
63    #[doc = "11: P modulus for K-163 ECC curve"]
64    ECCBIN163KN = 11,
65    #[doc = "12: P modulus for P-256 ECC curve"]
66    ECCPRIME256N = 12,
67    #[doc = "13: P modulus for P-224 ECC curve"]
68    ECCPRIME224N = 13,
69    #[doc = "14: P modulus for P-192 ECC curve"]
70    ECCPRIME192N = 14,
71}
72impl From<MODULUS_A> for u8 {
73    #[inline(always)]
74    fn from(variant: MODULUS_A) -> Self {
75        variant as _
76    }
77}
78#[doc = "Field `MODULUS` reader - Modular Operation Modulus"]
79pub type MODULUS_R = crate::FieldReader<u8, MODULUS_A>;
80impl MODULUS_R {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub fn variant(&self) -> Option<MODULUS_A> {
84        match self.bits {
85            0 => Some(MODULUS_A::BIN256),
86            1 => Some(MODULUS_A::BIN128),
87            2 => Some(MODULUS_A::ECCBIN233P),
88            3 => Some(MODULUS_A::ECCBIN163P),
89            4 => Some(MODULUS_A::GCMBIN128),
90            5 => Some(MODULUS_A::ECCPRIME256P),
91            6 => Some(MODULUS_A::ECCPRIME224P),
92            7 => Some(MODULUS_A::ECCPRIME192P),
93            8 => Some(MODULUS_A::ECCBIN233N),
94            9 => Some(MODULUS_A::ECCBIN233KN),
95            10 => Some(MODULUS_A::ECCBIN163N),
96            11 => Some(MODULUS_A::ECCBIN163KN),
97            12 => Some(MODULUS_A::ECCPRIME256N),
98            13 => Some(MODULUS_A::ECCPRIME224N),
99            14 => Some(MODULUS_A::ECCPRIME192N),
100            _ => None,
101        }
102    }
103    #[doc = "Checks if the value of the field is `BIN256`"]
104    #[inline(always)]
105    pub fn is_bin256(&self) -> bool {
106        *self == MODULUS_A::BIN256
107    }
108    #[doc = "Checks if the value of the field is `BIN128`"]
109    #[inline(always)]
110    pub fn is_bin128(&self) -> bool {
111        *self == MODULUS_A::BIN128
112    }
113    #[doc = "Checks if the value of the field is `ECCBIN233P`"]
114    #[inline(always)]
115    pub fn is_eccbin233p(&self) -> bool {
116        *self == MODULUS_A::ECCBIN233P
117    }
118    #[doc = "Checks if the value of the field is `ECCBIN163P`"]
119    #[inline(always)]
120    pub fn is_eccbin163p(&self) -> bool {
121        *self == MODULUS_A::ECCBIN163P
122    }
123    #[doc = "Checks if the value of the field is `GCMBIN128`"]
124    #[inline(always)]
125    pub fn is_gcmbin128(&self) -> bool {
126        *self == MODULUS_A::GCMBIN128
127    }
128    #[doc = "Checks if the value of the field is `ECCPRIME256P`"]
129    #[inline(always)]
130    pub fn is_eccprime256p(&self) -> bool {
131        *self == MODULUS_A::ECCPRIME256P
132    }
133    #[doc = "Checks if the value of the field is `ECCPRIME224P`"]
134    #[inline(always)]
135    pub fn is_eccprime224p(&self) -> bool {
136        *self == MODULUS_A::ECCPRIME224P
137    }
138    #[doc = "Checks if the value of the field is `ECCPRIME192P`"]
139    #[inline(always)]
140    pub fn is_eccprime192p(&self) -> bool {
141        *self == MODULUS_A::ECCPRIME192P
142    }
143    #[doc = "Checks if the value of the field is `ECCBIN233N`"]
144    #[inline(always)]
145    pub fn is_eccbin233n(&self) -> bool {
146        *self == MODULUS_A::ECCBIN233N
147    }
148    #[doc = "Checks if the value of the field is `ECCBIN233KN`"]
149    #[inline(always)]
150    pub fn is_eccbin233kn(&self) -> bool {
151        *self == MODULUS_A::ECCBIN233KN
152    }
153    #[doc = "Checks if the value of the field is `ECCBIN163N`"]
154    #[inline(always)]
155    pub fn is_eccbin163n(&self) -> bool {
156        *self == MODULUS_A::ECCBIN163N
157    }
158    #[doc = "Checks if the value of the field is `ECCBIN163KN`"]
159    #[inline(always)]
160    pub fn is_eccbin163kn(&self) -> bool {
161        *self == MODULUS_A::ECCBIN163KN
162    }
163    #[doc = "Checks if the value of the field is `ECCPRIME256N`"]
164    #[inline(always)]
165    pub fn is_eccprime256n(&self) -> bool {
166        *self == MODULUS_A::ECCPRIME256N
167    }
168    #[doc = "Checks if the value of the field is `ECCPRIME224N`"]
169    #[inline(always)]
170    pub fn is_eccprime224n(&self) -> bool {
171        *self == MODULUS_A::ECCPRIME224N
172    }
173    #[doc = "Checks if the value of the field is `ECCPRIME192N`"]
174    #[inline(always)]
175    pub fn is_eccprime192n(&self) -> bool {
176        *self == MODULUS_A::ECCPRIME192N
177    }
178}
179#[doc = "Field `MODULUS` writer - Modular Operation Modulus"]
180pub type MODULUS_W<'a> = crate::FieldWriter<'a, u32, WAC_SPEC, u8, MODULUS_A, 4, 0>;
181impl<'a> MODULUS_W<'a> {
182    #[doc = "Generic modulus. p = 2^256"]
183    #[inline(always)]
184    pub fn bin256(self) -> &'a mut W {
185        self.variant(MODULUS_A::BIN256)
186    }
187    #[doc = "Generic modulus. p = 2^128"]
188    #[inline(always)]
189    pub fn bin128(self) -> &'a mut W {
190        self.variant(MODULUS_A::BIN128)
191    }
192    #[doc = "Modulus for B-233 and K-233 ECC curves. p(t) = t^233 + t^74 + 1"]
193    #[inline(always)]
194    pub fn eccbin233p(self) -> &'a mut W {
195        self.variant(MODULUS_A::ECCBIN233P)
196    }
197    #[doc = "Modulus for B-163 and K-163 ECC curves. p(t) = t^163 + t^7 + t^6 + t^3 + 1"]
198    #[inline(always)]
199    pub fn eccbin163p(self) -> &'a mut W {
200        self.variant(MODULUS_A::ECCBIN163P)
201    }
202    #[doc = "Modulus for GCM. P(t) = t^128 + t^7 + t^2 + t + 1"]
203    #[inline(always)]
204    pub fn gcmbin128(self) -> &'a mut W {
205        self.variant(MODULUS_A::GCMBIN128)
206    }
207    #[doc = "Modulus for P-256 ECC curve. p = 2^256 - 2^224 + 2^192 + 2^96 - 1"]
208    #[inline(always)]
209    pub fn eccprime256p(self) -> &'a mut W {
210        self.variant(MODULUS_A::ECCPRIME256P)
211    }
212    #[doc = "Modulus for P-224 ECC curve. p = 2^224 - 2^96 - 1"]
213    #[inline(always)]
214    pub fn eccprime224p(self) -> &'a mut W {
215        self.variant(MODULUS_A::ECCPRIME224P)
216    }
217    #[doc = "Modulus for P-192 ECC curve. p = 2^192 - 2^64 - 1"]
218    #[inline(always)]
219    pub fn eccprime192p(self) -> &'a mut W {
220        self.variant(MODULUS_A::ECCPRIME192P)
221    }
222    #[doc = "P modulus for B-233 ECC curve"]
223    #[inline(always)]
224    pub fn eccbin233n(self) -> &'a mut W {
225        self.variant(MODULUS_A::ECCBIN233N)
226    }
227    #[doc = "P modulus for K-233 ECC curve"]
228    #[inline(always)]
229    pub fn eccbin233kn(self) -> &'a mut W {
230        self.variant(MODULUS_A::ECCBIN233KN)
231    }
232    #[doc = "P modulus for B-163 ECC curve"]
233    #[inline(always)]
234    pub fn eccbin163n(self) -> &'a mut W {
235        self.variant(MODULUS_A::ECCBIN163N)
236    }
237    #[doc = "P modulus for K-163 ECC curve"]
238    #[inline(always)]
239    pub fn eccbin163kn(self) -> &'a mut W {
240        self.variant(MODULUS_A::ECCBIN163KN)
241    }
242    #[doc = "P modulus for P-256 ECC curve"]
243    #[inline(always)]
244    pub fn eccprime256n(self) -> &'a mut W {
245        self.variant(MODULUS_A::ECCPRIME256N)
246    }
247    #[doc = "P modulus for P-224 ECC curve"]
248    #[inline(always)]
249    pub fn eccprime224n(self) -> &'a mut W {
250        self.variant(MODULUS_A::ECCPRIME224N)
251    }
252    #[doc = "P modulus for P-192 ECC curve"]
253    #[inline(always)]
254    pub fn eccprime192n(self) -> &'a mut W {
255        self.variant(MODULUS_A::ECCPRIME192N)
256    }
257}
258#[doc = "Field `MODOP` reader - Modular Operation Field Type"]
259pub type MODOP_R = crate::BitReader<bool>;
260#[doc = "Field `MODOP` writer - Modular Operation Field Type"]
261pub type MODOP_W<'a> = crate::BitWriter<'a, u32, WAC_SPEC, bool, 4>;
262#[doc = "Multiply Width\n\nValue on reset: 0"]
263#[derive(Clone, Copy, Debug, PartialEq)]
264#[repr(u8)]
265pub enum MULWIDTH_A {
266    #[doc = "0: Multiply 256 bits"]
267    MUL256 = 0,
268    #[doc = "1: Multiply 128 bits"]
269    MUL128 = 1,
270    #[doc = "2: Same number of bits as specified by MODULUS"]
271    MULMOD = 2,
272}
273impl From<MULWIDTH_A> for u8 {
274    #[inline(always)]
275    fn from(variant: MULWIDTH_A) -> Self {
276        variant as _
277    }
278}
279#[doc = "Field `MULWIDTH` reader - Multiply Width"]
280pub type MULWIDTH_R = crate::FieldReader<u8, MULWIDTH_A>;
281impl MULWIDTH_R {
282    #[doc = "Get enumerated values variant"]
283    #[inline(always)]
284    pub fn variant(&self) -> Option<MULWIDTH_A> {
285        match self.bits {
286            0 => Some(MULWIDTH_A::MUL256),
287            1 => Some(MULWIDTH_A::MUL128),
288            2 => Some(MULWIDTH_A::MULMOD),
289            _ => None,
290        }
291    }
292    #[doc = "Checks if the value of the field is `MUL256`"]
293    #[inline(always)]
294    pub fn is_mul256(&self) -> bool {
295        *self == MULWIDTH_A::MUL256
296    }
297    #[doc = "Checks if the value of the field is `MUL128`"]
298    #[inline(always)]
299    pub fn is_mul128(&self) -> bool {
300        *self == MULWIDTH_A::MUL128
301    }
302    #[doc = "Checks if the value of the field is `MULMOD`"]
303    #[inline(always)]
304    pub fn is_mulmod(&self) -> bool {
305        *self == MULWIDTH_A::MULMOD
306    }
307}
308#[doc = "Field `MULWIDTH` writer - Multiply Width"]
309pub type MULWIDTH_W<'a> = crate::FieldWriter<'a, u32, WAC_SPEC, u8, MULWIDTH_A, 2, 8>;
310impl<'a> MULWIDTH_W<'a> {
311    #[doc = "Multiply 256 bits"]
312    #[inline(always)]
313    pub fn mul256(self) -> &'a mut W {
314        self.variant(MULWIDTH_A::MUL256)
315    }
316    #[doc = "Multiply 128 bits"]
317    #[inline(always)]
318    pub fn mul128(self) -> &'a mut W {
319        self.variant(MULWIDTH_A::MUL128)
320    }
321    #[doc = "Same number of bits as specified by MODULUS"]
322    #[inline(always)]
323    pub fn mulmod(self) -> &'a mut W {
324        self.variant(MULWIDTH_A::MULMOD)
325    }
326}
327#[doc = "Result Width\n\nValue on reset: 0"]
328#[derive(Clone, Copy, Debug, PartialEq)]
329#[repr(u8)]
330pub enum RESULTWIDTH_A {
331    #[doc = "0: Results have 256 bits"]
332    _256BIT = 0,
333    #[doc = "1: Results have 128 bits"]
334    _128BIT = 1,
335    #[doc = "2: Results have 260 bits. Upper bits of result can be read through DDATA0MSBS in CRYPTO_STATUS"]
336    _260BIT = 2,
337}
338impl From<RESULTWIDTH_A> for u8 {
339    #[inline(always)]
340    fn from(variant: RESULTWIDTH_A) -> Self {
341        variant as _
342    }
343}
344#[doc = "Field `RESULTWIDTH` reader - Result Width"]
345pub type RESULTWIDTH_R = crate::FieldReader<u8, RESULTWIDTH_A>;
346impl RESULTWIDTH_R {
347    #[doc = "Get enumerated values variant"]
348    #[inline(always)]
349    pub fn variant(&self) -> Option<RESULTWIDTH_A> {
350        match self.bits {
351            0 => Some(RESULTWIDTH_A::_256BIT),
352            1 => Some(RESULTWIDTH_A::_128BIT),
353            2 => Some(RESULTWIDTH_A::_260BIT),
354            _ => None,
355        }
356    }
357    #[doc = "Checks if the value of the field is `_256BIT`"]
358    #[inline(always)]
359    pub fn is_256bit(&self) -> bool {
360        *self == RESULTWIDTH_A::_256BIT
361    }
362    #[doc = "Checks if the value of the field is `_128BIT`"]
363    #[inline(always)]
364    pub fn is_128bit(&self) -> bool {
365        *self == RESULTWIDTH_A::_128BIT
366    }
367    #[doc = "Checks if the value of the field is `_260BIT`"]
368    #[inline(always)]
369    pub fn is_260bit(&self) -> bool {
370        *self == RESULTWIDTH_A::_260BIT
371    }
372}
373#[doc = "Field `RESULTWIDTH` writer - Result Width"]
374pub type RESULTWIDTH_W<'a> = crate::FieldWriter<'a, u32, WAC_SPEC, u8, RESULTWIDTH_A, 2, 10>;
375impl<'a> RESULTWIDTH_W<'a> {
376    #[doc = "Results have 256 bits"]
377    #[inline(always)]
378    pub fn _256bit(self) -> &'a mut W {
379        self.variant(RESULTWIDTH_A::_256BIT)
380    }
381    #[doc = "Results have 128 bits"]
382    #[inline(always)]
383    pub fn _128bit(self) -> &'a mut W {
384        self.variant(RESULTWIDTH_A::_128BIT)
385    }
386    #[doc = "Results have 260 bits. Upper bits of result can be read through DDATA0MSBS in CRYPTO_STATUS"]
387    #[inline(always)]
388    pub fn _260bit(self) -> &'a mut W {
389        self.variant(RESULTWIDTH_A::_260BIT)
390    }
391}
392impl R {
393    #[doc = "Bits 0:3 - Modular Operation Modulus"]
394    #[inline(always)]
395    pub fn modulus(&self) -> MODULUS_R {
396        MODULUS_R::new((self.bits & 0x0f) as u8)
397    }
398    #[doc = "Bit 4 - Modular Operation Field Type"]
399    #[inline(always)]
400    pub fn modop(&self) -> MODOP_R {
401        MODOP_R::new(((self.bits >> 4) & 1) != 0)
402    }
403    #[doc = "Bits 8:9 - Multiply Width"]
404    #[inline(always)]
405    pub fn mulwidth(&self) -> MULWIDTH_R {
406        MULWIDTH_R::new(((self.bits >> 8) & 3) as u8)
407    }
408    #[doc = "Bits 10:11 - Result Width"]
409    #[inline(always)]
410    pub fn resultwidth(&self) -> RESULTWIDTH_R {
411        RESULTWIDTH_R::new(((self.bits >> 10) & 3) as u8)
412    }
413}
414impl W {
415    #[doc = "Bits 0:3 - Modular Operation Modulus"]
416    #[inline(always)]
417    pub fn modulus(&mut self) -> MODULUS_W {
418        MODULUS_W::new(self)
419    }
420    #[doc = "Bit 4 - Modular Operation Field Type"]
421    #[inline(always)]
422    pub fn modop(&mut self) -> MODOP_W {
423        MODOP_W::new(self)
424    }
425    #[doc = "Bits 8:9 - Multiply Width"]
426    #[inline(always)]
427    pub fn mulwidth(&mut self) -> MULWIDTH_W {
428        MULWIDTH_W::new(self)
429    }
430    #[doc = "Bits 10:11 - Result Width"]
431    #[inline(always)]
432    pub fn resultwidth(&mut self) -> RESULTWIDTH_W {
433        RESULTWIDTH_W::new(self)
434    }
435    #[doc = "Writes raw bits to the register."]
436    #[inline(always)]
437    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
438        self.0.bits(bits);
439        self
440    }
441}
442#[doc = "Wide Arithmetic Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [wac](index.html) module"]
443pub struct WAC_SPEC;
444impl crate::RegisterSpec for WAC_SPEC {
445    type Ux = u32;
446}
447#[doc = "`read()` method returns [wac::R](R) reader structure"]
448impl crate::Readable for WAC_SPEC {
449    type Reader = R;
450}
451#[doc = "`write(|w| ..)` method takes [wac::W](W) writer structure"]
452impl crate::Writable for WAC_SPEC {
453    type Writer = W;
454}
455#[doc = "`reset()` method sets WAC to value 0"]
456impl crate::Resettable for WAC_SPEC {
457    #[inline(always)]
458    fn reset_value() -> Self::Ux {
459        0
460    }
461}