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

Subversion Repositories System09

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

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

Line No. Rev Author Line
1 19 dilbert57
--===========================================================================--
2
--
3
-- ACIA 6850 Test Bench
4
--
5
--
6
-- John Kent 6th February 2007
7
--
8
--
9
-------------------------------------------------------------------------------
10
library ieee;
11
   use ieee.std_logic_1164.all;
12
   use IEEE.STD_LOGIC_ARITH.ALL;
13
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
14
   use ieee.numeric_std.all;
15
 
16
entity ACIA_6850_testbench is
17
end ACIA_6850_testbench;
18
 
19
-------------------------------------------------------------------------------
20
-- Architecture for ACIA 6850 Unit
21
-------------------------------------------------------------------------------
22
architecture behavior of ACIA_6850_testbench is
23
  -----------------------------------------------------------------------------
24
  -- Signals
25
  -----------------------------------------------------------------------------
26
  -- CPU Interface signals
27
  signal SysClk       : Std_Logic;
28
  signal uart_reset   : Std_Logic;
29
  signal uart_cs      : Std_Logic;
30
  signal uart_rw      : Std_Logic;
31
  signal uart_addr    : Std_Logic;
32
  signal uart_data_in : Std_Logic_Vector(7 downto 0);
33
  signal uart_data_out: Std_Logic_Vector(7 downto 0);
34
  signal uart_irq     : Std_Logic;
35
  signal rxclk        : Std_Logic;
36
  signal txclk        : Std_Logic;
37
  signal rxbit        : Std_Logic;
38
  signal txbit        : Std_Logic;
39
  signal dcd_n        : Std_Logic;
40
  signal cts_n        : Std_Logic;
41
  signal rts_n        : Std_Logic;
42
 
43
-----------------------------------------------------------------
44
--
45
-- ACIA 6850 UART
46
--
47
-----------------------------------------------------------------
48
component ACIA_6850
49
  port (
50
     --
51
          -- CPU signals
52
          --
53
     clk      : in  Std_Logic;  -- System Clock
54
     rst      : in  Std_Logic;  -- Reset input (active high)
55
     cs       : in  Std_Logic;  -- miniUART Chip Select
56
     rw       : in  Std_Logic;  -- Read / Not Write
57
     irq      : out Std_Logic;  -- Interrupt
58
     Addr     : in  Std_Logic;  -- Register Select
59
     DataIn   : in  Std_Logic_Vector(7 downto 0); -- Data Bus In 
60
     DataOut  : out Std_Logic_Vector(7 downto 0); -- Data Bus Out
61
     --
62
          -- Uart Signals
63
          --
64
     RxC      : in  Std_Logic;  -- Receive Baud Clock
65
     TxC      : in  Std_Logic;  -- Transmit Baud Clock
66
     RxD      : in  Std_Logic;  -- Receive Data
67
     TxD      : out Std_Logic;  -- Transmit Data
68
          DCD_n    : in  Std_Logic;  -- Data Carrier Detect
69
     CTS_n    : in  Std_Logic;  -- Clear To Send
70
     RTS_n    : out Std_Logic );  -- Request To send
71
end component; --================== End of entity ==============================--
72
 
73
begin
74
 
75
  -----------------------------------------------------------------------------
76
  -- Instantiation of internal components
77
  -----------------------------------------------------------------------------
78
 
79
my_acia  : ACIA_6850 port map (
80
    clk       => SysClk,
81
         rst       => uart_reset,
82
    cs        => uart_cs,
83
         rw        => uart_rw,
84
    Irq       => uart_irq,
85
    Addr      => uart_addr,
86
         Datain    => uart_data_in,
87
         DataOut   => uart_data_out,
88
         RxC       => rxclk,
89
         TxC       => txclk,
90
         RxD       => rxbit,
91
         TxD       => txbit,
92
         DCD_n     => dcd_n,
93
         CTS_n     => cts_n,
94
         RTS_n     => rts_n
95
         );
96
 
97
 
98
  -- *** Test Bench - User Defined Section ***
99
   tb : PROCESS
100
        variable count : integer;
101
   BEGIN
102
 
103
   cts_n <= '0';
104
        dcd_n <= '0';
105
 
106
                for count in 0 to 4096 loop
107
                   if (count mod 16) = 0 then
108
                     rxclk <= '1';
109
                          txclk <= '1';
110
                   elsif (count mod 16) = 8 then
111
                     rxclk <= '0';
112
                          txclk <= '0';
113
         end if;
114
 
115
                        case count is
116
                        when 0 =>
117
                                uart_reset <= '1';
118
                      uart_cs <= '0';
119
                                uart_rw <= '1';
120
                                uart_addr <= '0';
121
                                uart_data_in <= "00000000";
122
                                rxbit <= '1';
123
                        when 1 =>
124
                                uart_reset <= '0';
125
                        when 3 =>
126
                      uart_cs <= '1';
127
                                uart_rw <= '0'; -- write control
128
                                uart_addr <= '0';
129
                                uart_data_in <= "00010001";
130
                        when 4 =>
131
                      uart_cs <= '0';
132
                                uart_rw <= '1';
133
                                uart_addr <= '0';
134
                                uart_data_in <= "00000000";
135
                        when 5 =>
136
                      uart_cs <= '1';
137
                                uart_rw <= '0'; -- write data
138
                                uart_addr <= '1';
139
                                uart_data_in <= "01010101";
140
                        when 6 =>
141
                      uart_cs <= '0';
142
                                uart_rw <= '1';
143
                                uart_addr <= '1';
144
                                uart_data_in <= "00000000";
145
                        when 256 =>
146
            rxbit <= '0'; -- start
147
                        when 512 =>
148
                           rxbit <= '1'; -- bit 0
149
                        when 768 =>
150
            rxbit <= '0'; -- bit 1
151
                        when 1024 =>
152
                           rxbit <= '1'; -- bit 2
153
                        when 1280 =>
154
            rxbit <= '1'; -- bit3
155
                        when 1536 =>
156
                           rxbit <= '0'; -- bit 4
157
                        when 1792 =>
158
            rxbit <= '0'; -- bit 5
159
                        when 2048 =>
160
                           rxbit <= '1'; -- bit 6
161
                        when 2304 =>
162
            rxbit <= '0'; -- bit 7
163
                        when 2560 =>
164
                           rxbit <= '1'; -- stop 1
165
                        when 2816 =>
166
                           rxbit <= '1'; -- stop 2
167
                        when 3100 =>
168
                      uart_cs <= '1';
169
                                uart_rw <= '1'; -- read control
170
                                uart_addr <= '0';
171
                        when 3101 =>
172
                      uart_cs <= '0';
173
                                uart_rw <= '1';
174
                                uart_addr <= '0';
175
                        when 3102 =>
176
                      uart_cs <= '1';
177
                                uart_rw <= '1'; -- read data
178
                                uart_addr <= '1';
179
                        when 3103 =>
180
                      uart_cs <= '0';
181
                                uart_rw <= '1';
182
                                uart_addr <= '1';
183
                        when others =>
184
                           null;
185
                        end case;
186
                        SysClk <= '1';
187
                        wait for 40 ns;
188
                        SysClk <= '0';
189
                        wait for 40 ns;
190
                end loop;
191
 
192
      wait; -- will wait forever
193
   END PROCESS;
194
-- *** End Test Bench - User Defined Section ***
195
 
196
end behavior; --===================== End of architecture =======================--
197
 

powered by: WebSVN 2.1.0

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