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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [cpu/] [cp_Stack.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: cp_Stack.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      Program Counter stack
9
--
10
-- File history:
11
-- v1.0: 07/10/11: Creation
12
--
13
-- Targeted device: ProAsic A3P250 VQFP100
14
-- Author: AbdAllah Meziti
15
--------------------------------------------------------------------------------
16
 
17
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.numeric_std.all;
20
 
21
use     work.Usefull_Pkg.all;           -- Usefull Package
22
 
23
--------------------------------------------------------------------------------
24
-- Entity: cp_Stack
25
--
26
-- Description:
27
--      
28
--      REMARQUE:
29
--
30
--      
31
-- History:
32
-- 07/10/11 AM: Creation
33
-- ---------------------
34
-- xx/xx/xx AM: 
35
--                              
36
--------------------------------------------------------------------------------
37
entity cp_Stack is
38
        generic
39
        (
40
                GEN_WIDTH_PC            : positive := 8;
41
                GEN_DETPH                       : positive := 15
42
        );
43
        port (
44
        --------------------------------------------------------------------------------
45
        -- Signaux Systeme
46
        --------------------------------------------------------------------------------
47
                Clk_i                           : in std_ulogic;        --      signal d'horloge générale
48
                Rst_i_n                         : in std_ulogic;        --      signal de reset générale
49
 
50
        --------------------------------------------------------------------------------
51
        -- Signaux Fonctionels
52
        --------------------------------------------------------------------------------
53
                Data_i                          : in std_ulogic_vector(GEN_WIDTH_PC-1 downto 0); -- 
54
                Data_o                          : out std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);        -- 
55
 
56
                Enable_i                        : in std_ulogic;
57
 
58
                Push_i                          : in std_ulogic;
59
                Pop_i                           : in std_ulogic
60
        );
61
end cp_Stack;
62
 
63
--------------------------------------------------------------------------------
64
-- Architecture: RTL
65
-- of entity : cp_Stack
66
--------------------------------------------------------------------------------
67
architecture rtl of cp_Stack is
68
 
69
        --------------------------------------------------------------------------------
70
        -- Définition des fonctions
71
        --------------------------------------------------------------------------------
72
 
73
 
74
 
75
        --------------------------------------------------------------------------------
76
        -- Définition des constantes
77
        --------------------------------------------------------------------------------
78
 
79
        --------------------------------------------------------------------------------
80
        -- Définition des signaux interne
81
        --------------------------------------------------------------------------------
82
        type RAM_TYPE is array (0 to GEN_DETPH-1) of std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);--(Data_i'range);
83
 
84
        signal iStackMem        : RAM_TYPE;
85
        signal iStackEn         : std_ulogic;
86
 
87
        signal iPointer         : natural range 0 to GEN_DETPH-1;
88
        signal iPtrUp           : std_ulogic;
89
        signal iPtrDown         : std_ulogic;
90
 
91
        signal iTempo           : std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
92
 
93
        --------------------------------------------------------------------------------
94
        -- Déclaration des composants
95
        --------------------------------------------------------------------------------
96
 
97
begin
98
 
99
        iStackEn        <= not(Enable_i) and Push_i;
100
        --------------------------------------------------------------------------------
101
        -- Process : Stack_Proc
102
        -- Description: Stack Memory
103
        --------------------------------------------------------------------------------
104
        Stack_Proc : process(Rst_i_n, Clk_i)
105
        begin
106
                if ( Rst_i_n = '0' ) then
107
                        for i in 0 to GEN_DETPH-1 loop
108
                                iStackMem(i)    <= (others=>'0');
109
                        end loop;
110
                        iTempo                          <= (others=>'0');
111
                elsif ( rising_edge(Clk_i) ) then
112
                        if ( iPtrUp = '1' ) then
113
                                iTempo  <=      Data_i;
114
                        end if;
115
                        if ( iStackEn = '1' ) then
116
                                iStackMem( iPointer )   <= iTempo;
117
                        end if;
118
                end if;
119
        end process Stack_Proc;
120
 
121
 
122
        iPtrUp          <= Enable_i and Push_i;
123
        iPtrDown        <= Enable_i and Pop_i;
124
        --------------------------------------------------------------------------------
125
        -- Process : Ptr_Proc
126
        -- Description: Stack pointer
127
        --------------------------------------------------------------------------------
128
        Ptr_Proc : process(Rst_i_n, Clk_i)
129
        begin
130
                if ( Rst_i_n = '0' ) then
131
                        iPointer                <=      GEN_DETPH-1;
132
 
133
                elsif ( rising_edge(Clk_i) ) then
134
                        if ( iPtrUp = '1' ) then
135
                                if ( iPointer + 1 = GEN_DETPH ) then
136
                                        iPointer        <= 0;
137
                                else
138
                                        iPointer        <=      (iPointer + 1) ;
139
                                end if;
140
                        end if;
141
 
142
                        if ( iPtrDown = '1' ) then
143
                                if ( iPointer = 0 ) then
144
                                        iPointer        <= GEN_DETPH-1;
145
                                else
146
                                        iPointer        <=      (iPointer - 1) ;
147
                                end if;
148
 
149
                        end if;
150
 
151
                end if;
152
        end process Ptr_Proc;
153
 
154
        Data_o  <=      iStackMem( iPointer );
155
 
156
end rtl;
157
 

powered by: WebSVN 2.1.0

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