Software APIs
device_fpga_cw340.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
21const uint64_t kClockFreqCpuMhz = 24;
22
23const uint64_t kClockFreqCpuHz = kClockFreqCpuMhz * 1000 * 1000;
24
25uint64_t to_cpu_cycles(uint64_t usec) { return usec * kClockFreqCpuMhz; }
26
27const uint64_t kClockFreqHiSpeedPeripheralHz = 24 * 1000 * 1000; // 24MHz
28
29const uint64_t kClockFreqPeripheralHz = 6 * 1000 * 1000; // 6MHz
30
31const uint64_t kClockFreqUsbHz = 48 * 1000 * 1000; // 48MHz
32
33const uint64_t kClockFreqAonHz = 250 * 1000; // 250kHz
34
35const uint64_t kUartBaudrate = 115200;
36
37const uint32_t kUartNCOValue =
38 CALCULATE_UART_NCO(kUartBaudrate, kClockFreqPeripheralHz);
39
40const uint32_t kUartBaud115K =
41 CALCULATE_UART_NCO(115200, kClockFreqPeripheralHz);
42const uint32_t kUartBaud230K =
43 CALCULATE_UART_NCO(115200 * 2, kClockFreqPeripheralHz);
44const uint32_t kUartBaud460K =
45 CALCULATE_UART_NCO(115200 * 4, kClockFreqPeripheralHz);
46const uint32_t kUartBaud921K =
47 CALCULATE_UART_NCO(115200 * 8, kClockFreqPeripheralHz);
48const uint32_t kUartBaud1M33 =
49 CALCULATE_UART_NCO(1333333, kClockFreqPeripheralHz);
50const uint32_t kUartBaud1M50 =
51 CALCULATE_UART_NCO(1500000, kClockFreqPeripheralHz);
52
54 kUartBaudrate, kClockFreqCpuHz, UART_PARAM_TX_FIFO_DEPTH);
55
56const uint32_t kAstCheckPollCpuCycles =
58
59uintptr_t device_test_status_address(void) { return 0; }
60
61uintptr_t device_log_bypass_uart_address(void) { return 0; }
62
63const bool kJitterEnabled = false;
64
66 // This value is guaranteed to be zero on all non-FPGA implementations.
67 uint32_t fpga = ibex_fpga_version();
68 // : M O R
69 const uint32_t kRom = 0x3a4d4f52;
70 uart_write_imm(kRom);
71 // The cast to unsigned int stops GCC from complaining about uint32_t
72 // being a `long unsigned int` while the %x specifier takes `unsigned int`.
73 const uint32_t kNewline = 0x0a0d;
74 uart_write_hex(fpga, sizeof(fpga), kNewline);
75}