- fixed RX incorrect behavior with BAUD_DIV > 1
- added baud rate generator to TB
- added TB with TX and RX

git-svn-id: http://moon:8086/svn/vhdl/trunk@1343 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2016-12-18 10:13:12 +00:00
parent f7af661eda
commit 262d045890
10 changed files with 243 additions and 16 deletions
+25 -6
View File
@@ -32,6 +32,7 @@ architecture behave of tb_juart_rx is
-- Number of user data words for simulation
constant CLK_PERIOD : time := 10 ns;
constant BAUD_DIV : natural := 2;
signal rst : std_logic := '1';
signal clk : std_logic := '1';
@@ -41,6 +42,8 @@ architecture behave of tb_juart_rx is
signal data_out : unsigned(7 downto 0);
signal serial_word : unsigned(7 downto 0) := X"AA";
signal baud_count : unsigned(15 downto 0);
signal baud_reg : unsigned(15 downto 0) := to_unsigned(BAUD_DIV-1, baud_count'length);
signal data_reg : unsigned(7 downto 0);
begin
@@ -68,6 +71,22 @@ PROC_DATAREG: process
data_reg <= data_out;
end process;
baud_timer:
process(clk)
begin
if rising_edge(clk) then
en_16_x_baud <= '0';
if rst = '1' then
baud_count <= (others => '0');
elsif baud_count = baud_reg then
baud_count <= (others => '0');
en_16_x_baud <= '1';
else
baud_count <= baud_count + 1;
end if;
end if;
end process;
------------------------------------------------------------------------------------------
STIMULUS: process
@@ -79,22 +98,22 @@ STIMULUS: process
rst <= '0';
serial_word <= X"AA";
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
serial_in <= '0';
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
for i in serial_word'length-1 downto 0 loop
serial_in <= serial_word(i);
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
end loop;
serial_in <= '1';
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
serial_word <= X"55";
serial_in <= '0';
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
for i in serial_word'length-1 downto 0 loop
serial_in <= serial_word(i);
wait for 16*CLK_PERIOD;
wait for 16*baud_div*CLK_PERIOD;
end loop;
serial_in <= '1';
wait;