OpenCores
URL https://opencores.org/ocsvn/am9080_cpu_based_on_microcoded_am29xx_bit-slices/am9080_cpu_based_on_microcoded_am29xx_bit-slices/trunk

Subversion Repositories am9080_cpu_based_on_microcoded_am29xx_bit-slices

[/] [am9080_cpu_based_on_microcoded_am29xx_bit-slices/] [trunk/] [acia.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    11:56:00 11/12/2017 
6
-- Design Name: 
7
-- Module Name:    ACIA - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: Simple wrapper around https://github.com/jakubcabal/uart-for-fpga
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity ACIA is
33
    Port ( clk: in std_logic;
34
                          reset: in std_logic;
35
                          D : inout  STD_LOGIC_VECTOR (7 downto 0);
36
           A : in  STD_LOGIC;
37
           nRead : in  STD_LOGIC;
38
           nWrite : in  STD_LOGIC;
39
           nSelect : in  STD_LOGIC;
40
                          IntReq: buffer std_logic;
41
                          IntAck: in STD_LOGIC;
42
                          txd: out std_logic;
43
                          rxd: in std_logic);
44
end ACIA;
45
 
46
architecture Behavioral of ACIA is
47
 
48
--
49
-- https://github.com/jakubcabal/uart-for-fpga
50
-- 
51
component UART is
52
    Generic (
53
        CLK_FREQ      : integer := 50e6;   -- system clock frequency in Hz
54
        BAUD_RATE     : integer := 115200; -- baud rate value
55
        PARITY_BIT    : string  := "none"; -- type of parity: "none", "even", "odd", "mark", "space"
56
        USE_DEBOUNCER : boolean := True    -- enable/disable debouncer
57
    );
58
    Port (
59
        CLK         : in  std_logic; -- system clock
60
        RST         : in  std_logic; -- high active synchronous reset
61
        -- UART INTERFACE
62
        UART_TXD    : out std_logic; -- serial transmit data
63
        UART_RXD    : in  std_logic; -- serial receive data
64
        -- USER DATA INPUT INTERFACE
65
        DATA_IN     : in  std_logic_vector(7 downto 0); -- input data
66
        DATA_SEND   : in  std_logic; -- when DATA_SEND = 1, input data are valid and will be transmit
67
        BUSY        : out std_logic; -- when BUSY = 1, transmitter is busy and you must not set DATA_SEND to 1
68
        -- USER DATA OUTPUT INTERFACE
69
        DATA_OUT    : out std_logic_vector(7 downto 0); -- output data
70
        DATA_VLD    : out std_logic; -- when DATA_VLD = 1, output data are valid
71
        FRAME_ERROR : out std_logic  -- when FRAME_ERROR = 1, stop bit was invalid
72
    );
73
end component;
74
 
75
signal d_out, rxd_data: std_logic_vector(7 downto 0);
76
signal rd_data, wr_data, wr_data0, wr_data1, rd_status, data_send: std_logic;
77
signal readSelect, writeSelect: std_logic;
78
signal valid, busy, error, char_received, ready: std_logic;
79
signal status_valid, status_error: std_logic;
80
 
81
begin
82
 
83
readSelect <= nSelect nor nRead;
84
writeSelect <= nSelect nor nWrite;
85
 
86
wr_data <= writeSelect and A;
87
rd_data <= readSelect and A ;
88
rd_status <= readSelect and not(A);
89
 
90
D <= d_out when (readSelect = '1') else "ZZZZZZZZ";
91
d_out <= rxd_data when (A = '1') else
92
                        (IntReq & status_error & "0000" & ready & status_valid);
93
 
94
sio: UART
95
         generic map
96
         (
97
                --CLK_FREQ => 100e6,
98
                BAUD_RATE => 38400 -- science fiction for the 80ies era...
99
                --PARITY_BIT => "even"
100
         )
101
         port map
102
         (
103
        CLK => clk,
104
        RST => reset,
105
        -- UART INTERFACE
106
        UART_TXD => txd, -- serial transmit data
107
        UART_RXD => rxd, -- serial receive data
108
        -- USER DATA INPUT INTERFACE
109
        DATA_IN  => D,
110
        DATA_SEND => data_send,
111
        BUSY  => busy,
112
        -- USER DATA OUTPUT INTERFACE
113
        DATA_OUT => rxd_data,
114
        DATA_VLD => valid,
115
        FRAME_ERROR => error
116
    );
117
 
118
ready <= not busy;
119
data_send <= wr_data and not (wr_data1);
120
generate_sendpulse: process(reset, clk, busy, wr_data)
121
begin
122
        if (reset = '1') then
123
                wr_data0 <= '0';
124
                wr_data1 <= '0';
125
        else
126
                if (rising_edge(clk)) then
127
                        wr_data1 <= wr_data0;
128
                        wr_data0 <= wr_data;
129
                end if;
130
        end if;
131
end process;
132
 
133
char_received <= valid or error;
134
generate_intreq: process(reset, IntAck, rd_data, char_received)
135
begin
136
        if (reset = '1' or IntAck = '1' or rd_data = '1') then
137
                IntReq <= '0';
138
                status_error <= not(reset or rd_data);
139
                status_valid <= not(reset or rd_data);
140
        else
141
                if rising_edge(char_received) then
142
                        IntReq <= '1';
143
                        status_error <= error;
144
                        status_valid <= valid;
145
                end if;
146
        end if;
147
end process;
148
 
149
end Behavioral;
150
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.