Skip to content

Commit e556cb6

Browse files
authored
Merge pull request #2 from jakubcabal/dev
Merge version 1.2 of UART module to master.
2 parents 7235180 + 0cf9c37 commit e556cb6

11 files changed

+336
-345
lines changed

README.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ USE_DEBOUNCER : boolean := True -- enable/disable debouncer
3636

3737
## Table of resource usage summary:
3838

39-
Use debouncer | Parity type | LE (LUT+FF) | LUT | FF | BRAM | Fmax
39+
Use debouncer | Parity type | LE (LUT+FF) | LUT | FF | M9k | Fmax
4040
:---:|:---:|:---:|:---:|:---:|:---:|:---:
41-
True | none | 74 | 59 | 53 | 0 | 220.0 MHz
42-
True | even/odd | 81 | 70 | 56 | 0 | 193.3 MHz
43-
True | mark/space | 78 | 63 | 56 | 0 | 210.2 MHz
44-
False | none | 70 | 57 | 49 | 0 | 182.3 MHz
45-
False | even/odd | 78 | 68 | 52 | 0 | 183.5 MHz
46-
False | mark/space | 74 | 61 | 52 | 0 | 186.2 MHz
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
4747

48-
*Implementation was performed using Quartus Prime Lite Edition 17.0.0 for FPGA Altera Cyclone IV E EP4CE6E22C8. Setting of some generics: BAUD_RATE = 115200, CLK_FREQ = 50e6.*
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.*
4949

5050
## Simulation:
5151

@@ -57,8 +57,7 @@ vsim -do sim/sim.tcl
5757

5858
## UART loopback example:
5959

