Skip to content

Commit 9aed72b

Browse files
authored
Merge pull request #4 from jakubcabal/dev
Merge version 1.3 of UART module to master
2 parents e556cb6 + a5f1780 commit 9aed72b

25 files changed

+924
-226
lines changed

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog of Simple UART for FPGA
2+
3+
**Version 1.3 - released on 10 April 2021**
4+
- Added better simulation with automatic checking of transactions.
5+
- Little code cleaning and code optimization.
6+
- Added UART2WB bridge example (access to WB registers via UART).
7+
- Added Parity Error output.
8+
9+
**Version 1.2 - released on 23 December 2019**
10+
- Added double FF for safe CDC.
11+
- Fixed fake received transaction after FPGA boot without reset.
12+
- Added more precisely clock dividers, dividing with rounding.
13+
- UART loopback example is for CYC1000 board now.
14+
15+
**Version 1.1 - released on 20 December 2018**
16+
- Added better debouncer.
17+
- Added simulation script and Quartus project file.
18+
- Removed unnecessary resets.
19+
- Signal BUSY replaced by DIN_RDY.
20+
- Many other optimizations and changes.
21+
22+
**Version 1.0 - released on 27 May 2016**
23+
- Initial release.

README.md

+87-32
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,114 @@ Simple UART for FPGA is UART (Universal Asynchronous Receiver & Transmitter) con
66

77
The UART controller was simulated and tested in hardware.
88

9-
## Inputs and outputs ports:
9+
## UART controller:
10+
11+
### Generics:
12+
13+
```
14+
CLK_FREQ : integer := 50e6; -- system clock frequency in Hz
15+
BAUD_RATE : integer := 115200; -- baud rate value
16+
PARITY_BIT : string := "none"; -- type of parity: "none", "even", "odd", "mark", "space"
17+
USE_DEBOUNCER : boolean := True -- enable/disable debouncer
18+
```
19+
20+
### Inputs and outputs ports:
1021

1122
```
1223
-- CLOCK AND RESET
13-
CLK : in std_logic; -- system clock
14-
RST : in std_logic; -- high active synchronous reset
24+
CLK : in std_logic; -- system clock
25+
RST : in std_logic; -- high active synchronous reset
1526
-- UART INTERFACE
16-
UART_TXD : out std_logic; -- serial transmit data
17-
UART_RXD : in std_logic; -- serial receive data
27+
UART_TXD : out std_logic; -- serial transmit data
28+
UART_RXD : in std_logic; -- serial receive data
1829
-- USER DATA INPUT INTERFACE
19-
DIN : in std_logic_vector(7 downto 0); -- input data to be transmitted over UART
20-
DIN_VLD : in std_logic; -- when DIN_VLD = 1, input data (DIN) are valid
21-
DIN_RDY : out std_logic -- when DIN_RDY = 1, transmitter is ready and valid input data will be accepted for transmiting
30+
DIN : in std_logic_vector(7 downto 0); -- input data to be transmitted over UART
31+
DIN_VLD : in std_logic; -- when DIN_VLD = 1, input data (DIN) are valid
32+
DIN_RDY : out std_logic -- when DIN_RDY = 1, transmitter is ready and valid input data will be accepted for transmiting
2233
-- USER DATA OUTPUT INTERFACE
23-
DOUT : out std_logic_vector(7 downto 0); -- output data received via UART
24-
DOUT_VLD : out std_logic; -- when DOUT_VLD = 1, output data (DOUT) are valid (is assert only for one clock cycle)
25-
FRAME_ERROR : out std_logic -- when FRAME_ERROR = 1, stop bit was invalid (is assert only for one clock cycle)
34+
DOUT : out std_logic_vector(7 downto 0); -- output data received via UART
35+
DOUT_VLD : out std_logic; -- when DOUT_VLD = 1, output data (DOUT) are valid (is assert only for one clock cycle)
36+
FRAME_ERROR : out std_logic; -- when FRAME_ERROR = 1, stop bit was invalid (is assert only for one clock cycle)
37+
PARITY_ERROR : out std_logic -- when PARITY_ERROR = 1, parity bit was invalid (is assert only for one clock cycle)
2638
```
2739

28-
## Generics:
40+
### User interface examples:
41+
42+
Example of sending data on the user interface of the UART controller.
2943

