File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright lowRISC contributors.
2
+ # Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ """Communication interface for OpenTitan RNG FI framework.
5
+
6
+ Communication with OpenTitan happens over the uJSON command interface.
7
+ """
8
+ import json
9
+ import time
10
+ from typing import Optional
11
+
12
+
13
+ from target .communication .otfi import OTFI
14
+ from target .communication .otfi_test import OTFITest
15
+
16
+
17
+ class OTFIRng (OTFI ):
18
+ TESTS = [
19
+ OTFITest ("csrng_bias" ),
20
+ OTFITest ("edn_bus_ack" ),
21
+ ]
22
+
23
+ def __init__ (self , target ) -> None :
24
+ super ().__init__ (target , "Rng" )
25
+
26
+ def init (self , test : Optional [str ] = "" ) -> None :
27
+ """ Initialize the RNG FI code on the chip.
28
+
29
+ Args:
30
+ test: The selected test.
31
+ Returns:
32
+ The device ID of the device.
33
+ """
34
+ # RngFi command.
35
+ self ._ujson_fi_cmd ()
36
+ # Init command.
37
+ time .sleep (0.01 )
38
+ if "csrng" in test :
39
+ self .target .write (json .dumps ("CsrngInit" ).encode ("ascii" ))
40
+ else :
41
+ self .target .write (json .dumps ("EdnInit" ).encode ("ascii" ))
42
+ # Read back device ID from device.
43
+ return self .read_response (max_tries = 30 )
You can’t perform that action at this time.
0 commit comments