60-
The UART loopback example design is for testing data transfer between FPGA and PC.
61-
I use it on my cheap FPGA board ([EP4CE6 Starter Board](http://www.ebay.com/itm/111975895262) with Altera FPGA Cyclone IV EP4CE6E22C8) together with external USB to UART Bridge.
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.
6261

6362
## License:
6463

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#-------------------------------------------------------------------------------
22
# PROJECT: SIMPLE UART FOR FPGA
33
#-------------------------------------------------------------------------------
4-
# NAME: QUARTUS PROJECT FILE
54
# AUTHORS: Jakub Cabal <[email protected]>
65
# LICENSE: The MIT License (MIT), please read LICENSE file
76
# WEBSITE: https://github.com/jakubcabal/uart-for-fpga
87
#-------------------------------------------------------------------------------
98

10-
PROJECT_REVISION = "uart_loopback"
9+
PROJECT_REVISION = "UART_LOOPBACK_CYC1000"
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
#-------------------------------------------------------------------------------
22
# PROJECT: SIMPLE UART FOR FPGA
33
#-------------------------------------------------------------------------------
4-
# NAME: QUARTUS SETTINGS FILE FOR EP4CE6 STARTER BOARD
54
# AUTHORS: Jakub Cabal <[email protected]>
65
# LICENSE: The MIT License (MIT), please read LICENSE file
76
# WEBSITE: https://github.com/jakubcabal/uart-for-fpga
87
#-------------------------------------------------------------------------------
98

10-
set_global_assignment -name FAMILY "Cyclone IV E"
11-
set_global_assignment -name DEVICE EP4CE6E22C8
12-
set_global_assignment -name TOP_LEVEL_ENTITY UART_LOOPBACK
9+
# QUARTUS SETTINGS FILE FOR CYC1000 BOARD
10+
set_global_assignment -name FAMILY "Cyclone 10 LP"
11+
set_global_assignment -name DEVICE 10CL025YU256C8G
12+
set_global_assignment -name TOP_LEVEL_ENTITY UART_LOOPBACK_CYC1000
1313

1414
# PROJECT VHDL FILES
15-
set_global_assignment -name VHDL_FILE ../uart_loopback.vhd
16-
set_global_assignment -name VHDL_FILE ../../rtl/uart.vhd
17-
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_tx.vhd
18-
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_rx.vhd
15+
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_clk_div.vhd
1916
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_parity.vhd
2017
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_debouncer.vhd
18+
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_tx.vhd
19+
set_global_assignment -name VHDL_FILE ../../rtl/comp/uart_rx.vhd
20+
set_global_assignment -name VHDL_FILE ../../rtl/uart.vhd
21+
set_global_assignment -name VHDL_FILE ../rst_sync.vhd
22+
set_global_assignment -name VHDL_FILE ../uart_loopback_cyc1000.vhd
2123

2224
# TIMING CONSTRAINTS
23-
set_global_assignment -name SDC_FILE ../timing_constraints.sdc
25+
set_global_assignment -name SDC_FILE ./uart_loopback_cyc1000.sdc
2426

25-
# FPGA PINS ASSIGNMENT FOR EP4CE6 STARTER BOARD
26-
set_location_assignment PIN_91 -to CLK
27-
set_location_assignment PIN_25 -to RST
28-
set_location_assignment PIN_85 -to UART_TXD
29-
set_location_assignment PIN_86 -to UART_RXD
27+
# FPGA PINS ASSIGNMENT
28+
set_location_assignment PIN_M2 -to CLK_12M
29+
set_location_assignment PIN_N6 -to RST_BTN_N
30+
set_location_assignment PIN_T7 -to UART_TXD
31+
set_location_assignment PIN_R7 -to UART_RXD
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#-------------------------------------------------------------------------------
22
# PROJECT: SIMPLE UART FOR FPGA
33
#-------------------------------------------------------------------------------
4-
# MODULE: TIMING CONSTRAINTS
54
# AUTHORS: Jakub Cabal <[email protected]>
65
# LICENSE: The MIT License (MIT), please read LICENSE file
76
# WEBSITE: https://github.com/jakubcabal/uart-for-fpga
87
#-------------------------------------------------------------------------------
98

10-
create_clock -name CLK50 -period 20.000 [get_ports {CLK}]
9+
create_clock -name CLK12M -period 12MHz [get_ports {CLK_12M}]

example/rst_sync.vhd

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--------------------------------------------------------------------------------
2+
-- PROJECT: SIMPLE UART FOR FPGA
3+
--------------------------------------------------------------------------------
4+
-- AUTHORS: Jakub Cabal <[email protected]>
5+
-- LICENSE: The MIT License (MIT), please read LICENSE file
6+
-- WEBSITE: https://github.com/jakubcabal/uart-for-fpga
7+
--------------------------------------------------------------------------------
8+
9+
library IEEE;
10+
use IEEE.STD_LOGIC_1164.ALL;
11+
use IEEE.NUMERIC_STD.ALL;
12+
13+
entity RST_SYNC is
14+
Port (
15+
CLK : in std_logic;
16+
ASYNC_RST : in std_logic;
17+
SYNCED_RST : out std_logic
18+
);
19+
end entity;
20+
21+
architecture RTL of RST_SYNC is
22+
23+
attribute ALTERA_ATTRIBUTE : string;
24+
attribute PRESERVE : boolean;
25+
26+
signal meta_reg : std_logic;
27+
signal reset_reg : std_logic;
28+
29+
attribute ALTERA_ATTRIBUTE of RTL : architecture is "-name SDC_STATEMENT ""set_false_path -to [get_registers {*RST_SYNC:*|meta_reg}] """;
30+
attribute ALTERA_ATTRIBUTE of meta_reg : signal is "-name SYNCHRONIZER_IDENTIFICATION ""FORCED IF ASYNCHRONOUS""";
31+
attribute ALTERA_ATTRIBUTE of reset_reg : signal is "-name SYNCHRONIZER_IDENTIFICATION ""FORCED IF ASYNCHRONOUS""";
32+
attribute PRESERVE of meta_reg : signal is TRUE;
33+
attribute PRESERVE of reset_reg : signal is TRUE;
34+
35+
begin
36+
37+
process (CLK, ASYNC_RST)
38+
begin
39+
if (ASYNC_RST = '1') then
40+
meta_reg <= '1';
41+
reset_reg <= '1';
42+
elsif (rising_edge(CLK)) then
43+
meta_reg <= '0';
44+
reset_reg <= meta_reg;
45+
end if;
46+
end process;
47+
48+
SYNCED_RST <= reset_reg;
49+
50+
end architecture;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
--------------------------------------------------------------------------------
22
-- PROJECT: SIMPLE UART FOR FPGA
33
--------------------------------------------------------------------------------
4-
-- MODULE: UART LOOPBACK EXAMPLE TOP MODULE
54
-- AUTHORS: Jakub Cabal <[email protected]>
65
-- LICENSE: The MIT License (MIT), please read LICENSE file
76
-- WEBSITE: https://github.com/jakubcabal/uart-for-fpga
@@ -11,32 +10,45 @@ library IEEE;
1110
use IEEE.STD_LOGIC_1164.ALL;
1211
use IEEE.NUMERIC_STD.ALL;
1312

13+
-- UART LOOPBACK EXAMPLE TOP MODULE FOR CYC1000 BOARD
14+
-- ==================================================
1415
-- UART FOR FPGA REQUIRES: 1 START BIT, 8 DATA BITS, 1 STOP BIT!!!
1516
-- OTHER PARAMETERS CAN BE SET USING GENERICS.
1617

17-
entity UART_LOOPBACK is
18+
entity UART_LOOPBACK_CYC1000 is
1819
Generic (
19-
CLK_FREQ : integer := 50e6; -- set system clock frequency in Hz
20+
CLK_FREQ : integer := 12e6; -- set system clock frequency in Hz
2021
BAUD_RATE : integer := 115200; -- baud rate value
2122
PARITY_BIT : string := "none"; -- legal values: "none", "even", "odd", "mark", "space"
2223
USE_DEBOUNCER : boolean := True -- enable/disable debouncer
2324
);
2425
Port (
25-
CLK : in std_logic; -- system clock
26-
RST : in std_logic; -- high active synchronous reset
26+
CLK_12M : in std_logic; -- system clock 12 MHz
27+
RST_BTN_N : in std_logic; -- low active reset button
2728
-- UART INTERFACE
28-
UART_TXD : out std_logic;
29-
UART_RXD : in std_logic
29+
UART_TXD : out std_logic;
30+
UART_RXD : in std_logic
3031
);
31-
end UART_LOOPBACK;
32+
end entity;
3233

33-
architecture FULL of UART_LOOPBACK is
34+
architecture RTL of UART_LOOPBACK_CYC1000 is
3435

35-
signal data : std_logic_vector(7 downto 0);
36-
signal valid : std_logic;
36+
signal rst_btn : std_logic;
37+
signal reset : std_logic;
38+
signal data : std_logic_vector(7 downto 0);
39+
signal valid : std_logic;
3740

3841
begin
3942

43+
rst_btn <= not RST_BTN_N;
44+
45+
rst_sync_i : entity work.RST_SYNC
46+
port map (
47+
CLK => CLK_12M,
48+
ASYNC_RST => rst_btn,
49+
SYNCED_RST => reset
50+
);
51+
4052
uart_i: entity work.UART
4153
generic map (
4254
CLK_FREQ => CLK_FREQ,
@@ -45,8 +57,8 @@ begin
4557
USE_DEBOUNCER => USE_DEBOUNCER
4658
)
4759
port map (
48-
CLK => CLK,
49-
RST => RST,
60+
CLK => CLK_12M,
61+
RST => reset,
5062
-- UART INTERFACE
5163
UART_TXD => UART_TXD,
5264
UART_RXD => UART_RXD,
@@ -60,4 +72,4 @@ begin
6072
DIN_RDY => open
6173
);
6274

63-
end FULL;
75+
end architecture;

example/uart_loopback_tb.vhd

-115
This file was deleted.

0 commit comments

Comments
 (0)