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

Subversion Repositories g729a_codec

[/] [g729a_codec/] [trunk/] [VHDL/] [G729A_asip_lcstk.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2013 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
---------------------------------------------------------------
29
-- G.729a ASIP loop control stack
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
 
36
library WORK;
37
use WORK.G729A_ASIP_PKG.all;
38
 
39
entity G729A_ASIP_LCSTK is
40
  generic(
41
    DEPTH : natural
42
  );
43
  port(
44
    CLK_i : in std_logic;
45
    RST_i : in std_logic;
46
    SRST_i : in std_logic;
47
    PUSH_i : in std_logic;
48
    POP_i : in std_logic;
49
    DECR_i : in std_logic;
50
    LBADR_i : in unsigned(ALEN-1 downto 0); -- loop begin address
51
    LEADR_i : in unsigned(ALEN-1 downto 0); -- loop end address
52
    LCNT_i : in unsigned(16-1 downto 0); -- loop count
53
 
54
    SE_o : out std_logic;
55
    SF_o : out std_logic;
56
    LBADR_o : out unsigned(ALEN-1 downto 0); -- loop begin address
57
    LEADR_o : out unsigned(ALEN-1 downto 0); -- loop end address
58
    LCNT_o : out unsigned(16-1 downto 0) -- loop count
59
  );
60
end G729A_ASIP_LCSTK;
61
 
62
architecture ARC of G729A_ASIP_LCSTK is
63
 
64
  type STK_ENTRY_T is record
65
    LBADR : unsigned(ALEN-1 downto 0);
66
    LEADR : unsigned(ALEN-1 downto 0);
67
    LCNT : unsigned(16-1 downto 0);
68
  end record;
69
 
70
  type LPSTK_T is array (DEPTH-1 downto 0) of STK_ENTRY_T;
71
  signal LPSTK_q : LPSTK_T;
72
  signal TOS_q : integer range 0 to DEPTH;
73
  signal TOSM1_q : integer range 0 to DEPTH;
74
  signal SE,SF : std_logic;
75
 
76
begin
77
 
78
  -- TOS register (points to bottommost empty entry)
79
  process(CLK_i)
80
  begin
81
    if(CLK_i = '1' and CLK_i'event) then
82
      if(RST_i = '1' or SRST_i = '1') then
83
        TOS_q <= 0;
84
      elsif(POP_i = '1' and SE = '0') then
85
        TOS_q <= TOS_q - 1;
86
      elsif(PUSH_i = '1' and SF = '0') then
87
        TOS_q <= TOS_q + 1;
88
      end if;
89
    end if;
90
  end process;
91
 
92
  -- TOS-1 register
93
  process(CLK_i)
94
  begin
95
    if(CLK_i = '1' and CLK_i'event) then
96
      if(RST_i = '1' or SRST_i = '1' or (POP_i = '1' and TOS_q  < 2)) then
97
        TOSM1_q <= 0;
98
      elsif(POP_i = '1' and SE = '0') then
99
        TOSM1_q <= TOS_q - 2;
100
      elsif(PUSH_i = '1' and SF = '0') then
101
        TOSM1_q <= TOS_q;
102
      end if;
103
    end if;
104
  end process;
105
 
106
  -- Stack Empty flag
107
  SE <= '1' when TOS_q = 0 else '0';
108
 
109
  -- Stack Full flag
110
  SF <= '1' when TOS_q = DEPTH else '0';
111
 
112
  -- Stack data registers
113
 
114
  process(CLK_i)
115
    variable TMP : STK_ENTRY_T;
116
  begin
117
    if(CLK_i = '1' and CLK_i'event) then
118
      if(PUSH_i = '1') then
119
        LPSTK_q(TOS_q) <= (LBADR_i,LEADR_i,LCNT_i);
120
      elsif(DECR_i = '1') then
121
        TMP := LPSTK_q(TOSM1_q);
122
        LPSTK_q(TOSM1_q) <= (TMP.LBADR,TMP.LEADR,(TMP.LCNT - 1));
123
      end if;
124
    end if;
125
  end process;
126
 
127
  -- Outputs
128
 
129
  process(LPSTK_q,TOSM1_q)
130
  begin
131
    LBADR_o <= LPSTK_q(TOSM1_q).LBADR;
132
    LEADR_o <= LPSTK_q(TOSM1_q).LEADR;
133
    LCNT_o <= LPSTK_q(TOSM1_q).LCNT;
134
  end process;
135
 
136
  SE_o <= SE;
137
 
138
  SF_o <= SF;
139
 
140
end ARC;

powered by: WebSVN 2.1.0

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