OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [ACIA_tb.vhd] - Blame information for rev 138

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 dilbert57
--===========================================================================--
2 122 dilbert57
--                                                                           --
3
--                        VHDL 6850 ACIA TestBench                           --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--
8
-- File name      : ACIA_tb.vhd
9
--
10
-- Entity name    : ACIA6850_testbench
11
--
12
-- Purpose        : VHDL testbench for acia6850
13
--
14
-- Dependencies   : ieee.std_logic_1164
15
--                  ieee.std_logic_unsigned
16
--                  ieee.std_logic_arith
17
--                  ieee.numeric_std
18
--
19
-- Author         : John E. Kent
20
--
21
-- Email          : dilbert57@opencores.org      
22
--
23
-- Web            : http://opencores.org/project,system09
24 19 dilbert57
--
25 122 dilbert57
--  Copyright (C) 2007 - 2011 John Kent
26
--
27
--  This program is free software: you can redistribute it and/or modify
28
--  it under the terms of the GNU General Public License as published by
29
--  the Free Software Foundation, either version 3 of the License, or
30
--  (at your option) any later version.
31
--
32
--  This program is distributed in the hope that it will be useful,
33
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
34
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35
--  GNU General Public License for more details.
36
--
37
--  You should have received a copy of the GNU General Public License
38
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
39
--
40
--===========================================================================--
41
--                                                                           --
42
--                                Revision History                           --
43
--                                                                           --
44
--===========================================================================--
45
--
46
-- Rev  Date        Author     Notes 
47
-- 0.1  2007-02-06  John Kent  Initial Version
48
-- 0.2  2011-10-09  John Kent  Renamed acia_6850 to acia6850
49 19 dilbert57
--
50
-------------------------------------------------------------------------------
51
library ieee;
52
   use ieee.std_logic_1164.all;
53
   use IEEE.STD_LOGIC_ARITH.ALL;
54
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
55
   use ieee.numeric_std.all;
56
 
57 122 dilbert57
entity ACIA6850_testbench is
58
end ACIA6850_testbench;
59 19 dilbert57
 
60
-------------------------------------------------------------------------------
61
-- Architecture for ACIA 6850 Unit
62
-------------------------------------------------------------------------------
63 122 dilbert57
architecture behavior of ACIA6850_testbench is
64 19 dilbert57
  -----------------------------------------------------------------------------
65
  -- Signals
66
  -----------------------------------------------------------------------------
67
  -- CPU Interface signals
68
  signal SysClk       : Std_Logic;
69
  signal uart_reset   : Std_Logic;
70
  signal uart_cs      : Std_Logic;
71
  signal uart_rw      : Std_Logic;
72
  signal uart_addr    : Std_Logic;
73
  signal uart_data_in : Std_Logic_Vector(7 downto 0);
74
  signal uart_data_out: Std_Logic_Vector(7 downto 0);
75
  signal uart_irq     : Std_Logic;
76
  signal rxclk        : Std_Logic;
77
  signal txclk        : Std_Logic;
78
  signal rxbit        : Std_Logic;
79
  signal txbit        : Std_Logic;
80
  signal dcd_n        : Std_Logic;
81
  signal cts_n        : Std_Logic;
82
  signal rts_n        : Std_Logic;
83
 
84
-----------------------------------------------------------------
85
--
86
-- ACIA 6850 UART
87
--
88
-----------------------------------------------------------------
89 122 dilbert57
component ACIA6850
90 19 dilbert57
  port (
91
     --
92
          -- CPU signals
93
          --
94 122 dilbert57
     clk      : in  std_logic;  -- System Clock
95
     rst      : in  std_logic;  -- Reset input (active high)
96
     cs       : in  std_logic;  -- miniUART Chip Select
97
     rw       : in  std_logic;  -- Read / Not Write
98
     addr     : in  std_logic;  -- Register Select
99
     data_in  : in  std_logic_vector(7 downto 0); -- Data Bus In 
100
     data_out : out std_logic_vector(7 downto 0); -- Data Bus Out
101
     irq      : out std_logic;  -- Interrupt
102 19 dilbert57
     --
103
          -- Uart Signals
104
          --
105 122 dilbert57
     RxC      : in  std_logic;  -- Receive Baud Clock
106
     TxC      : in  std_logic;  -- Transmit Baud Clock
107
     RxD      : in  std_logic;  -- Receive Data
108
     TxD      : out std_logic;  -- Transmit Data
109
          DCD_n    : in  std_logic;  -- Data Carrier Detect
110
     CTS_n    : in  std_logic;  -- Clear To Send
111
     RTS_n    : out std_logic );  -- Request To send
