mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-23 21:57:33 -04:00
minor edits, optimizations and clean-ups
This commit is contained in:
parent
3904793c5f
commit
381044745b
4 changed files with 11 additions and 4 deletions
BIN
docs/NEORV32.pdf
BIN
docs/NEORV32.pdf
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 52 KiB |
|
@ -52,8 +52,8 @@ entity neorv32_cpu_cp_muldiv is
|
|||
clk_i : in std_ulogic; -- global clock, rising edge
|
||||
rstn_i : in std_ulogic; -- global reset, low-active, async
|
||||
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
||||
-- data input --
|
||||
start_i : in std_ulogic; -- trigger operation
|
||||
-- data input --
|
||||
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
||||
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
||||
-- result and status --
|
||||
|
|
|
@ -71,7 +71,7 @@ int neorv32_uart_available(void) {
|
|||
/**********************************************************************//**
|
||||
* Enable and configure UART.
|
||||
*
|
||||
* @warning The 'UART_SIM_MODE' compiler flag will redirect all UART TX data to the simulation output. Use this for simulations only!
|
||||
* @warning The 'UART_SIM_MODE' compiler flag will configure UART for simulation mode: all UART TX data will be redirected to simulation output. Use this for simulations only!
|
||||
* @warning To enable simulation mode add <USER_FLAGS+=-DUART_SIM_MODE> when compiling.
|
||||
*
|
||||
* @param[in] baudrate Targeted BAUD rate (e.g. 9600).
|
||||
|
@ -82,14 +82,21 @@ void neorv32_uart_setup(uint32_t baudrate, uint8_t rx_irq, uint8_t tx_irq) {
|
|||
|
||||
UART_CT = 0; // reset
|
||||
|
||||
// raw baud rate prescaler
|
||||
uint32_t clock = SYSINFO_CLK;
|
||||
uint16_t i = 0; // BAUD rate divisor
|
||||
uint8_t p = 0; // prsc = CLK/2
|
||||
uint8_t p = 0; // initial prsc = CLK/2
|
||||
|
||||
// raw clock prescaler
|
||||
#ifdef __riscv_div
|
||||
// use div instructions
|
||||
i = (uint16_t)(clock / (2*baudrate));
|
||||
#else
|
||||
// division via repeated subtraction
|
||||
while (clock >= 2*baudrate) {
|
||||
clock -= 2*baudrate;
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
|
||||
// find clock prsc
|
||||
while (i >= 0x0fff) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue