Skip to content

Commit 5db1331

Browse files
committed
[FEATURE]: Add Parity Error output port
1 parent 71d3600 commit 5db1331

File tree

4 files changed

+55
-49
lines changed

4 files changed

+55
-49
lines changed

examples/loopback/uart_loopback_cyc1000.vhd

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,20 @@ begin
5757
USE_DEBOUNCER => USE_DEBOUNCER
5858
)
5959
port map (
60-
CLK => CLK_12M,
61-
RST => reset,
60+
CLK => CLK_12M,
61+
RST => reset,
6262
-- UART INTERFACE
63-
UART_TXD => UART_TXD,
64-
UART_RXD => UART_RXD,
65-
-- USER DATA OUTPUT INTERFACE
66-
DOUT => data,
67-
DOUT_VLD => valid,
68-
FRAME_ERROR => open,
63+
UART_TXD => UART_TXD,
64+
UART_RXD => UART_RXD,
6965
-- USER DATA INPUT INTERFACE
70-
DIN => data,
71-
DIN_VLD => valid,
72-
DIN_RDY => open
66+
DIN => data,
67+
DIN_VLD => valid,
68+
DIN_RDY => open,
69+
-- USER DATA OUTPUT INTERFACE
70+
DOUT => data,
71+
DOUT_VLD => valid,
72+
FRAME_ERROR => open,
73+
PARITY_ERROR => open
7374
);
7475

7576
end architecture;

examples/uart2wb/uart2wbm.vhd

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,20 @@ begin
260260
USE_DEBOUNCER => True
261261
)
262262
port map (
263-
CLK => CLK,
264-
RST => RST,
263+
CLK => CLK,
264+
RST => RST,
265265
-- UART INTERFACE
266-
UART_TXD => UART_TXD,
267-
UART_RXD => UART_RXD,
268-
-- USER DATA OUTPUT INTERFACE
269-
DOUT => uart_dout,
270-
DOUT_VLD => uart_dout_vld,
271-
FRAME_ERROR => open,
266+
UART_TXD => UART_TXD,
267+
UART_RXD => UART_RXD,
272268
-- USER DATA INPUT INTERFACE
273-
DIN => uart_din,
274-
DIN_VLD => uart_din_vld,
275-
DIN_RDY => uart_din_rdy
269+
DIN => uart_din,
270+
DIN_VLD => uart_din_vld,
271+
DIN_RDY => uart_din_rdy,
272+
-- USER DATA OUTPUT INTERFACE
273+
DOUT => uart_dout,
274+
DOUT_VLD => uart_dout_vld,
275+
FRAME_ERROR => open,
276+
PARITY_ERROR => open
276277
);
277278

278279
end architecture;

rtl/uart.vhd

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use IEEE.MATH_REAL.ALL;
3535
-- Added better simulation with automatic checking of transactions.
3636
-- Little code cleaning and code optimization.
3737
-- Added UART2WB bridge example (access to WB registers via UART).
38+
-- Added Parity Error output.
3839

3940
entity UART is
4041
Generic (
@@ -45,19 +46,20 @@ entity UART is
4546
);
4647
Port (
4748
-- CLOCK AND RESET
48-
CLK : in std_logic; -- system clock
49-
RST : in std_logic; -- high active synchronous reset
49+
CLK : in std_logic; -- system clock
50+
RST : in std_logic; -- high active synchronous reset
5051
-- UART INTERFACE
51-
UART_TXD : out std_logic; -- serial transmit data
52-
UART_RXD : in std_logic; -- serial receive data
52+
UART_TXD : out std_logic; -- serial transmit data
53+
UART_RXD : in std_logic; -- serial receive data
5354
-- USER DATA INPUT INTERFACE
54-
DIN : in std_logic_vector(7 downto 0); -- input data to be transmitted over UART
55-
DIN_VLD : in std_logic; -- when DIN_VLD = 1, input data (DIN) are valid
56-
DIN_RDY : out std_logic; -- when DIN_RDY = 1, transmitter is ready and valid input data will be accepted for transmiting
55+
DIN : in std_logic_vector(7 downto 0); -- input data to be transmitted over UART
56+
DIN_VLD : in std_logic; -- when DIN_VLD = 1, input data (DIN) are valid
57+
DIN_RDY : out std_logic; -- when DIN_RDY = 1, transmitter is ready and valid input data will be accepted for transmiting
5758
-- USER DATA OUTPUT INTERFACE
58-
DOUT : out std_logic_vector(7 downto 0); -- output data received via UART
59-
DOUT_VLD : out std_logic; -- when DOUT_VLD = 1, output data (DOUT) are valid (is assert only for one clock cycle)
60-
FRAME_ERROR : out std_logic -- when FRAME_ERROR = 1, stop bit was invalid (is assert only for one clock cycle)
59+
DOUT : out std_logic_vector(7 downto 0); -- output data received via UART
60+
DOUT_VLD : out std_logic; -- when DOUT_VLD = 1, output data (DOUT) are valid (is assert only for one clock cycle)
61+
FRAME_ERROR : out std_logic; -- when FRAME_ERROR = 1, stop bit was invalid (is assert only for one clock cycle)
62+
PARITY_ERROR : out std_logic -- when PARITY_ERROR = 1, parity bit was invalid (is assert only for one clock cycle)
6163
);
6264
end entity;
6365

