![]() |
NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
|
Conway's game of life in a UART terminal. More...
#include <neorv32.h>Macros | |
User configuration | |
| #define | BAUD_RATE (19200) |
| #define | NUM_CELLS_X (160) |
| #define | NUM_CELLS_Y (40) |
| #define | GEN_DELAY (500) |
| #define | CELL_DEAD (' ') |
| #define | CELL_ALIVE ('#') |
Functions | |
| void | clear_universe (int u) |
| void | set_cell (int u, int x, int y) |
| int | get_cell (int u, int x, int y) |
| int | get_neighborhood (int u, int x, int y) |
| void | print_universe (int u) |
| int | pop_count (int u) |
| void | delay_ms (uint32_t time_ms) |
| int | main (void) |
Variables | |
| uint8_t | universe [2][NUM_CELLS_X/8][NUM_CELLS_Y] |
Conway's game of life in a UART terminal.
| #define BAUD_RATE (19200) |
UART BAUD rate
| #define CELL_ALIVE ('#') |
Symbol for alive cell
| #define CELL_DEAD (' ') |
Symbol for dead cell
| #define GEN_DELAY (500) |
Delay between generations in ms
| #define NUM_CELLS_X (160) |
Universe x size (has to be a multiple of 8)
| #define NUM_CELLS_Y (40) |
Universe y size
| void clear_universe | ( | int | u | ) |
Kill all cells in universe.
| [in] | u | Universe select (0 or 1). |
| void delay_ms | ( | uint32_t | time_ms | ) |
Simple bus-wait helper.
| [in] | time_ms | Time in ms to wait (unsigned 32-bit). |
| int get_cell | ( | int | u, |
| int | x, | ||
| int | y ) |
Get state of cell.
| [in] | u | Universe select (0 or 1). |
| [in] | x | X coordinate of cell. |
| [in] | y | Y coordinate of cell. |
| int get_neighborhood | ( | int | u, |
| int | x, | ||
| int | y ) |
Get number of living cells in neighborhood.
| [in] | u | Universe select (0 or 1). |
| [in] | x | X coordinate of the neighborhood's center cell. |
| [in] | y | Y coordinate of the neighborhood's center cell. |
| int main | ( | void | ) |
Conway's Game of Life.
| int pop_count | ( | int | u | ) |
Count living cells in universe.
| [in] | u | Universe select (0 or 1). |
| void print_universe | ( | int | u | ) |
Print universe via UARt.
| [in] | u | Universe select (0 or 1). |
| void set_cell | ( | int | u, |
| int | x, | ||
| int | y ) |
Make cell alive.
| [in] | u | Universe select (0 or 1). |
| [in] | x | X coordinate of cell. |
| [in] | y | Y coordinate of cell. |
| uint8_t universe[2][NUM_CELLS_X/8][NUM_CELLS_Y] |
The universe