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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [VHDL/] [dma6844.vhd] - Blame information for rev 114

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

Line No. Rev Author Line
1 100 davidgb
--===========================================================================--
2
--                                                                           --
3
--               Synthesizable 6844 Compatible DMA Controller                --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : dma6844.vhd
8
--
9
--  Entity name    : dma6844
10
--
11
--  Purpose        : Implements a 6844 compatible Direct Memory Access Controller
12
--                   It is intended for use with 68xx compatible FPGA SoCs.
13
--                  
14
--  Dependencies   : ieee.std_logic_1164
15
--                   ieee.std_logic_unsigned
16
--                   ieee.std_logic_arith
17
--                   unisim.vcomponents
18
--
19
--  Author         : John E. Kent
20
--
21
--  Email          : dilbert57@opencores.org      
22
--
23
--  Web            : http://opencores.org/project,system09
24
--
25
--  Registers      :
26
--
27
--  4 Channel version
28
--
29
--  IO +  0 = DMA_AH0 = Address Register 0 High
30
--  IO +  1 = DMA_AL0 = Address Register 0 Low
31
--  IO +  2 = DMA_CH0 = Count   Register 0 High
32
--  IO +  3 = DMA_CL0 = Count   Register 0 Low
33
--
34
--  IO +  4 = DMA_AH1 = Address Register 1 High
35
--  IO +  5 = DMA_AL1 = Address Register 1 Low
36
--  IO +  6 = DMA_CH1 = Count   Register 1 High
37
--  IO +  7 = DMA_CL1 = Count   Register 1 Low
38
-- 
39
--  IO +  8 = DMA_AH2 = Address Register 2 High
40
--  IO +  9 = DMA_AL2 = Address Register 2 Low
41
--  IO + 10 = DMA_CH2 = Count   Register 2 High
42
--  IO + 11 = DMA_CL2 = Count   Register 2 Low
43
-- 
44
--  IO + 12 = DMA_AH3 = Address Register 3 High
45
--  IO + 13 = DMA_AL3 = Address Register 3 Low
46
--  IO + 14 = DMA_CH3 = Count   Register 3 High
47
--  IO + 15 = DMA_CL3 = Count   Register 3 Low
48
--  
49
--  IO + 16 = DMA_CC0 = Channel Control Register 0
50
--  IO + 17 = DMA_CC1 = Channel Control Register 1
51
--  IO + 18 = DMA_CC2 = Channel Control Register 2
52
--  IO + 19 = DMA_CC3 = Channel Control Register 3
53
--    Bit[7] = DMA_DEF = DMA END FLAG (DEND)
54
--    Bit[6] = DMA_BSY = DMA BUSY FLAG (READ ONLY)
55
--    Bit[3] = DMA_AUD = DMA ADDRESS NOT UP/DOWN
56
--    Bit[2] = DMA_MCA = DMA MODE CONTROL 0=>DRQ2   1=>DRQ1 
57
--    Bit[1] = DMA_MCB = DMA MODE CONTROL 0=>SINGLE 1=>BLOCK 
58
--       0 0 = DMA_MD2 = DMA MODE 2 - SINGLE TRANSFER - DRQ2
59
--       0 1 = DMA_MD3 = DMA MODE 3 - BLOCK  TRANSFER - DRQ2
60
--       1 0 = DMA_MD1 = DMA MODE 1 - SINGLE TRANSFER - DRQ1
61
--       1 1 = DMA_MDU = DMA MODE 4 - BLOCK  TRANSFER - DRQ1 - ACTUALLY UDEFINED 
62
--    Bit[0] = DMA_RW  = DMA READ/NOT WRITE
63
--
64
--  IO + 20  = DMA_PRI = DMA Priority Control Register
65
--    Bit[7] = DMA_ROT = DMA Rotate Control 0=>FIXED 1=>ROTATE
66
--    Bit[3] = DMA_RE3 = DMA REQUEST ENABLE #3
67
--    Bit[2] = DMA_RE2 = DMA REQUEST ENABLE #2
68
--    Bit[1] = DMA_RE1 = DMA REQUEST ENABLE #1
69
--    Bit[0] = DMA_RE0 = DMA REQUEST ENABLE #0
70
-- 
71
--  IO + 21  = DMA_INT = DMA Interrupt Control Register
72
--    Bit[7] = DMA_IEF = DMA END IRQ FLAG
73
--    Bit[3] = DMA_IE3 = DMA END IRQ ENABLE #3
74
--    Bit[2] = DMA_IE2 = DMA END IRQ ENABLE #2
75
--    Bit[1] = DMA_IE1 = DMA END IRQ ENABLE #1
76
--    Bit[0] = DMA_IE0 = DMA END IRQ ENABLE #0
77
--  
78
--  IO + 22  = DMA_CHN = DMA Data Chain register
79
--    Bit[3] = DMA_C24 = TWO/FOUR CHANNEL SELECT
80
--    Bit[2] = DMA_DCB = DATA CHAIN CHANNEL SELECT B
81
--    Bit[1] = DMA_DCA = DATA CHAIN CHANNEL SELECT A
82
--    Bit[0] = DMA_DCE = DATA CHAIN ENABLE 
83
--
84
--  Copyright (C) 2010 John Kent
85
--
86
--  This program is free software: you can redistribute it and/or modify
87
--  it under the terms of the GNU General Public License as published by
88
--  the Free Software Foundation, either version 3 of the License, or
89
--  (at your option) any later version.
90
--
91
--  This program is distributed in the hope that it will be useful,
92
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
93
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
94
--  GNU General Public License for more details.
95
--
96
--  You should have received a copy of the GNU General Public License
97
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
98
--
99
--===========================================================================--
100
--                                                                           --
101
--                              Revision  History                            --
102
--                                                                           --
103
--===========================================================================--
104
--
105
-- Revision Author        Date               Description
106
-- 0.1      John E. Kent  18th April 2010    Initial release
107
--
108
 