112 19 dilbert57
end component; --================== End of entity ==============================--
113
 
114
begin
115
 
116
  -----------------------------------------------------------------------------
117
  -- Instantiation of internal components
118
  -----------------------------------------------------------------------------
119
 
120 122 dilbert57
my_acia  : ACIA6850 port map (
121 19 dilbert57
    clk       => SysClk,
122
         rst       => uart_reset,
123
    cs        => uart_cs,
124
         rw        => uart_rw,
125 122 dilbert57
    addr      => uart_addr,
126
         data_in   => uart_data_in,
127
         data_out  => uart_data_out,
128
    irq       => uart_irq,
129 19 dilbert57
         RxC       => rxclk,
130
         TxC       => txclk,
131
         RxD       => rxbit,
132
         TxD       => txbit,
133
         DCD_n     => dcd_n,
134
         CTS_n     => cts_n,
135
         RTS_n     => rts_n
136
         );
137
 
138
 
139
  -- *** Test Bench - User Defined Section ***
140
   tb : PROCESS
141
        variable count : integer;
142
   BEGIN
143
 
144
   cts_n <= '0';
145
        dcd_n <= '0';
146
 
147
                for count in 0 to 4096 loop
148
                   if (count mod 16) = 0 then
149
                     rxclk <= '1';
150
                          txclk <= '1';
151
                   elsif (count mod 16) = 8 then
152
                     rxclk <= '0';
153
                          txclk <= '0';
154
         end if;
155
 
156
                        case count is
157
                        when 0 =>
158
                                uart_reset <= '1';
159
                      uart_cs <= '0';
160
                                uart_rw <= '1';
161
                                uart_addr <= '0';
162
                                uart_data_in <= "00000000";
163
                                rxbit <= '1';
164
                        when 1 =>
165
                                uart_reset <= '0';
166
                        when 3 =>
167
                      uart_cs <= '1';
168
                                uart_rw <= '0'; -- write control
169
                                uart_addr <= '0';
170
                                uart_data_in <= "00010001";
171
                        when 4 =>
172
                      uart_cs <= '0';
173
                                uart_rw <= '1';
174
                                uart_addr <= '0';
175
                                uart_data_in <= "00000000";
176
                        when 5 =>
177
                      uart_cs <= '1';
178
                                uart_rw <= '0'; -- write data
179
                                uart_addr <= '1';
180
                                uart_data_in <= "01010101";
181
                        when 6 =>
182
                      uart_cs <= '0';
183
                                uart_rw <= '1';
184
                                uart_addr <= '1';
185
                                uart_data_in <= "00000000";
186
                        when 256 =>
187
            rxbit <= '0'; -- start
188
                        when 512 =>
189
                           rxbit <= '1'; -- bit 0
190
                        when 768 =>
191
            rxbit <= '0'; -- bit 1
192
                        when 1024 =>
193
                           rxbit <= '1'; -- bit 2
194
                        when 1280 =>
195
            rxbit <= '1'; -- bit3
196
                        when 1536 =>
197
                           rxbit <= '0'; -- bit 4
198
                        when 1792 =>
199
            rxbit <= '0'; -- bit 5
200
                        when 2048 =>
201
                           rxbit <= '1'; -- bit 6
202
                        when 2304 =>
203
            rxbit <= '0'; -- bit 7
204
                        when 2560 =>
205
                           rxbit <= '1'; -- stop 1
206
                        when 2816 =>
207
                           rxbit <= '1'; -- stop 2
208
                        when 3100 =>
209
                      uart_cs <= '1';
210
                                uart_rw <= '1'; -- read control
211
                                uart_addr <= '0';
212
                        when 3101 =>
213
                      uart_cs <= '0';
214
                                uart_rw <= '1';
215
                                uart_addr <= '0';
216
                        when 3102 =>
217
                      uart_cs <= '1';
218
                                uart_rw <= '1'; -- read data
219
                                uart_addr <= '1';
220
                        when 3103 =>
221
                      uart_cs <= '0';
222
                                uart_rw <= '1';
223
                                uart_addr <= '1';
224
                        when others =>
225
                           null;
226
                        end case;
227
                        SysClk <= '1';
228
                        wait for 40 ns;
229
                        SysClk <= '0';
230
                        wait for 40 ns;
231
                end loop;
232
 
233
      wait; -- will wait forever
234
   END PROCESS;
235
-- *** End Test Bench - User Defined Section ***
236
 
237
end behavior; --===================== End of architecture =======================--
238
 

powered by: WebSVN 2.1.0

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