w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
serport_master_tb.vhd
Go to the documentation of this file.
1-- $Id: serport_master_tb.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2015-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: serport_master_tb - sim
7-- Description: serial port: serial port module, master side (SIM only!)
8--
9-- Dependencies: serport_uart_rxtx_ab_tb
10-- serport_xonrx_tb
11-- serport_xontx_tb
12-- Test bench: -
13-- Target Devices: generic
14-- Tool versions: ghdl 0.31-0.34
15--
16-- Revision History:
17-- Date Rev Version Comment
18-- 2018-12-16 1087 1.1 add 100 ps RXSD,TXSD delay to allow clock jitter
19-- 2016-01-03 724 1.0 Initial version (copied from serport_master)
20
21------------------------------------------------------------------------------
22
23library ieee;
24use ieee.std_logic_1164.all;
25use ieee.numeric_std.all;
26
27use work.slvtypes.all;
28
29entity serport_master_tb is -- serial port module, 1 clock domain
30 generic (
31 CDWIDTH : positive := 13); -- clk divider width
32 port (
33 CLK : in slbit; -- clock
34 RESET : in slbit; -- reset
35 CLKDIV : in slv(CDWIDTH-1 downto 0); -- clock divider setting
36 ENAXON : in slbit := '0'; -- enable xon/xoff handling
37 ENAESC : in slbit := '0'; -- enable xon/xoff escaping
38 RXDATA : out slv8; -- receiver data out
39 RXVAL : out slbit; -- receiver data valid
40 RXERR : out slbit; -- receiver data error (frame error)
41 RXOK : in slbit := '1'; -- rx channel ok
42 TXDATA : in slv8; -- transmit data in
43 TXENA : in slbit; -- transmit data enable
44 TXBUSY : out slbit; -- transmit busy
45 RXSD : in slbit; -- receive serial data (uart view)
46 TXSD : out slbit; -- transmit serial data (uart view)
47 RXRTS_N : out slbit; -- receive rts (uart view, act.low)
48 TXCTS_N : in slbit := '0' -- transmit cts (uart view, act.low)
49 );
51
52
53architecture sim of serport_master_tb is
54
55 signal UART_RXDATA : slv8 := (others=>'0');
56 signal UART_RXVAL : slbit := '0';
57 signal UART_TXDATA : slv8 := (others=>'0');
58 signal UART_TXENA : slbit := '0';
59 signal UART_TXBUSY : slbit := '0';
60
61 signal XONTX_TXENA : slbit := '0';
62 signal XONTX_TXBUSY : slbit := '0';
63
64 signal UART_RXSD : slbit := '0';
65 signal UART_TXSD : slbit := '0';
66
67 signal TXOK : slbit := '0';
68
69begin
70
71 UART : entity work.serport_uart_rxtx_tb -- uart, rx+tx combo
72 generic map (
74 port map (
75 CLK => CLK,
76 RESET => RESET,
77 CLKDIV => CLKDIV,
78 RXSD => UART_RXSD,
81 RXERR => RXERR,
82 RXACT => open,
83 TXSD => UART_TXSD,
87 );
88
89 -- add some minor (100 ps) delay in the serial data path.
90 -- this makes transmission immune against small clock jitter between test
91 -- bench and UUT (e.g. from sfs re-phasing done differently in tb and UUT).
92
93 TXSD <= UART_TXSD after 100 ps;
94 UART_RXSD <= RXSD after 100 ps;
95
96 XONRX : entity work.serport_xonrx_tb -- xon/xoff logic rx path
97 port map (
98 CLK => CLK,
99 RESET => RESET,
100 ENAXON => ENAXON,
101 ENAESC => ENAESC,
104 RXDATA => RXDATA,
105 RXVAL => RXVAL,
106 RXHOLD => '0',
107 RXOVR => open,
108 TXOK => TXOK
109 );
110
111 XONTX : entity work.serport_xontx_tb -- xon/xoff logic tx path
112 port map (
113 CLK => CLK,
114 RESET => RESET,
115 ENAXON => ENAXON,
116 ENAESC => ENAESC,
120 TXDATA => TXDATA,
121 TXENA => TXENA,
122 TXBUSY => TXBUSY,
123 RXOK => RXOK,
124 TXOK => TXOK
125 );
126
127 RXRTS_N <= not RXOK;
128
129 proc_cts: process (TXCTS_N, XONTX_TXENA, UART_TXBUSY)
130 begin
131 if TXCTS_N = '0' then -- transmit cts asserted
134 else -- transmit cts not asserted
135 UART_TXENA <= '0';
136 XONTX_TXBUSY <= '1';
137 end if;
138 end process proc_cts;
139
140end sim;
slv8 :=( others => '0') UART_TXDATA
slv8 :=( others => '0') UART_RXDATA
CDWIDTH positive := 13
in ENAESC slbit := '0'
in ENAXON slbit := '0'
in CLKDIV slv( CDWIDTH- 1 downto 0)
in RXOK slbit := '1'
in TXCTS_N slbit := '0'
in CLKDIV slv( CDWIDTH- 1 downto 0)
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector slv
Definition: slvtypes.vhd:31