44+
![Example of sending data on the user interface](docs/user_din.svg)
45+
46+
Example of receiving data on the user interface of the UART controller. The last transaction in the example was corrupted during transmission, it contains a bad parity and stop bit.
47+
48+
![Example of receiving data on the user interface](docs/user_dout.svg)
49+
50+
### Table of resource usage summary:
51+
52+
Parity type | LE | FF | M9k | Fmax
53+
:---:|:---:|:---:|:---:|:---:
54+
none | 77 | 56 | 0 | 305.5 MHz
55+
even/odd | 84 | 60 | 0 | 289.4 MHz
56+
mark/space | 82 | 60 | 0 | 290.7 MHz
57+
58+
*Implementation was performed using Quartus Prime Lite Edition 20.1.0 for Intel Cyclone 10 FPGA (10CL025YU256C8G). Setting of some generics: USE_DEBOUNCER = True, BAUD_RATE = 115200, CLK_FREQ = 50e6.*
59+
60+
## Simulation:
61+
62+
A simulation is prepared in the repository. You can use the prepared TCL script to run simulation in ModelSim.
3063
```
31-
CLK_FREQ : integer := 50e6; -- system clock frequency in Hz
32-
BAUD_RATE : integer := 115200; -- baud rate value
33-
PARITY_BIT : string := "none"; -- type of parity: "none", "even", "odd", "mark", "space"
34-
USE_DEBOUNCER : boolean := True -- enable/disable debouncer
64+
vsim -do sim/sim.tcl
3565
```
3666

37-
## Table of resource usage summary:
67+
## Examples:
3868

39-
Use debouncer | Parity type | LE (LUT+FF) | LUT | FF | M9k | Fmax
40-
:---:|:---:|:---:|:---:|:---:|:---:|:---:
41-
True | none | 76 | 62 | 56 | 0 | 304.8 MHz
42-
True | even/odd | 86 | 73 | 59 | 0 | 277.3 MHz
43-
True | mark/space | 80 | 66 | 59 | 0 | 292.3 MHz
44-
False | none | 73 | 60 | 52 | 0 | 308.7 MHz
45-
False | even/odd | 79 | 71 | 55 | 0 | 278.7 MHz
46-
False | mark/space | 77 | 64 | 55 | 0 | 338.0 MHz
69+
The repository also includes several UART example designs. I use it on my [FPGA board CYC1000](https://shop.trenz-electronic.de/en/TEI0003-02-CYC1000-with-Cyclone-10-FPGA-8-MByte-SDRAM) with Intel Cyclone 10 FPGA (10CL025YU256C8G) and FTDI USB to UART Bridge. Here you can find [the documentation of the CYC1000 board](https://www.trenz-electronic.de/fileadmin/docs/Trenz_Electronic/Modules_and_Module_Carriers/2.5x6.15/TEI0003/REV02/Documents/CYC1000%20User%20Guide.pdf).
4770

48-
*Implementation was performed using Quartus Prime Lite Edition 18.1.0 for Intel Cyclone 10 FPGA (10CL025YU256C8G). Setting of some generics: BAUD_RATE = 115200, CLK_FREQ = 50e6.*
71+
### UART loopback:
4972

50-
## Simulation:
73+
The UART loopback example design is for testing data transfer between FPGA and PC. Data that you send from the PC to the FPGA via UART will be automatically sent back to the PC.
5174

52-
A basic simulation is prepared in the repository. You can use the prepared TCL script to run simulation in ModelSim.
75+
![Block diagram of UART loopback example design](docs/uart_loopback.svg)
5376

77+
### UART2WB bridge:
78+
79+
The UART2WB bridge example design is for testing access to Wishbone registers via the UART bridge. The example uses a simple script written in Python that allows you to read or write to 32-bit user registers connected to the [Wishbone bus](http://cdn.opencores.org/downloads/wbspec_b4.pdf).
80+
81+
![Block diagram of UART2WB bridge example design](docs/uart2wb.svg)
82+
83+
After connecting the CYC1000 board to the PC, upload an example design to the FPGA and run the script ([Python 3](https://www.python.org) and [PySerial](https://pyserial.readthedocs.io/en/latest/shortintro.html) is required):
5484
```
55-
vsim -do sim/sim.tcl
85+
python examples/uart2wb/sw/wishbone.py
5686
```
5787

58-
## UART loopback example:
88+
The expected output is:
89+
```
90+
Test of access to CSR (control status registers) via UART2WBM module...
91+
=======================================================================
92+
The UART on COM1 is open.
93+
The wishbone bus is ready.
94+
95+
READ from 0x0:
96+
0x20210406
97+
98+
READ from 0x4:
99+
0xABCDEF12
100+
101+
WRITE 0x12345678 to 0x4.
102+
103+
READ from 0x4:
104+
0x12345678
59105
60-
The UART loopback example design is for testing data transfer between FPGA and PC. I use it on my FPGA board [CYC1000](https://shop.trenz-electronic.de/en/TEI0003-02-CYC1000-with-Cyclone-10-FPGA-8-MByte-SDRAM) with Intel Cyclone 10 FPGA (10CL025YU256C8G) and FTDI USB to UART Bridge.
106+
WRITE 0xABCDEF12 to 0x4.
107+
108+
READ from 0x4:
109+
0xABCDEF12
110+
111+
READ from 0x8844:
112+
0xDEADCAFE
113+
114+
The UART is closed.
115+
```
61116

62117
## License:
63118

64-
This UART controller is available under the MIT license (MIT). Please read [LICENSE file](LICENSE).
119+
This UART controller is available under the MIT license. Please read [LICENSE file](LICENSE).

docs/uart2wb.svg

+3
Loading

0 commit comments

Comments
 (0)