1 /***************************************************************************//**
2 * \file cy_cryptolite_trng_config.h
3 * \version 2.50
4 *
5 * \brief
6 *  This file provides  constants and parameters
7 *  for the Cryptolite TRNG driver.
8 *
9 ********************************************************************************
10 * Copyright 2016-2020 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 *    http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25 
26 
27 #if !defined (CY_CRYPTOLITE_TRNG_CONFIG_H)
28 #define CY_CRYPTOLITE_TRNG_CONFIG_H
29 
30 #include "cy_device.h"
31 
32 #if defined (CY_IP_MXCRYPTOLITE)
33 
34 #if defined(__cplusplus)
35 extern "C" {
36 #endif
37 
38 #include "cy_cryptolite_common.h"
39 
40 
41 #if (CRYPTOLITE_TRNG_PRESENT == 1)
42 #if defined(CY_CRYPTOLITE_CFG_TRNG_C)
43 
44 /** TRNG Configuration default values */
45 /**
46 * Specifies the clock divider that is used to sample oscillator data.
47 * "0": sample clock is "clk_sys".
48 * "1": sample clock is "clk_sys"/2.
49 * ...
50 * "255": sample clock is "clk_sys"/256.
51 */
52 #define CY_CRYPTOLITE_DEF_TRNG_SAMPLE_CLOCK_DIV          (1UL)
53 
54 /**
55 * Specifies the clock divider used to produce reduced bits.
56 * "0": 1 reduced bit is produced for each sample.
57 * "1": 1 reduced bit is produced for each 2 samples.
58 * ...
59 * "255": 1 reduced bit is produced for each 256 samples.
60 *
61 * The reduced bits are considered random bits and shifted into TR_RESULT0.DATA32.
62 */
63 #define CY_CRYPTOLITE_DEF_TRNG_RED_CLOCK_DIV                  (3UL)
64 
65 /**
66 * Specifies an initialization delay: a number of removed/dropped samples before
67 * reduced bits are generated. This field should be programmed in the range [1, 255].
68 * After starting the oscillators, at least the first 2 samples should be
69 * removed/dropped to clear the state of internal synchronizers. In addition,
70 * it is advised to drop at least the second 2 samples from the oscillators
71 * (to circumvent the semi-predictable oscillator start-up behavior). This results
72 * in the default field value of "3". the field encoding is as follows:
73 * "0": 1 sample is dropped.
74 * "1": 2 samples are dropped.
75 * ...
76 * "255": 256 samples are dropped.
77 *
78 * The TR_INITIALIZED interrupt cause is set to '1', when the initialization delay is passed.
79 */
80 #define CY_CRYPTOLITE_DEF_TRNG_INIT_DELAY                        (255UL)
81 
82 /**
83 * Specifies if the "von Neumann corrector" is disabled or enabled:
84 * '0': disabled.
85 * '1': enabled.
86 * The "von Neumann corrector" post-processes the reduced bits to remove a '0' or '1' bias.
87 * The corrector operates on reduced bit pairs ("oldest bit, newest bit"):
88 * "00": no bit is produced.
89 * "01": '0' bit is produced (oldest bit).
90 * "10": '1' bit is produced (oldest bit).
91 * "11": no bit is produced.
92 * NOTE: The corrector produces bits at a random pace and at a frequency that
93 * is 1/4 of the reduced bit frequency (reduced bits are processed in pairs,
94 * and half of the pairs do NOT produce a bit).
95 */
96 #define CY_CRYPTOLITE_DEF_TRNG_VON_NEUMANN_CORR            (1UL)
97 
98 /**
99 * Specifies if the TRNG adaptive proportion test is enabled
100 * Is test fails HW sets INTR.TR_AP_DETECT to '1' */
101 #define CY_CRYPTOLITE_DEF_TRNG_AP_ENABLE          (1UL)
102 
103 /**
104 * Specifies if the TRNG repetition count test is enabled
105 * Is test fails HW sets INTR.TR_RC_DETECT to '1' */
106 #define CY_CRYPTOLITE_DEF_TRNG_RC_ENABLE          (1UL)
107 
108 /**
109 * Specifies if the TRNG functionality is stopped on an adaptive proportion test
110 * detection (when HW sets INTR.TR_AP_DETECT to '1'):
111 * '0': Functionality is stopped (TR_CTL1 fields are set to '0' by HW).
112 * '1': Functionality is NOT stopped.
113 */
114 #define CY_CRYPTOLITE_DEF_TRNG_STOP_ON_AP_DETECT          (1UL)
115 
116 /**
117 * Specifies if the TRNG functionality is stopped on a repetition count test detection
118 * (when HW sets INTR.TR_RC_DETECT to '1'):
119 * '0': Functionality is stopped (TR_CTL1 fields are set to '0' by HW).
120 * '1': Functionality is NOT stopped.
121 */
122 #define CY_CRYPTOLITE_DEF_TRNG_STOP_ON_RC_DETECT          (1UL)
123 
124 /**
125 * The polynomial for programmable Galois ring oscillator. The polynomial is represented
126 * WITHOUT the high order bit (this bit is always assumed '1'). The polynomial should be aligned
127 * so that the more significant bits (bit 30 and down) contain the polynomial and the less
128 * significant bits (bit 0 and up) contain padding '0's.
129 */
130 #define CY_CRYPTOLITE_DEF_TRNG_GARO                                    (0xb2d1ab70U)
131 
132 /**
133 * The polynomial for the programmable Fibonacci ring oscillator. The polynomial is represented
134 * WITHOUT the high order bit (this bit is always assumed '1'). The polynomial should
135 * be aligned so that the more significant bits (bit 30 and down) contain the polynomial
136 * and the less significant bits (bit 0 and up) contain padding '0's.
137 */
138 #define CY_CRYPTOLITE_DEF_TRNG_FIRO                                    (0xe6b8c3b3UL)
139 
140 /**
141 * Selection of the bit stream:
142 * "0": DAS bit stream.
143 * "1": RED bit stream.
144 * "2": TR bit stream.
145 * "3": Undefined.
146 */
147 #define CY_CRYPTOLITE_DEF_TRNG_BITSTREAM_SEL                  (CY_CRYPTOLITE_TRMON_BS_TR)
148 
149 /**
150 * Cut-off count (legal range is [1, 255]):
151 * "0": Illegal.
152 * "1": 1 repetition.
153 * ...
154 * "255": 255 repetitions.
155 */
156 #define CY_CRYPTOLITE_DEF_TRNG_CUTOFF_COUNT8                  (255UL)
157 
158 /**
159 * Cut-off count (legal range is [1, 65535]).
160 * "0": Illegal.
161 * "1": 1 occurrence.
162 * ...
163 * "65535": 65535 occurrences.
164 */
165 #define CY_CRYPTOLITE_DEF_TRNG_CUTOFF_COUNT16                (255UL)
166 
167 /**
168 * The window size (minus 1) :
169 * "0": 1 bit.
170 * ...
171 * "65535": 65536 bits.
172 */
173 
174 #define CY_CRYPTOLITE_DEF_TRNG_WINDOW_SIZE           (255UL)
175 
176 
177 #if defined(__cplusplus)
178 }
179 #endif
180 
181 #endif /* CRYPTOLITE_TRNG_PRESENT */
182 #endif /* CY_CRYPTOLITE_CFG_TRNG_C */
183 #endif /* CY_IP_MXCRYPTOLITE */
184 
185 #endif /* #if !defined (CY_CRYPTOLITE_TRNG_CONFIG_H) */
186 
187 
188 /* [] END OF FILE */
189