Software APIs
device_sim_verilator.c File Reference

Device-specific symbol definitions for the Verilator device. More...

#include <assert.h>
#include <stdbool.h>
#include "dt/dt_rv_core_ibex.h"
#include "sw/device/lib/arch/device.h"
#include "rv_core_ibex_regs.h"

Go to the source code of this file.

Macros

#define CPU_FREQ_HZ   500 * 1000
 

Functions

uint64_t to_cpu_cycles (uint64_t usec)
 A platform-specific function to convert microseconds to cpu cycles.
 
uintptr_t device_test_status_address (void)
 An address to write to report test status.
 
uintptr_t device_log_bypass_uart_address (void)
 An address to write use for UART logging bypass.
 

Variables

const device_type_t kDeviceType = kDeviceSimVerilator
 Indicates the device that this program has been linked for.
 
const uint64_t kClockFreqCpuHz = CPU_FREQ_HZ
 The CPU clock frequency of the device, in hertz.
 
const uint64_t kClockFreqHiSpeedPeripheralHz = 500 * 1000
 The high-speed peripheral clock frequency of the device, in hertz.
 
const uint64_t kClockFreqPeripheralHz = 125 * 1000
 The peripheral clock frequency of the device, in hertz.
 
const uint64_t kClockFreqUsbHz = 500 * 1000
 The USB clock frequency of the device, in hertz.
 
const uint64_t kClockFreqAonHz = 125 * 1000
 The always on clock frequency of the device, in hertz.
 
const uint64_t kUartBaudrate = 7200
 The baudrate of the UART peripheral (if such a thing is present).
 
const uint32_t kUartNCOValue
 The pre-calculated UART NCO value based on the Baudrate and Peripheral clock.
 
const uint32_t kUartBaud115K
 Additional pre-calculated UART NCO values.
 
const uint32_t kUartBaud230K
 
const uint32_t kUartBaud460K
 
const uint32_t kUartBaud921K
 
const uint32_t kUartBaud1M33
 
const uint32_t kUartBaud1M50
 
const uint32_t kAstCheckPollCpuCycles
 Maximum duration of the AST initialization check poll in CPU cycles.
 

Detailed Description

Device-specific symbol definitions for the Verilator device.

Definition in file device_sim_verilator.c.

Macro Definition Documentation

◆ CPU_FREQ_HZ

#define CPU_FREQ_HZ   500 * 1000

Definition at line 31 of file device_sim_verilator.c.

Function Documentation

◆ device_log_bypass_uart_address()

uintptr_t device_log_bypass_uart_address ( void )

An address to write use for UART logging bypass.

If this is zero, there is no address to write to bypass UART logging.

See also
LOG

Definition at line 75 of file device_sim_verilator.c.

◆ device_test_status_address()

uintptr_t device_test_status_address ( void )

An address to write to report test status.

If this is zero, there is no address to write to report test status.

Depending on the simulation environment and the value written to this address, the simulation may stop.

See also
test_status_set

Definition at line 71 of file device_sim_verilator.c.

◆ to_cpu_cycles()

uint64_t to_cpu_cycles ( uint64_t usec)

A platform-specific function to convert microseconds to cpu cycles.

This is primarily used for spin waits that use the cpu cycle counters. For platforms with clock periods slower than 1 us this will round up.

Definition at line 36 of file device_sim_verilator.c.

Variable Documentation

◆ kAstCheckPollCpuCycles

const uint32_t kAstCheckPollCpuCycles
Initial value:

Maximum duration of the AST initialization check poll in CPU cycles.

This number depends on kClockFreqCpuHz and the resulting duration must be 100us.

Definition at line 68 of file device_sim_verilator.c.

◆ kClockFreqAonHz

const uint64_t kClockFreqAonHz = 125 * 1000

The always on clock frequency of the device, in hertz.

This is the operating clock used by the always on timer, power manager and other peripherals that continue to operate after the device is in sleep state.

Definition at line 48 of file device_sim_verilator.c.

◆ kClockFreqCpuHz

const uint64_t kClockFreqCpuHz = CPU_FREQ_HZ

The CPU clock frequency of the device, in hertz.

This is the operating clock for the main processing host.

Definition at line 32 of file device_sim_verilator.c.

◆ kClockFreqHiSpeedPeripheralHz

const uint64_t kClockFreqHiSpeedPeripheralHz = 500 * 1000

The high-speed peripheral clock frequency of the device, in hertz.

This is the operating clock used by the spi host

Definition at line 42 of file device_sim_verilator.c.

◆ kClockFreqPeripheralHz

const uint64_t kClockFreqPeripheralHz = 125 * 1000

The peripheral clock frequency of the device, in hertz.

This is the operating clock used by timers, uarts, other peripheral interfaces.

Definition at line 44 of file device_sim_verilator.c.

◆ kClockFreqUsbHz

const uint64_t kClockFreqUsbHz = 500 * 1000

The USB clock frequency of the device, in hertz.

This is the operating clock used by the USB phy interface and USB's software interface.

Definition at line 46 of file device_sim_verilator.c.

◆ kDeviceType

const device_type_t kDeviceType = kDeviceSimVerilator

Indicates the device that this program has been linked for.

This can be used, for example, for conditioning an operation on the precise device type.

Indicates the device that this program has been linked for.

Definition at line 26 of file device_sim_verilator.c.

◆ kUartBaud115K

const uint32_t kUartBaud115K
Initial value:
=
CALCULATE_UART_NCO(115200, kClockFreqPeripheralHz)

Additional pre-calculated UART NCO values.

If the pre-calculated value is zero, then the corresponding baudrate is not supported.

Definition at line 55 of file device_sim_verilator.c.

◆ kUartBaud1M33

const uint32_t kUartBaud1M33
Initial value:
=
CALCULATE_UART_NCO(1333333, kClockFreqPeripheralHz)

Definition at line 63 of file device_sim_verilator.c.

◆ kUartBaud1M50

const uint32_t kUartBaud1M50
Initial value:
=
CALCULATE_UART_NCO(1500000, kClockFreqPeripheralHz)

Definition at line 65 of file device_sim_verilator.c.

◆ kUartBaud230K

const uint32_t kUartBaud230K
Initial value:
=
CALCULATE_UART_NCO(115200 * 2, kClockFreqPeripheralHz)

Definition at line 57 of file device_sim_verilator.c.

◆ kUartBaud460K

const uint32_t kUartBaud460K
Initial value:
=
CALCULATE_UART_NCO(115200 * 4, kClockFreqPeripheralHz)

Definition at line 59 of file device_sim_verilator.c.

◆ kUartBaud921K

const uint32_t kUartBaud921K
Initial value:
=
CALCULATE_UART_NCO(115200 * 8, kClockFreqPeripheralHz)

Definition at line 61 of file device_sim_verilator.c.

◆ kUartBaudrate

const uint64_t kUartBaudrate = 7200

The baudrate of the UART peripheral (if such a thing is present).

Definition at line 50 of file device_sim_verilator.c.

◆ kUartNCOValue

const uint32_t kUartNCOValue
Initial value:
=

The pre-calculated UART NCO value based on the Baudrate and Peripheral clock.

Definition at line 52 of file device_sim_verilator.c.