@@ -144,7 +146,7 @@ begin
144146
DOUT => DOUT,
145147
DOUT_VLD => DOUT_VLD,
146148
FRAME_ERROR => FRAME_ERROR,
147-
PARITY_ERROR => open
149+
PARITY_ERROR => PARITY_ERROR
148150
);
149151

150152
-- -------------------------------------------------------------------------

sim/uart_tb.vhd

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ architecture SIM of UART_TB is
4040
signal monitor_txd_start_bit : std_logic := '0';
4141
signal monitor_txd_stop_bit : std_logic := '0';
4242

43-
signal frame_error : std_logic;
43+
signal frame_error : std_logic;
44+
signal parity_error : std_logic;
45+
4446
signal rand_int : integer := 0;
4547

4648
constant CLK_FREQ : natural := 50e6;
@@ -98,7 +100,7 @@ architecture SIM of UART_TB is
98100
-- move to middle of stop bit
99101
wait for UART_PER/2;
100102
if (UART_RXD = '0') then
101-
report "Invalid stop bit in UART_MONITOR!" severity failure;
103+
report "======== INVALID STOP BIT IN UART_MONITOR! ========" severity failure;
102104
end if;
103105
UART_STOP_BIT <= '0';
104106
-- in middle of stop bit move to resync (wait for start bit)
@@ -116,27 +118,27 @@ begin
116118
wait for CLK_PERIOD;
117119
end process;
118120

119-
120121
utt : entity work.UART
121122
generic map (
122123
CLK_FREQ => CLK_FREQ,
123124
BAUD_RATE => BAUD_RATE,
124125
PARITY_BIT => "none" -- parity bit is not supported in this simulation
125126
)
126127
port map (
127-
CLK => CLK,
128-
RST => RST,
128+
CLK => CLK,
129+
RST => RST,
129130
-- UART INTERFACE
130-
UART_TXD => monitor_txd,
131-
UART_RXD => driver_rxd,
131+
UART_TXD => monitor_txd,
132+
UART_RXD => driver_rxd,
132133
-- USER DATA INPUT INTERFACE
133-
DIN => driver_din,
134-
DIN_VLD => driver_din_vld,
135-
DIN_RDY => driver_din_rdy,
134+
DIN => driver_din,
135+
DIN_VLD => driver_din_vld,
136+
DIN_RDY => driver_din_rdy,
136137
-- USER DATA OUTPUT INTERFACE
137-
DOUT => monitor_dout,
138-
DOUT_VLD => monitor_dout_vld,
139-
FRAME_ERROR => frame_error
138+
DOUT => monitor_dout,
139+
DOUT_VLD => monitor_dout_vld,
140+
FRAME_ERROR => frame_error,
141+
PARITY_ERROR => parity_error
140142
);
141143

142144
clk_gen_p : process
@@ -181,7 +183,7 @@ begin
181183
if (monitor_dout = monitor_dout_expected) then
182184
--report "Transaction on DOUT port is OK." severity note;
183185
else
184-
report "Unexpected transaction on DOUT port!" severity failure;
186+
report "======== UNEXPECTED TRANSACTION ON DOUT PORT! ========" severity failure;
185187
end if;
186188
wait for CLK_PERIOD;
187189
end loop;
@@ -221,7 +223,7 @@ begin
221223
if (monitor_txd_dout = monitor_txd_dout_expected) then
222224
--report "Transaction on UART_TXD port is OK." severity note;
223225
else
224-
report "Unexpected transaction on UART_TXD port!" severity failure;
226+
report "======== UNEXPECTED TRANSACTION ON UART_TXD PORT! ========" severity failure;
225227
end if;
226228
end loop;
227229
monitor_txd_done <= '1';
@@ -238,7 +240,7 @@ begin
238240
v_test_done := driver_rxd_done and monitor_dout_done and driver_din_done and monitor_txd_done;
239241
if (v_test_done = '1') then
240242
wait for 100*CLK_PERIOD;
241-
report "Simulation successfully completed." severity failure;
243+
report "======== SIMULATION SUCCESSFULLY COMPLETED! ========" severity failure;
242244
end if;
243245
wait for CLK_PERIOD;
244246
end process;

0 commit comments

Comments
 (0)