109
library ieee;
110
  use ieee.std_logic_1164.all;
111
  use ieee.std_logic_unsigned.all;
112
  use ieee.std_logic_arith.all;
113
 
114
library unisim;
115
  use unisim.vcomponents.all;
116
 
117
entity dma6844 is
118
   generic (
119
      ADDR_WIDTH = 16;
120
      DATA_WIDTH = 8;
121
      CHAN_COUNT = 4
122
      )
123
        port (
124
      --
125
      -- CPU Slave Interface
126
      --        
127
                clk      : in  std_logic;
128
                rst      : in  std_logic;
129
                rw       : out std_logic;
130
                cs       : out std_logic;
131
                addr     : in  std_logic_vector(LOG2(CHAN_COUNT*4*ADDR_WIDTH/DATA_WIDTH)-1 downto 0);
132
           data_in  : in  std_logic_vector(DATA_WIDTH-1 downto 0);
133
           data_out : out std_logic_vector(DATA_WIDTH-1 downto 0);
134
      irq      : out std_logic;
135
      --
136
      -- Bus Master Interface
137
      --
138
      breq     : out std_logic;
139
      bgnt     : in  std_logic;
140
      brw      : out std_logic;
141
      bvma     : out std_logic;
142
      baddr    : out std_logic_vector(ADDR_WIDTH-1 downto 0);
143
      --
144
      -- Device Interface
145
      --
146
      txreq    : in  std_logic_vector(CHAN_COUNT-1 downto 0);
147
      txstb    : out std_logic_vector(CHAN_COUNT-1 downto 0);
148
      txack    : out std_logic_vector(CHAN_COUNT-1 downto 0);
149
      txend    : out std_logic_vector(CHAN_COUNT-1 downto 0)
150
                );
151
end dma6844;
152
 
153
architecture rtl of dma6844 is
154
 
155
constant REG_COUNT : integer = (CHAN_COUNT * 2 * ADDR_WIDTH / DATA_WIDTH) + DMA_CHAN + 3;
156
 
157
subtype addr_subtype is std_logic_vector(ADDR_WIDTH-1 downto 0);
158
subtype data_subtype is std_logic_vector(DATA_WIDTH-1 downto 0);
159
 
160
type addr_type is array(0 to CHAN_COUNT-1) of addr_subtype;
161
type data_type is array(0 to CHAN_COUNT-1) of data_subtype;
162
type reg_type  is array(0 to REG_COUNT-1)  of data_subtype;
163
 
164
signal dma_addr    : addr_type;
165
signal dma_count   : addr_type;
166
signal dma_in_reg  : reg_type;
167
signal dma_out_reg : reg_type;
168
 
169
signal dma_reg_wr : std_logic := '0';
170
signal dma_reg_rd : std_logic := '0';
171
 
172
--
173
-- Registers
174
--
175
signal dma_adh_reg : data_type;
176
signal dma_adl_reg : data_type;
177
signal dma_cth_reg : data_type;
178
signal dma_ctl_reg : data_type;
179
signal dma_chc_reg : data_type;
180
signal dma_pri_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
181
signal dma_irq_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
182
signal dma_chn_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
183
 
184
begin
185
--
186
-- Write to DMA input register
187
--
188
dma_reg_write : process( clk, rst )
189
variable reg_addr   : integer := 0;
190
begin
191
  if( falling_edge(clk) )
192
    if( rst = '1' ) then
193
      for i in 0 to CHAN_COUNT-1 loop
194
        dma_addr(i)   <= (others=>'0');
195
        dma_count(i)  <= (others=>'0');
196
      end loop;
197
      for i in 0 to REG_COUNT-1 loop
198
        dma_in_reg(i) <= (others=>'0');
199
      end loop;
200
    else
201
      if( cs='1' and rw='0' ) then
202
        reg_addr := conv_integer(addr(ADDR_WIDTH-1 downto 0));
203
        if( reg_addr < REG_COUNT ) then
204
          dma_in_reg(reg_addr) <= data_in;
205
        end if;
206
      end if;
207
    end if;
208
  end if;
209
end process;
210
 
211
--
212
-- Assign input register to specific register names
213
--
214
dma_reg_assign : process( dma_in_reg )
215
begin
216
  for i in 0 to CHAN_COUNT-1 loop
217
    dma_adh_reg(i) <= dma_in_reg((i*4)+0);
218
    dma_adl_reg(i) <= dma_in_reg((i*4)+1);
219
    dma_cth_reg(i) <= dma_in_reg((i*4)+2);
220
    dma_ctl_reg(i) <= dma_in_reg((i*4)+3);
221
    dma_chc_reg(i) <= dma_in_reg((CHAN_COUNT*4)+i);
222
  end loop;
223
  dma_pri_reg <= dma_in_reg((CHAN_COUNT*5)+0);
224
  dma_irq_reg <= dma_in_reg((CHAN_COUNT*5)+1);
225
  dma_chn_reg <= dma_in_reg((CHAN_COUNT*5)+2);
226
end process;
227
 
228
--
229
-- Process Transfer Request Inputs
230
--
231
dma_tx_req : process( clk, rst, txreq )
232
begin
233
  if( rising_edge( clk ) ) then
234
    if( rst='1' ) then
235
    else
236
      for i in 0 to CHAN_COUNT-1 loop
237
      end loop;
238
    end if;
239
  end if;
240
end process;
241
 
242
end architecture rtl;
243
 

powered by: WebSVN 2.1.0

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