| 1 |
6 |
smuller |
-----------------------------------------------------------------------------------------
|
| 2 |
|
|
-- uart to internal bus top module
|
| 3 |
|
|
--
|
| 4 |
|
|
-----------------------------------------------------------------------------------------
|
| 5 |
|
|
library IEEE;
|
| 6 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 7 |
|
|
|
| 8 |
|
|
entity uart2BusTop is
|
| 9 |
|
|
generic ( AW : integer := 8);
|
| 10 |
|
|
port ( -- global signals
|
| 11 |
|
|
clr : in STD_LOGIC; -- global reset input
|
| 12 |
|
|
clk : in STD_LOGIC; -- global clock input
|
| 13 |
|
|
-- uart serial signals
|
| 14 |
|
|
serIn : in STD_LOGIC; -- serial data input
|
| 15 |
|
|
serOut : out STD_LOGIC; -- serial data output
|
| 16 |
|
|
-- internal bus to register file
|
| 17 |
|
|
intRdData : in STD_LOGIC_VECTOR (7 downto 0); -- data read from register file
|
| 18 |
|
|
intAddress : out STD_LOGIC_VECTOR (AW - 1 downto 0); -- address bus to register file
|
| 19 |
|
|
intWrData : out STD_LOGIC_VECTOR (7 downto 0); -- write data to register file
|
| 20 |
|
|
intWrite : out STD_LOGIC; -- write control to register file
|
| 21 |
|
|
intRead : out STD_LOGIC); -- read control to register file
|
| 22 |
|
|
end uart2BusTop;
|
| 23 |
|
|
|
| 24 |
|
|
architecture Behavioral of uart2BusTop is
|
| 25 |
|
|
|
| 26 |
|
|
component uartTop
|
| 27 |
|
|
port ( clr : in std_logic;
|
| 28 |
|
|
clk : in std_logic;
|
| 29 |
|
|
serIn : in std_logic;
|
| 30 |
|
|
txData : in std_logic_vector(7 downto 0);
|
| 31 |
|
|
newTxData : in std_logic;
|
| 32 |
|
|
baudFreq : in std_logic_vector(11 downto 0);
|
| 33 |
|
|
baudLimit : in std_logic_vector(15 downto 0);
|
| 34 |
|
|
serOut : out std_logic;
|
| 35 |
|
|
txBusy : out std_logic;
|
| 36 |
|
|
rxData : out std_logic_vector(7 downto 0);
|
| 37 |
|
|
newRxData : out std_logic;
|
| 38 |
|
|
baudClk : out std_logic);
|
| 39 |
|
|
end component;
|
| 40 |
|
|
|
| 41 |
|
|
component uartParser
|
| 42 |
|
|
generic ( AW : integer := 8);
|
| 43 |
|
|
port ( clr : in std_logic;
|
| 44 |
|
|
clk : in std_logic;
|
| 45 |
|
|
txBusy : in std_logic;
|
| 46 |
|
|
rxData : in std_logic_vector(7 downto 0);
|
| 47 |
|
|
newRxData : in std_logic;
|
| 48 |
|
|
intRdData : in std_logic_vector(7 downto 0);
|
| 49 |
|
|
txData : out std_logic_vector(7 downto 0);
|
| 50 |
|
|
newTxData : out std_logic;
|
| 51 |
|
|
intAddress : out std_logic_vector(AW - 1 downto 0);
|
| 52 |
|
|
intWrData : out std_logic_vector(7 downto 0);
|
| 53 |
|
|
intWrite : out std_logic;
|
| 54 |
|
|
intRead : out std_logic);
|
| 55 |
|
|
end component;
|
| 56 |
|
|
|
| 57 |
|
|
-- baud rate configuration, see baudGen.vhd for more details.
|
| 58 |
|
|
-- baud rate generator parameters for 115200 baud on 25MHz clock
|
| 59 |
|
|
constant baudFreq : std_logic_vector(11 downto 0) := x"480";
|
| 60 |
|
|
constant baudLimit : std_logic_vector(15 downto 0) := x"3889";
|
| 61 |
|
|
signal txData : std_logic_vector(7 downto 0); -- data byte to transmit
|
| 62 |
|
|
signal newTxData : std_logic; -- asserted to indicate that there is a new data byte for transmission
|
| 63 |
|
|
signal txBusy : std_logic; -- signs that transmitter is busy
|
| 64 |
|
|
signal rxData : std_logic_vector(7 downto 0); -- data byte received
|
| 65 |
|
|
signal newRxData : std_logic; -- signs that a new byte was received
|
| 66 |
|
|
|
| 67 |
|
|
begin
|
| 68 |
|
|
-- uart top module instance
|
| 69 |
|
|
ut : uartTop
|
| 70 |
|
|
port map (
|
| 71 |
|
|
clr => clr,
|
| 72 |
|
|
clk => clk,
|
| 73 |
|
|
serIn => serIn,
|
| 74 |
|
|
txData => txData,
|
| 75 |
|
|
newTxData => newTxData,
|
| 76 |
|
|
baudFreq => baudFreq,
|
| 77 |
|
|
baudLimit => baudLimit,
|
| 78 |
|
|
serOut => serOut,
|
| 79 |
|
|
txBusy => txBusy,
|
| 80 |
|
|
rxData => rxData,
|
| 81 |
|
|
newRxData => newRxData,
|
| 82 |
|
|
baudClk => open);
|
| 83 |
|
|
-- uart parser instance
|
| 84 |
|
|
up : uartParser
|
| 85 |
|
|
generic map (
|
| 86 |
|
|
AW => AW)
|
| 87 |
|
|
port map (
|
| 88 |
|
|
clr => clr,
|
| 89 |
|
|
clk => clk,
|
| 90 |
|
|
txBusy => txBusy,
|
| 91 |
|
|
rxData => rxData,
|
| 92 |
|
|
newRxData => newRxData,
|
| 93 |
|
|
intRdData => intRdData,
|
| 94 |
|
|
txData => txData,
|
| 95 |
|
|
newTxData => newTxData,
|
| 96 |
|
|
intAddress => intAddress,
|
| 97 |
|
|
intWrData => intWrData,
|
| 98 |
|
|
intWrite => intWrite,
|
| 99 |
|
|
intRead => intRead);
|
| 100 |
|
|
end Behavioral;
|