OpenCores
URL https://opencores.org/ocsvn/lzrw1-compressor-core/lzrw1-compressor-core/trunk

Subversion Repositories lzrw1-compressor-core

[/] [lzrw1-compressor-core/] [trunk/] [hw/] [HDL/] [CompressorTop.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 habicht
--/**************************************************************************************************************
2
--*
3
--*    L Z R W 1   E N C O D E R   C O R E
4
--*
5
--*  A high throughput loss less data compression core.
6
--* 
7
--* Copyright 2012-2013   Lukas Schrittwieser (LS)
8
--*
9
--*    This program is free software: you can redistribute it and/or modify
10
--*    it under the terms of the GNU General Public License as published by
11
--*    the Free Software Foundation, either version 2 of the License, or
12
--*    (at your option) any later version.
13
--*
14
--*    This program is distributed in the hope that it will be useful,
15
--*    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
--*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
--*    GNU General Public License for more details.
18
--*
19
--*    You should have received a copy of the GNU General Public License
20
--*    along with this program; if not, write to the Free Software
21
--*    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22
--*    Or see <http://www.gnu.org/licenses/>
23
--*
24
--***************************************************************************************************************
25
--*
26
--* Change Log:
27
--*
28
--* Version 1.0 - 2012/10/16 - LS
29
--*   started file
30
--*
31
--* Version 1.0 - 2013/04/05 - LS
32
--*   released
33
--*
34
--***************************************************************************************************************
35
--*
36
--* Naming convention:  http://dz.ee.ethz.ch/en/information/hdl-help/vhdl-naming-conventions.html
37
--*
38
--***************************************************************************************************************
39
--*
40
--* Top level file for data compressor. Implements the wishbone interfaces, a
41
--* simple DMA controller and some glue logic.
42
--*
43
--***************************************************************************************************************
44
library IEEE;
45
use IEEE.STD_LOGIC_1164.all;
46
use IEEE.NUMERIC_STD.all;
47
 
48
library UNISIM;
49
use UNISIM.VComponents.all;
50
 
51
entity CompressorTop is
52
  port (
53
    ClkxCI   : in  std_logic;
54
    RstxRI   : in  std_logic;
55
    -- wishbone config and data input interface (32 bit access only!!)
56
    SlCycxSI : in  std_logic;
57
    SlStbxSI : in  std_logic;
58
    SlWexSI  : in  std_logic;
59
    SlSelxDI : in  std_logic_vector(3 downto 0);
60
    SlAdrxDI : in  std_logic_vector(4 downto 2);
61
    SlDatxDI : in  std_logic_vector(31 downto 0);
62
    SlDatxDO : out std_logic_vector(31 downto 0);
63
    SlAckxSO : out std_logic;
64
    SlErrxSO : out std_logic;
65
    IntxSO   : out std_logic;
66
    -- wishbone dma master interface
67
    MaCycxSO : out std_logic;
68
    MaStbxSO : out std_logic;
69
    MaWexSO  : out std_logic;
70
    MaSelxDO : out std_logic_vector(3 downto 0);
71
    MaAdrxDO : out std_logic_vector(31 downto 0);
72
    MaDatxDO : out std_logic_vector(31 downto 0);
73
    MaDatxDI : in  std_logic_vector(31 downto 0);
74
    MaAckxSI : in  std_logic;
75
    MaErrxSI : in  std_logic
76
    );
77
end CompressorTop;
78
 
79
architecture Behavioral of CompressorTop is
80
 
81
  component InputFIFO
82
    port (
83
      ClkxCI        : in  std_logic;
84
      RstxRI        : in  std_logic;
85
      DInxDI        : in  std_logic_vector(31 downto 0);
86
      WExSI         : in  std_logic;
87
      StopOutputxSI : in  std_logic;
88
      BusyxSO       : out std_logic;
89
      DOutxDO       : out std_logic_vector(7 downto 0);
90
      OutStrobexSO  : out std_logic;
91
      LengthxDO     : out integer range 0 to 2048);
92
  end component;
93
 
94
  component LZRWcompressor
95
    port (
96
      ClkxCI         : in  std_logic;
97
      RstxRI         : in  std_logic;
98
      DataInxDI      : in  std_logic_vector(7 downto 0);
99
      StrobexSI      : in  std_logic;
100
      FlushBufxSI    : in  std_logic;
101
      BusyxSO        : out std_logic;
102
      DonexSO        : out std_logic;
103
      BufOutxDO      : out std_logic_vector(7 downto 0);
104
      OutputValidxSO : out std_logic;
105
      RdStrobexSI    : in  std_logic;
106
      LengthxDO      : out integer range 0 to 1024);
107
  end component;
108
 
109
  constant INPUT_FIFO_SIZE : integer := 1024;  -- length of input fifo in bytes
110
  constant DMA_LEN_SIZE    : integer := 16;  -- size of dma len counter in bits
111
  --constant MAX_DMA_LEN_VALUE : integer := 2**16-1;  -- maximum value of the dma length counter
112
 
113
  signal RstCorexSN, RstCorexSP : std_logic := '1';
114
  signal WeInFIFOxS             : std_logic;
115
  signal InFIFOLenxD            : integer range 0 to INPUT_FIFO_SIZE;
116
 
117
  signal CoreBusyxS                 : std_logic;
118
  signal CoreDonexS                 : std_logic;
119
  signal CoreDatInxD                : std_logic_vector(7 downto 0);
120
  signal CoreStbxS                  : std_logic;
121
  signal FIFOBusyxS                 : std_logic;
122
  signal FlushxSN, FlushxSP         : std_logic := '0';
123
  signal FlushCorexSN, FlushCorexSP : std_logic := '0';
124
  signal CoreRdStbxS                : std_logic;
125
  signal OutFIFOLenxD               : integer range 0 to 1024;
126
  signal CoreDatOutxD               : std_logic_vector(7 downto 0);
127
  signal CoreOutValidxS             : std_logic;
128
 
129
  signal ClearIntFlagsxSN, ClearIntFlagsxSP      : std_logic                     := '0';
130
  signal ClearInFIFOFlagsxS, ClearOutFIFOFlagsxS : std_logic;
131
  signal InFIFOEmptyFlgxSN, InFIFOEmptyFlgxSP    : std_logic                     := '0';
132
  signal InFIFOFullFlgxSN, InFIFOFullFlgxSP      : std_logic                     := '0';
133
  signal OutFIFOEmptyFlgxSN, OutFIFOEmptyFlgxSP  : std_logic                     := '0';
134
  signal OutFIFOFullFlgxSN, OutFIFOFullFlgxSP    : std_logic                     := '0';
135
  signal IEInFIFOEmptyxSN, IEInFIFOEmptyxSP      : std_logic                     := '0';
136
  signal IEInFIFOFullxSN, IEInFIFOFullxSP        : std_logic                     := '0';
137
  signal IEOutFIFOEmptyxSN, IEOutFIFOEmptyxSP    : std_logic                     := '0';
138
  signal IEOutFIFOFullxSN, IEOutFIFOFullxSP      : std_logic                     := '0';
139
  signal IEDmaErrxSN, IEDmaErrxSP                : std_logic                     := '0';
140
  signal IECoreDonexSN, IECoreDonexSP            : std_logic                     := '0';
141
  signal IRQxSN, IRQxSP                          : std_logic                     := '0';
142
  signal InFIFOEmptyThrxDN, InFIFOEmptyThrxDP    : std_logic_vector(15 downto 0) := (others => '0');
143
  signal InFIFOFullThrxDN, InFIFOFullThrxDP      : std_logic_vector(15 downto 0) := (others => '1');
144
  signal OutFIFOEmptyThrxDN, OutFIFOEmptyThrxDP  : std_logic_vector(15 downto 0) := (others => '0');
145
  signal OutFIFOFullThrxDN, OutFIFOFullThrxDP    : std_logic_vector(15 downto 0) := (others => '1');
146
 
147
  signal IncDestAdrFlgxSN, IncDestAdrFlgxSP : std_logic                            := '0';
148
  signal DmaErrFlgxSN, DmaErrFlgxSP         : std_logic                            := '0';
149
  signal WrDmaDestAdrxS                     : std_logic;
150
  signal WrDmaLenxS                         : std_logic;
151
  signal DmaBusyxSN, DmaBusyxSP             : std_logic                            := '0';
152
  signal DmaDestAdrxDN, DmaDestAdrxDP       : std_logic_vector(31 downto 0)        := (others => '0');
153
  signal XferByteCntxDN, XferByteCntxDP     : integer range 0 to 4                 := 0;
154
  signal DmaLenxDN, DmaLenxDP               : integer range 0 to 2**DMA_LEN_SIZE-1 := 0;
155
  signal DmaDataOutxDN, DmaDataOutxDP       : std_logic_vector(31 downto 0)        := (others => '0');
156
  signal DmaSelxSN, DmaSelxSP               : std_logic_vector(3 downto 0)         := (others => '0');
157
  signal MaCycxSN, MaCycxSP                 : std_logic                            := '0';
158
  signal MaStbxSN, MaStbxSP                 : std_logic                            := '0';
159
 
160
begin  -- Behavioral
161
 
162
  WbSlInPrcs : process (DmaBusyxSP, FlushCorexSP, FlushxSP, IECoreDonexSP,
163
                        IEDmaErrxSP, IEInFIFOEmptyxSP, IEInFIFOFullxSP,
164
                        IEOutFIFOEmptyxSP, IEOutFIFOFullxSP, InFIFOEmptyThrxDP,
165
                        InFIFOFullThrxDP, IncDestAdrFlgxSP, OutFIFOEmptyThrxDP,
166
                        OutFIFOFullThrxDP, SlAdrxDI, SlCycxSI, SlDatxDI,
167
                        SlStbxSI, SlWexSI)
168
  begin
169
    WeInFIFOxS          <= '0';
170
    RstCorexSN          <= '0';
171
    FlushxSN            <= FlushxSP and not FlushCorexSP;  -- clear flush flag when core is flushed
172
    ClearInFIFOFlagsxS  <= '0';
173
    ClearOutFIFOFlagsxS <= '0';
174
    ClearIntFlagsxSN    <= '0';
175
    IEInFIFOEmptyxSN    <= IEInFIFOEmptyxSP;
176
    IEInFIFOFullxSN     <= IEInFIFOFullxSP;
177
    IEOutFIFOEmptyxSN   <= IEOutFIFOEmptyxSP;
178
    IEOutFIFOFullxSN    <= IEOutFIFOFullxSP;
179
    IEDmaErrxSN         <= IEDmaErrxSP;
180
    IECoreDonexSN       <= IECoreDonexSP;
181
    IncDestAdrFlgxSN    <= IncDestAdrFlgxSP;
182
    InFIFOEmptyThrxDN   <= InFIFOEmptyThrxDP;
183
    InFIFOFullThrxDN    <= InFIFOFullThrxDP;
184
    OutFIFOFullThrxDN   <= OutFIFOFullThrxDP;
185
    OutFIFOEmptyThrxDN  <= OutFIFOEmptyThrxDP;
186
    WrDmaDestAdrxS      <= '0';
187
    WrDmaLenxS          <= '0';
188
 
189
    -- decode write commands
190
    if SlCycxSI = '1' and SlStbxSI = '1' and SlWexSI = '1' then
191
      case SlAdrxDI is
192
        when "000" =>                   -- data input register
193
          if FlushxSP = '0' then        -- ignore all data after flush command was sent
194
            WeInFIFOxS <= '1';
195
          end if;
196
 
197
        when "001" =>                   -- config flags
198
          if DmaBusyxSP = '0' then
199
            IncDestAdrFlgxSN <= SlDatxDI(8);
200
          end if;
201
          IEInFIFOEmptyxSN  <= SlDatxDI(16);
202
          IEInFIFOFullxSN   <= SlDatxDI(17);
203
          IEOutFIFOEmptyxSN <= SlDatxDI(18);
204
          IEOutFIFOFullxSN  <= SlDatxDI(19);
205
          IEDmaErrxSN       <= SlDatxDI(20);
206
          IECoreDonexSN     <= SlDatxDI(21);
207
          ClearIntFlagsxSN  <= '1';
208
 
209
        when "010" =>
210
          InFIFOFullThrxDN   <= SlDatxDI(31 downto 16);
211
          InFIFOEmptyThrxDN  <= SlDatxDI(15 downto 0);
212
          ClearInFIFOFlagsxS <= '1';
213
 
214
        when "011" =>
215
          OutFIFOFullThrxDN   <= SlDatxDI(31 downto 16);
216
          OutFIFOEmptyThrxDN  <= SlDatxDI(15 downto 0);
217
          ClearOutFIFOFlagsxS <= '1';
218
 
219
        when "100" =>
220
          -- may only be written if dma unit is not busy
221
          if DmaBusyxSP = '0' then
222
            WrDmaDestAdrxS <= '1';
223
          end if;
224
 
225
        when "101" =>
226
          if DmaBusyxSP = '0' then
227
            WrDmaLenxS <= '1';
228
          end if;
229
 
230
        when "111" =>                   -- command register
231
          if SlDatxDI(0) = '1' then
232
            -- reset command
233
            RstCorexSN          <= SlDatxDI(0);
234
            ClearInFIFOFlagsxS  <= '1';
235
            ClearOutFIFOFlagsxS <= '1';
236
          end if;
237
          FlushxSN <= SlDatxDI(1) or FlushxSP;
238
 
239
        when others => null;
240
      end case;
241
    end if;
242
  end process WbSlInPrcs;
243
 
244
  -- we flush the core if a flush was requested and the intput fifo is empty
245
  FlushCorexSN <= '1' when FlushxSP = '1' and InFIFOLenxD = 0 else '0';
246
 
247
 
248
  process (CoreDonexS, DmaBusyxSP, DmaDestAdrxDP, DmaErrFlgxSP, DmaLenxDP,
249
           IECoreDonexSP, IEDmaErrxSP, IEInFIFOEmptyxSP, IEInFIFOFullxSP,
250
           IEOutFIFOEmptyxSP, IEOutFIFOFullxSP, InFIFOEmptyFlgxSP,
251
           InFIFOEmptyThrxDP, InFIFOFullFlgxSP, InFIFOFullThrxDP, InFIFOLenxD,
252
           IncDestAdrFlgxSP, OutFIFOEmptyFlgxSP, OutFIFOEmptyThrxDP,
253
           OutFIFOFullFlgxSP, OutFIFOFullThrxDN, OutFIFOLenxD, SlAdrxDI,
254
           SlCycxSI, SlStbxSI, SlWexSI, XferByteCntxDP)
255
  begin  --
256
 
257
    SlDatxDO <= x"00000000";
258
    -- decode read commands
259
    if SlCycxSI = '1' and SlStbxSI = '1' and SlWexSI = '0' then
260
      case SlAdrxDI is
261
        when "000" => null;             -- data input, no read access
262
 
263
        when "001" =>                         -- config and status reg
264
          SlDatxDO(3)  <= DmaBusyxSP;
265
          SlDatxDO(8)  <= IncDestAdrFlgxSP;   -- config flags
266
          SlDatxDO(16) <= IEInFIFOEmptyxSP;   -- interrupt enables
267
          SlDatxDO(17) <= IEInFIFOFullxSP;
268
          SlDatxDO(18) <= IEOutFIFOEmptyxSP;
269
          SlDatxDO(19) <= IEOutFIFOFullxSP;
270
          SlDatxDO(20) <= IEDmaErrxSP;
271
          SlDatxDO(21) <= IECoreDonexSP;
272
          SlDatxDO(24) <= InFIFOEmptyFlgxSP;  -- interrupt flags
273
          SlDatxDO(25) <= InFIFOFullFlgxSP;
274
          SlDatxDO(26) <= OutFIFOEmptyFlgxSP;
275
          SlDatxDO(27) <= OutFIFOFullFlgxSP;
276
          SlDatxDO(28) <= DmaErrFlgxSP;
277
          SlDatxDO(29) <= CoreDonexS;
278
          --ClearIntFlagsxSN <= '1';
279
 
280
        when "010" => SlDatxDO <= InFIFOFullThrxDP & InFIFOEmptyThrxDP;
281
 
282
        when "011" => SlDatxDO <= OutFIFOFullThrxDN & OutFIFOEmptyThrxDP;
283
 
284
        when "100" => SlDatxDO <= DmaDestAdrxDP(31 downto 2) & std_logic_vector(to_unsigned(XferByteCntxDP, 2));
285
 
286
        when "101" => SlDatxDO <= x"0000" & std_logic_vector(to_unsigned(DmaLenxDP, DMA_LEN_SIZE));
287
 
288
        when "110" => SlDatxDO <= std_logic_vector(to_unsigned(OutFIFOLenxD, 16)) & std_logic_vector(to_unsigned(InFIFOLenxD, 16));
289
 
290
        when others => null;
291
      end case;
292
    end if;
293
 
294
  end process;
295
 
296
 
297
  -- create an ACK on slave bus for all 32bits accesses. Other types of
298
  -- accesses are not possible -> terminate with error signal
299
  SlAckxSO <= SlCycxSI and SlStbxSI when SlSelxDI = "1111" else '0';
300
  SlErrxSO <= SlCycxSI and SlStbxSI when SlSelxDI /= "1111" else '0';
301
 
302
 
303
  InterruptsPrcs : process (ClearInFIFOFlagsxS, ClearIntFlagsxSP,
304
                            ClearOutFIFOFlagsxS, CoreDonexS, DmaErrFlgxSP,
305
                            IECoreDonexSP, IEDmaErrxSP, IEInFIFOEmptyxSP,
306
                            IEInFIFOFullxSP, IEOutFIFOEmptyxSP,
307
                            IEOutFIFOFullxSP, InFIFOEmptyFlgxSP,
308
                            InFIFOEmptyThrxDP, InFIFOFullFlgxSP,
309
                            InFIFOFullThrxDP, InFIFOLenxD, OutFIFOEmptyFlgxSP,
310
                            OutFIFOEmptyThrxDP, OutFIFOFullFlgxSP,
311
                            OutFIFOFullThrxDP, OutFIFOLenxD)
312
  begin
313
    InFIFOEmptyFlgxSN  <= InFIFOEmptyFlgxSP;
314
    InFIFOFullFlgxSN   <= InFIFOFullFlgxSP;
315
    OutFIFOEmptyFlgxSN <= OutFIFOEmptyFlgxSP;
316
    OutFIFOFullFlgxSN  <= OutFIFOFullFlgxSP;
317
 
318
    if ClearInFIFOFlagsxS = '0' then
319
      if InFIFOLenxD < to_integer(unsigned(InFIFOEmptyThrxDP)) then
320
        InFIFOEmptyFlgxSN <= '1';
321
      end if;
322
 
323
      if InFIFOLenxD >= to_integer(unsigned(InFIFOFullThrxDP)) then
324
        InFIFOFullFlgxSN <= '1';
325
      end if;
326
    else
327
      InFIFOEmptyFlgxSN <= '0';
328
      InFIFOFullFlgxSN  <= '0';
329
    end if;
330
 
331
    if ClearOutFIFOFlagsxS = '0' then
332
      if OutFIFOLenxD < to_integer(unsigned(OutFIFOEmptyThrxDP)) then
333
        OutFIFOEmptyFlgxSN <= '1';
334
      end if;
335
 
336
      if OutFIFOLenxD >= to_integer(unsigned(OutFIFOFullThrxDP)) then
337
        OutFIFOFullFlgxSN <= '1';
338
      end if;
339
    else
340
      OutFIFOEmptyFlgxSN <= '0';
341
      OutFIFOFullFlgxSN  <= '0';
342
    end if;
343
 
344
    if ClearIntFlagsxSP = '1' then
345
      InFIFOEmptyFlgxSN  <= '0';
346
      InFIFOFullFlgxSN   <= '0';
347
      OutFIFOEmptyFlgxSN <= '0';
348
      OutFIFOFullFlgxSN  <= '0';
349
    end if;
350
 
351
    IRQxSN <= (InFIFOEmptyFlgxSP and IEInFIFOEmptyxSP) or
352
              (InFIFOFullFlgxSP and IEInFIFOFullxSP) or
353
              (OutFIFOEmptyFlgxSP and IEOutFIFOEmptyxSP) or
354
              (OutFIFOFullFlgxSP and IEOutFIFOFullxSP) or
355
              (DmaErrFlgxSP and IEDmaErrxSP) or
356
              (CoreDonexS and IECoreDonexSP);
357
  end process InterruptsPrcs;
358
 
359
  IntxSO <= IRQxSP;
360
 
361
 
362
  DmaPrcs : process (ClearIntFlagsxSP, CoreDatOutxD, CoreOutValidxS,
363
                     DmaDataOutxDP, DmaDestAdrxDP, DmaErrFlgxSP, DmaLenxDP,
364
                     DmaSelxSP, IncDestAdrFlgxSP, MaAckxSI, MaCycxSP, MaErrxSI,
365
                     MaStbxSP, OutFIFOLenxD, RstCorexSP, SlDatxDI,
366
                     WrDmaDestAdrxS, WrDmaLenxS, XferByteCntxDP)
367
  begin
368
    DmaLenxDN      <= DmaLenxDP;
369
    DmaDestAdrxDN  <= DmaDestAdrxDP;
370
    XferByteCntxDN <= XferByteCntxDP;
371
    DmaDataOutxDN  <= DmaDataOutxDP;
372
    DmaSelxSN      <= DmaSelxSP;
373
    CoreRdStbxS    <= '0';
374
    MaCycxSN       <= MaCycxSP;
375
    MaStbxSN       <= MaStbxSP;
376
    DmaErrFlgxSN   <= DmaErrFlgxSP;
377
 
378
    -- if len is not zero dma unit is busy with a transfer
379
    if DmaLenxDP = 0 then
380
      DmaBusyxSN <= '0';
381
      if WrDmaDestAdrxS = '1' then
382
        -- the last two bits specify at which byte within the 4 byte wide bus
383
        -- we start -> load them into the transfer byte counter
384
        DmaDestAdrxDN  <= SlDatxDI(31 downto 2) & "00";
385
        XferByteCntxDN <= to_integer(unsigned(SlDatxDI(1 downto 0)));
386
        DmaSelxSN      <= (others => '0');
387
      end if;
388
      if WrDmaLenxS = '1' then
389
        DmaLenxDN <= to_integer(unsigned(SlDatxDI(DMA_LEN_SIZE-1 downto 0)));
390
      end if;
391
 
392
    else
393
      if RstCorexSP = '1' then
394
        -- abort the dma operation
395
        DmaLenxDN  <= 0;
396
        MaCycxSN   <= '0';
397
        MaStbxSN   <= '0';
398
        DmaBusyxSN <= '0';
399
      else
400
 
401
        DmaBusyxSN <= '1';
402
 
403
        -- wait until the last wishbone transfer is done
404
        if MaCycxSP = '0' then
405
          -- read data from output fifo when it becomes available
406
          if OutFIFOLenxD > 0 then
407
            -- output a read strobe if there is room for more than one byte
408
            -- (check dma length counter and transfer byte counter). This condition is
409
            -- loosened if there is no byte comming in this cycle
410
            if (XferByteCntxDP < 3 and DmaLenxDP > 1) or CoreOutValidxS = '0' then
411
              -- send read request to core
412
              CoreRdStbxS <= '1';
413
            end if;
414
          end if;
415
 
416
          if CoreOutValidxS = '1' then
417
            -- copy byte from core into output buffer
418
            DmaLenxDN <= DmaLenxDP - 1;
419
            if IncDestAdrFlgxSP = '1' and XferByteCntxDP < 4 then
420
              XferByteCntxDN <= XferByteCntxDP + 1;
421
            end if;
422
            DmaDataOutxDN((XferByteCntxDP+1)*8-1 downto XferByteCntxDP*8) <= CoreDatOutxD;
423
            DmaSelxSN(XferByteCntxDP)                                     <= '1';
424
            -- if we write the last byte (end of buffer or end of fifo or end of dma len) address or we have a don't inc
425
            -- transfer we create a whishbone cycle
426
            if XferByteCntxDP = 3 or IncDestAdrFlgxSP = '0' or DmaLenxDP = 1 or OutFIFOLenxD = 0 then
427
              MaCycxSN <= '1';
428
              MaStbxSN <= '1';
429
            end if;
430
          end if;
431
        end if;
432
      end if;
433
    end if;
434
 
435
    -- wait for an ack or err from the slave
436
    if MaAckxSI = '1' then
437
      -- transfer is done, deassert signals
438
      MaCycxSN  <= '0';
439
      MaStbxSN  <= '0';
440
      DmaSelxSN <= (others => '0');     -- reset sel signals for next transfer
441
      if XferByteCntxDP = 4 then
442
        XferByteCntxDN <= 0;
443
        -- inc destination address to the next word
444
        if IncDestAdrFlgxSP = '1' then
445
          DmaDestAdrxDN <= std_logic_vector(to_unsigned(to_integer(unsigned(DmaDestAdrxDP))+4, 32));
446
        end if;
447
      end if;
448
    end if;
449
    if MaErrxSI = '1' then
450
      -- transfer is done, deassert signals
451
      MaCycxSN     <= '0';
452
      MaStbxSN     <= '0';
453
      -- an whishbone error occured, abort dma transfer
454
      DmaLenxDN    <= 0;
455
      DmaErrFlgxSN <= '1';
456
    end if;
457
 
458
    if ClearIntFlagsxSP = '1' then
459
      DmaErrFlgxSN <= '0';
460
    end if;
461
  end process DmaPrcs;
462
 
463
  MaCycxSO <= MaCycxSP;
464
  MaStbxSO <= MaStbxSP;
465
  MaSelxDO <= DmaSelxSP;
466
  MaDatxDO <= DmaDataOutxDP;
467
  MaAdrxDO <= DmaDestAdrxDP;
468
  MaWexSO  <= '1';  -- we don't do any reads on the dma interface
469
 
470
  -- registers
471
  process (ClkxCI)
472
  begin
473
 
474
    if ClkxCI'event and ClkxCI = '1' then  -- rising clock edge
475
 
476
      if RstxRI = '1' then
477
        RstCorexSP         <= '1';
478
        FlushxSP           <= '0';
479
        FlushCorexSP       <= '0';
480
        ClearIntFlagsxSP   <= '0';
481
        InFIFOEmptyFlgxSP  <= '0';
482
        InFIFOFullFlgxSP   <= '0';
483
        OutFIFOEmptyFlgxSP <= '0';
484
        OutFIFOFullFlgxSP  <= '0';
485
        IEInFIFOEmptyxSP   <= '0';
486
        IEInFIFOFullxSP    <= '0';
487
        IEOutFIFOEmptyxSP  <= '0';
488
        IEOutFIFOFullxSP   <= '0';
489
        IEDmaErrxSP        <= '0';
490
        IECoreDonexSP      <= '0';
491
        IRQxSP             <= '0';
492
        InFIFOEmptyThrxDP  <= (others => '0');
493
        InFIFOFullThrxDP   <= (others => '1');
494
        OutFIFOEmptyThrxDP <= (others => '0');
495
        OutFIFOFullThrxDP  <= (others => '1');
496
        IncDestAdrFlgxSP   <= '0';
497
        DmaErrFlgxSP       <= '0';
498
        DmaBusyxSP         <= '0';
499
        DmaDestAdrxDP      <= (others => '0');
500
        XferByteCntxDP     <= 0;
501
        DmaLenxDP          <= 0;
502
        DmaDataOutxDP      <= (others => '0');
503
        DmaSelxSP          <= (others => '0');
504
        MaCycxSP           <= '0';
505
        MaStbxSP           <= '0';
506
      else
507
        RstCorexSP         <= RstCorexSN;
508
        FlushxSP           <= FlushxSN;
509
        FlushCorexSP       <= FlushCorexSN;
510
        ClearIntFlagsxSP   <= ClearIntFlagsxSN;
511
        InFIFOEmptyFlgxSP  <= InFIFOEmptyFlgxSN;
512
        InFIFOFullFlgxSP   <= InFIFOFullFlgxSN;
513
        OutFIFOEmptyFlgxSP <= OutFIFOEmptyFlgxSN;
514
        OutFIFOFullFlgxSP  <= OutFIFOFullFlgxSN;
515
        IEInFIFOEmptyxSP   <= IEInFIFOEmptyxSN;
516
        IEInFIFOFullxSP    <= IEInFIFOFullxSN;
517
        IEOutFIFOEmptyxSP  <= IEOutFIFOEmptyxSN;
518
        IEOutFIFOFullxSP   <= IEOutFIFOFullxSN;
519
        IEDmaErrxSP        <= IEDmaErrxSN;
520
        IECoreDonexSP      <= IECoreDonexSN;
521
        IRQxSP             <= IRQxSN;
522
        InFIFOEmptyThrxDP  <= InFIFOEmptyThrxDN;
523
        InFIFOFullThrxDP   <= InFIFOFullThrxDN;
524
        OutFIFOEmptyThrxDP <= OutFIFOEmptyThrxDN;
525
        OutFIFOFullThrxDP  <= OutFIFOFullThrxDN;
526
        IncDestAdrFlgxSP   <= IncDestAdrFlgxSN;
527
        DmaErrFlgxSP       <= DmaErrFlgxSN;
528
        DmaBusyxSP         <= DmaBusyxSP;
529
        DmaDestAdrxDP      <= DmaDestAdrxDN;
530
        XferByteCntxDP     <= XferByteCntxDN;
531
        DmaLenxDP          <= DmaLenxDN;
532
        DmaDataOutxDP      <= DmaDataOutxDN;
533
        DmaSelxSP          <= DmaSelxSN;
534
        MaCycxSP           <= MaCycxSN;
535
        MaStbxSP           <= MaStbxSN;
536
      end if;
537
 
538
    end if;
539
  end process;
540
 
541
 
542
  -- input data FIFO buffer
543
  InputFIFOInst : InputFIFO
544
    port map (
545
      ClkxCI        => ClkxCI,
546
      RstxRI        => RstCorexSP,
547
      DInxDI        => SlDatxDI,
548
      WExSI         => WeInFIFOxS,
549
      StopOutputxSI => CoreBusyxS,
550
      BusyxSO       => FIFOBusyxS,
551
      DOutxDO       => CoreDatInxD,
552
      OutStrobexSO  => CoreStbxS,
553
      LengthxDO     => InFIFOLenxD);
554
 
555
 
556
  LZRWcompressorInst : LZRWcompressor
557
    port map (
558
      ClkxCI         => ClkxCI,
559
      RstxRI         => RstCorexSP,
560
      DataInxDI      => CoreDatInxD,
561
      StrobexSI      => CoreStbxS,
562
      FlushBufxSI    => FlushCorexSP,
563
      BusyxSO        => CoreBusyxS,
564
      DonexSO        => CoreDonexS,
565
      BufOutxDO      => CoreDatOutxD,
566
      OutputValidxSO => CoreOutValidxS,
567
      RdStrobexSI    => CoreRdStbxS,
568
      LengthxDO      => OutFIFOLenxD);
569
 
570
end Behavioral;
571
 

powered by: WebSVN 2.1.0

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