----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 10:29:42 03/20/2018
-- Design Name:
-- Module Name: uartTop - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
--library work;
--use work.uart2BusTop_pkg.all;
entity uartTop is
port ( -- global signals
clr : in std_logic; -- global reset input
clk : in std_logic; -- global clock input
serOut : out std_logic; -- serial data output
newTxData : in std_logic; -- asserted to indicate that there is a new data byte for transmission
txBusy : out std_logic; -- signs that transmitter is busy
baudClk : out std_logic); --
end uartTop;
architecture Behavioral of uartTop is
signal ce16 : std_logic; -- clock enable at bit rate
signal Data: std_logic_vector(7 downto 0);
signal Data1: std_logic_vector(31 downto 0);
signal i: integer range 0 to 3:= 0;
signal slow_clock : std_logic;
component baudGen
port (
clr : in std_logic;
clk : in std_logic;
slow_clock : out std_logic;
ce16 : out std_logic);
end component;
component uartTx
port (
clr : in std_logic;
clk : in std_logic;
ce16 : in std_logic;
txData : in std_logic_vector(7 downto 0);
newTxData : in std_logic;
serOut : out std_logic;
txBusy : out std_logic);
end component;
begin
-- baud rate generator module
bg : baudGen
port map (
clr => clr,
clk => clk,
slow_clock => slow_clock,
ce16 => ce16);
-- uart receiver
ut : uartTx
port map (
clr => clr,
clk => clk,
ce16 => ce16,
txData => Data,
newTxData => newTxData,
serOut => serOut,
txBusy => txBusy);
baudClk <= ce16;
process (slow_clock)
variable i : integer range 0 to 3 := 0;
begin
if (rising_edge(slow_clock)) then
if i = 0 then
Data<= Data1(31 downto 24);
i := 1;
elsif i = 1 then
Data<= Data1(15 downto 8);
i := 2;
elsif i = 2 then
Data<= Data1(23 downto 16);
i := 3;
elsif i = 3 then
Data<= Data1(7 downto 0);
i := 0;
end if;
end if;
end process;
Data1<= "00110000001100010011001000110011"; --00110000 = 0,00110001= 1,00110010= 2,00110011= 3
end Behavioral;