You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-42Lines changed: 23 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,12 @@ The CPU is implemented using a variable-size build-order-independent subframe ar
25
25
|`0x00000000`| Configurable | R/X | Program ROM |
26
26
| Configurable | Configurable | R/X | Data ROM |
27
27
|`0x80000000`| Configurable | R/W/X/A\*| RAM |
28
-
|`0xf0000000`|`0x4`| R/W |`mtime`|
29
-
|`0xf0000004`|`0x4`| R/W |`mtimeh`|
30
-
|`0xf0000008`|`0x4`| R/W |`mtimecmp`|
31
-
|`0xf000000c`|`0x4`| R/W |`mtimecmph`|
32
-
|`0xf0000010`|`0x20`| R/W | UART0 |
33
-
|`0xf0000030`|`0x20`| R/W | UART1 |
34
-
|`0xf0000050`|`0x20`| R/W | UART2 |
35
-
|`0xf0000070`|`0x20`| R/W | UART3 |
28
+
|`0xf0000000`|`0x8`| R/W |`mtime`|
29
+
|`0xf0000008`|`0x8`| R/W |`mtimecmp`|
30
+
|`0xf0000010`|`0x10`| R/W | UART0 |
31
+
|`0xf0000020`|`0x10`| R/W | UART1 |
32
+
|`0xf0000030`|`0x10`| R/W | UART2 |
33
+
|`0xf0000040`|`0x10`| R/W | UART3 |
36
34
|`0xfffffff0`|`0x4`| R/W | Syscon |
37
35
38
36
\* Atomic instructions are only supported in RAM.
@@ -49,27 +47,19 @@ The `mtime` and `mtimecmp` registers are mapped to `0xf0000000` and `0xf0000008`
49
47
50
48
### UART
51
49
52
-
The processor includes four identical emulated UART 16550 peripherals based on [this datasheet](https://caro.su/msx/ocm_de1/16550.pdf). The UARTs support the following features:
50
+
The processor includes four instances of an emulated UART peripheral compatible with the [AXI UART Lite](https://docs.amd.com/v/u/en-US/pg142-axi-uartlite). The UARTs support the following features:
53
51
52
+
- Up to 32 data bits.
54
53
- Configurable FIFO capacity (up to 253 bytes) for TX and RX, stored as a variable in the CONFIG processor.
55
54
- Theoretical maximum transfer rate of 121440 bits/sec (253 bytes/tick).
56
-
- Line Status Register flags: Transmitter Empty, THR Empty, Overrun Error, Data Ready.
57
-
- FIFO Control Register flags: Enable FIFOs (0 is ignored), Reset RX/TX FIFO
58
-
59
-
The UART registers have a stride of 4 bytes to simplify some internal logic.
- Edge-triggered interrupts for RX FIFO non-empty and TX FIFO empty.
56
+
57
+
| Offset | Access Type | Register |
58
+
| ------ | ----------- | -------- |
59
+
|`0x0`| R | RX FIFO |
60
+
|`0x4`| W | TX FIFO |
61
+
|`0x8`| R | Status |
62
+
|`0xc`| W | Control |
73
63
74
64
Each UART is implemented as two circular buffers in a memory bank with the following layout. Note that RX refers to data sent to / read by the processor, and TX refers to data sent from / written by the processor.
75
65
@@ -82,28 +72,19 @@ Each UART is implemented as two circular buffers in a memory bank with the follo
82
72
| 510 | TX buffer read pointer |
83
73
| 511 | TX buffer write pointer |
84
74
85
-
Read/write pointers are stored modulo `capacity + 1`. A buffer is empty when `rptr == wptr` and full when `rptr == (wptr + 1) % (capacity + 1)`. If the RX buffer is full and more data arrives, producers should discard the new data rather than overwriting old data in the buffer. An overflow may optionally be indicated to the processor by setting bit 8 of `rx_wptr` (ie. `rx_wptr | 0x100`).
75
+
Read/write pointers are stored modulo `capacity + 1`. A buffer is empty when `rptr == wptr` and full when `rptr == (wptr + 1) % (capacity + 1)`. If the RX buffer is full and more data arrives, producers should discard the new data rather than overwriting old data in the buffer.
86
76
87
-
Note that the processor itself does not set the TX overflow flag or prevent code from overflowing the TX buffer. Users are expected to check the Line Status Register and avoid writing too much data at once.
77
+
Note that the processor itself does not prevent code from overflowing the TX buffer. Users are expected to check the Status register and avoid writing too much data at once.
88
78
89
-
If any UART interrupt is pending, `mip.MEIP` will become pending. To make UART interrupts visible to S-mode, M-mode software must either delegate `mip.MEIP` via `mideleg`, or manually update `mip.SEIP` in an M-mode interrupt handler.
79
+
If any UART interrupt is pending, `mip.MEIP` will become pending. To make UART interrupts visible to S-mode, M-mode software must either delegate `mip.MEIP` via `mideleg`, or manually update `mip.SEIP` in an M-mode interrupt handler. The interrupt for a given port is cleared when any register for that port is accessed.
90
80
91
81
Internally, UART interrupts are implemented using the `uart_flags` variable.
0 commit comments