|
|
@@ -34,6 +34,19 @@ architecture beh of async_8n1_tx_tb is
|
|
|
);
|
|
|
end component;
|
|
|
|
|
|
+ component async_8n1_tx_v2 is
|
|
|
+ port
|
|
|
+ (
|
|
|
+ clk : in std_logic;
|
|
|
+ rst : in std_logic;
|
|
|
+ en : in std_logic;
|
|
|
+ wr : in std_logic;
|
|
|
+ data_in : in unsigned (7 downto 0);
|
|
|
+ rdy : out std_logic;
|
|
|
+ data_out : out std_logic
|
|
|
+ );
|
|
|
+ end component;
|
|
|
+
|
|
|
constant freq : integer := 50; -- MHz
|
|
|
constant period : time := 1000 / freq * 1 ns;
|
|
|
constant half_period : time := period / 2;
|
|
|
@@ -45,13 +58,18 @@ architecture beh of async_8n1_tx_tb is
|
|
|
|
|
|
signal prescaled_clk_en : std_logic;
|
|
|
|
|
|
- constant prescaler_value : integer := 10;
|
|
|
+ constant prescaler_value : integer := 5;
|
|
|
constant prescaler_num_bits : integer := integer(ceil(log2(real(prescaler_value))));
|
|
|
|
|
|
signal running : boolean := true;
|
|
|
|
|
|
- signal tx : std_logic;
|
|
|
- signal rdy : std_logic;
|
|
|
+ signal tx1 : std_logic;
|
|
|
+ signal rdy1 : std_logic;
|
|
|
+
|
|
|
+ signal tx2 : std_logic;
|
|
|
+ signal rdy2 : std_logic;
|
|
|
+
|
|
|
+
|
|
|
signal wr : std_logic;
|
|
|
signal tx_char : unsigned (7 downto 0);
|
|
|
|
|
|
@@ -71,7 +89,11 @@ begin
|
|
|
'1' after 11 * period;
|
|
|
|
|
|
--tx_char <= to_unsigned(character'pos('a'), 8);
|
|
|
- tx_char <= x"aa";
|
|
|
+ tx_char <= x"aa",
|
|
|
+ x"55" after 50 * period,
|
|
|
+ x"00" after 100 * period,
|
|
|
+ x"ff" after 150 * period,
|
|
|
+ x"aa" after 200 * period;
|
|
|
|
|
|
i_prescaler : generic_prescaler
|
|
|
generic map(
|
|
|
@@ -86,15 +108,26 @@ begin
|
|
|
en_out => prescaled_clk_en
|
|
|
);
|
|
|
|
|
|
- DUT : async_8n1_tx
|
|
|
+ DUT1 : async_8n1_tx
|
|
|
+ port map(
|
|
|
+ clk => clock,
|
|
|
+ rst => reset,
|
|
|
+ en => '1', --prescaled_clk_en,
|
|
|
+ wr => wr,
|
|
|
+ data_in => tx_char,
|
|
|
+ rdy => rdy1,
|
|
|
+ data_out => tx1
|
|
|
+ );
|
|
|
+
|
|
|
+ DUT2 : async_8n1_tx_v2
|
|
|
port map(
|
|
|
clk => clock,
|
|
|
rst => reset,
|
|
|
- en => prescaled_clk_en,
|
|
|
+ en => '1', --prescaled_clk_en,
|
|
|
wr => wr,
|
|
|
data_in => tx_char,
|
|
|
- rdy => rdy,
|
|
|
- data_out => tx
|
|
|
+ rdy => rdy2,
|
|
|
+ data_out => tx2
|
|
|
);
|
|
|
-- clock process
|
|
|
process is
|
|
|
@@ -129,6 +162,9 @@ begin
|
|
|
if rising_edge(clock)
|
|
|
and num_rising_edges > 1 then
|
|
|
assert not (num_rising_edges mod prescaler_value = 0 and prescaled_clk_en /= '1') report "Prescaler not working!" severity error;
|
|
|
+
|
|
|
+ assert tx1 = tx2 report "Transciever tx disagreement" severity error;
|
|
|
+ assert rdy1 = rdy2 report "Transciever rdy disagreement" severity error;
|
|
|
end if;
|
|
|
end process;
|
|
|
end architecture;
|