Software APIs
device_fpga_cw310.c
Go to the documentation of this file.
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include <stdbool.h>
6 
9 #include "sw/device/silicon_creator/lib/drivers/ibex.h"
10 #include "sw/device/silicon_creator/lib/drivers/uart.h"
11 
12 #include "uart_regs.h"
13 
14 /**
15  * @file
16  * @brief Device-specific symbol definitions for the ChipWhisperer CW310 device.
17  */
18 
20 
21 const uint64_t kClockFreqCpuMhz = 24;
22 
23 const uint64_t kClockFreqCpuHz = kClockFreqCpuMhz * 1000 * 1000;
24 
25 uint64_t to_cpu_cycles(uint64_t usec) { return usec * kClockFreqCpuMhz; }
26 
27 const uint64_t kClockFreqHiSpeedPeripheralHz = 24 * 1000 * 1000; // 24MHz
28 
29 const uint64_t kClockFreqPeripheralHz = 6 * 1000 * 1000; // 6MHz
30 
31 const uint64_t kClockFreqUsbHz = 48 * 1000 * 1000; // 48MHz
32 
33 const uint64_t kClockFreqAonHz = 250 * 1000; // 250kHz
34 
35 const uint64_t kUartBaudrate = 115200;
36 
37 const uint32_t kUartNCOValue =
38  CALCULATE_UART_NCO(kUartBaudrate, kClockFreqPeripheralHz);
39 
40 const uint32_t kUartBaud115K =
41  CALCULATE_UART_NCO(115200, kClockFreqPeripheralHz);
42 const uint32_t kUartBaud230K =
43  CALCULATE_UART_NCO(115200 * 2, kClockFreqPeripheralHz);
44 const uint32_t kUartBaud460K =
45  CALCULATE_UART_NCO(115200 * 4, kClockFreqPeripheralHz);
46 const uint32_t kUartBaud921K =
47  CALCULATE_UART_NCO(115200 * 8, kClockFreqPeripheralHz);
48 const uint32_t kUartBaud1M33 =
49  CALCULATE_UART_NCO(1333333, kClockFreqPeripheralHz);
50 const uint32_t kUartBaud1M50 =
51  CALCULATE_UART_NCO(1500000, kClockFreqPeripheralHz);
52 
54  kUartBaudrate, kClockFreqCpuHz, UART_PARAM_TX_FIFO_DEPTH);
55 
56 const uint32_t kAstCheckPollCpuCycles =
58 
59 const uintptr_t kDeviceTestStatusAddress = 0;
60 
61 const uintptr_t kDeviceLogBypassUartAddress = 0;
62 
64  // This value is guaranteed to be zero on all non-FPGA implementations.
65  uint32_t fpga = ibex_fpga_version();
66  // : M O R
67  const uint32_t kRom = 0x3a4d4f52;
68  uart_write_imm(kRom);
69  // The cast to unsigned int stops GCC from complaining about uint32_t
70  // being a `long unsigned int` while the %x specifier takes `unsigned int`.
71  const uint32_t kNewline = 0x0a0d;
72  uart_write_hex(fpga, sizeof(fpga), kNewline);
73 }