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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [cpu/] [cp_Toggle.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_Toggle.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      Toggle horloge clock (divisor by 2)
9
--
10
-- File history:
11
-- v1.0: 07/10/11: Creation
12
-- v2.0: 25/10/11: Add Freeze Management
13
--
14
-- Targeted device: ProAsic A3P250 VQFP100
15
-- Author: AbdAllah Meziti
16
--------------------------------------------------------------------------------
17
 
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use ieee.numeric_std.all;
21
 
22
use     work.Usefull_Pkg.all;           -- Usefull Package
23
 
24
--------------------------------------------------------------------------------
25
-- Entity: cp_Toggle
26
--
27
-- Description:
28
--      
29
--      REMARQUE:
30
--
31
--      
32
-- History:
33
-- 07/10/11 AM: Creation
34
-- ---------------------
35
-- xx/xx/xx AM: 
36
--                              
37
--------------------------------------------------------------------------------
38
entity cp_Toggle is
39
        port (
40
        --------------------------------------------------------------------------------
41
        -- Signaux Systeme
42
        --------------------------------------------------------------------------------
43
                Clk_i                           : in std_ulogic;        --      signal d'horloge générale
44
                Rst_i_n                         : in std_ulogic;        --      signal de reset générale
45
 
46
        --------------------------------------------------------------------------------
47
        -- Signaux Fonctionels
48
        --------------------------------------------------------------------------------
49
                Freeze_i                        : in std_ulogic;
50
 
51
                Phase1_o                        : out std_ulogic;
52
                Phase2_o                        : out std_ulogic
53
        );
54
end cp_Toggle;
55
 
56
--------------------------------------------------------------------------------
57
-- Architecture: RTL
58
-- of entity : cp_Toggle
59
--------------------------------------------------------------------------------
60
architecture rtl of cp_Toggle is
61
 
62
        --------------------------------------------------------------------------------
63
        -- Définition des fonctions
64
        --------------------------------------------------------------------------------
65
        type States_TYPE is
66
        (
67
                S_NORMAL                ,       -- 
68
                S_FREEZE                        -- for external "Freeze processor" signal
69
        );
70
 
71
 
72
 
73
        --------------------------------------------------------------------------------
74
        -- Définition des constantes
75
        --------------------------------------------------------------------------------
76
 
77
        --------------------------------------------------------------------------------
78
        -- Définition des signaux interne
79
        --------------------------------------------------------------------------------
80
        signal  iFSM_State      : States_TYPE;                                                          -- Signal de la machine d'état
81
 
82
        signal  iPhase1         : std_ulogic;
83
        signal  iPhase2         : std_ulogic;
84
 
85
        signal  iPhase1Out      : std_ulogic;
86
        signal  iPhase2Out      : std_ulogic;
87
 
88
        --------------------------------------------------------------------------------
89
        -- Déclaration des composants
90
        --------------------------------------------------------------------------------
91
 
92
begin
93
 
94
        --------------------------------------------------------------------------------
95
        -- Process : Phase_Proc
96
        -- Description: generate the Phase1 and Phase2 of the processor
97
        --------------------------------------------------------------------------------
98
        Phase_Proc : process(Rst_i_n, Clk_i)
99
        begin
100
                if ( Rst_i_n = '0' ) then
101
                        iPhase1 <= '0';
102
                        iPhase2 <= '0';
103
 
104
                elsif ( rising_edge(Clk_i) ) then
105
                        iPhase1 <= not( iPhase1 );
106
                        iPhase2 <= iPhase1;
107
                end if;
108
        end process Phase_Proc;
109
 
110
 
111
        --------------------------------------------------------------------------------
112
        -- Process : Freeze_Proc
113
        -- Description: if Freeze_i signal is active, then the processor exectution is freezed (stoped)
114
        --------------------------------------------------------------------------------
115
        Freeze_Proc : process(Rst_i_n, Clk_i)
116
        begin
117
 
118
                if ( Rst_i_n = '0' ) then
119
                        iFSM_State              <=      S_NORMAL;
120
 
121
                elsif ( rising_edge(Clk_i) ) then
122
 
123
                                case iFSM_State is
124
                                        when S_NORMAL =>
125
                                                if ( ( iPhase2 = '1' ) and (Freeze_i = '1') ) then
126
                                                        iFSM_State      <=      S_FREEZE;
127
                                                end if;
128
 
129
                                        when S_FREEZE =>
130
                                                if ( ( iPhase2 = '1' ) and (Freeze_i = '0') ) then
131
                                                        iFSM_State      <=      S_NORMAL;
132
                                                end if;
133
 
134
                                end case;
135
 
136
                end if;
137
        end process Freeze_Proc;
138
 
139
        with iFSM_State select
140
                iPhase1Out      <=      iPhase1 when S_NORMAL,
141
                                                '0'              when S_FREEZE,  --      Phase 1 to 0
142
                                                '0'              when others;
143
        with iFSM_State select
144
                iPhase2Out      <=      iPhase2 when S_NORMAL,
145
                                                '0'              when S_FREEZE,  --      Phase 2 to 0
146
                                                '0'              when others;
147
 
148
 
149
        Phase1_o        <= iPhase1Out;
150
        Phase2_o        <= iPhase2Out;
151
 
152
end rtl;
153
 

powered by: WebSVN 2.1.0

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