1 |
2 |
ameziti |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
--
|
4 |
|
|
-- File: cp_ProgramCounter.vhd
|
5 |
|
|
--
|
6 |
|
|
-- Description:
|
7 |
|
|
-- projet copyblaze
|
8 |
|
|
-- Program Counter management
|
9 |
|
|
--
|
10 |
|
|
-- File history:
|
11 |
|
|
-- v1.0: 04/10/11: Creation
|
12 |
|
|
-- v1.1: 12/10/11: Modification du traitement des conditions de saut
|
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_ProgramCounter
|
26 |
|
|
--
|
27 |
|
|
-- Description:
|
28 |
|
|
--
|
29 |
|
|
-- REMARQUE:
|
30 |
|
|
--
|
31 |
|
|
--
|
32 |
|
|
-- History:
|
33 |
|
|
-- 04/10/11 AM: Creation
|
34 |
|
|
-- ---------------------
|
35 |
|
|
-- xx/xx/xx AM:
|
36 |
|
|
--
|
37 |
|
|
--------------------------------------------------------------------------------
|
38 |
|
|
entity cp_ProgramCounter is
|
39 |
|
|
generic
|
40 |
|
|
(
|
41 |
|
|
GEN_WIDTH_PC : positive := 8
|
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 |
|
|
Enable_i : in std_ulogic;
|
51 |
|
|
--------------------------------------------------------------------------------
|
52 |
|
|
-- Signaux Fonctionels
|
53 |
|
|
--------------------------------------------------------------------------------
|
54 |
|
|
PC_i : in std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
|
55 |
|
|
Change_i : in std_ulogic;
|
56 |
|
|
|
57 |
|
|
PC_o : out std_ulogic_vector(GEN_WIDTH_PC-1 downto 0)
|
58 |
|
|
);
|
59 |
|
|
end cp_ProgramCounter;
|
60 |
|
|
|
61 |
|
|
--------------------------------------------------------------------------------
|
62 |
|
|
-- Architecture: RTL
|
63 |
|
|
-- of entity : cp_ProgramCounter
|
64 |
|
|
--------------------------------------------------------------------------------
|
65 |
|
|
architecture rtl of cp_ProgramCounter is
|
66 |
|
|
|
67 |
|
|
--------------------------------------------------------------------------------
|
68 |
|
|
-- Définition des fonctions
|
69 |
|
|
--------------------------------------------------------------------------------
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
--------------------------------------------------------------------------------
|
73 |
|
|
-- Définition des constantes
|
74 |
|
|
--------------------------------------------------------------------------------
|
75 |
|
|
|
76 |
|
|
--------------------------------------------------------------------------------
|
77 |
|
|
-- Définition des signaux interne
|
78 |
|
|
--------------------------------------------------------------------------------
|
79 |
|
|
signal iPC : std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
|
80 |
|
|
signal iPcNext : std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
|
81 |
|
|
|
82 |
|
|
--------------------------------------------------------------------------------
|
83 |
|
|
-- Déclaration des composants
|
84 |
|
|
--------------------------------------------------------------------------------
|
85 |
|
|
|
86 |
|
|
begin
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
iPcNext <= (PC_i) when ( Change_i = '1' ) else
|
90 |
|
|
std_ulogic_vector(UNSIGNED(iPC) + 1);
|
91 |
|
|
|
92 |
|
|
--------------------------------------------------------------------------------
|
93 |
|
|
-- Process : PC_Proc
|
94 |
|
|
-- Description:
|
95 |
|
|
--------------------------------------------------------------------------------
|
96 |
|
|
PC_Proc : process(Rst_i_n, Clk_i)
|
97 |
|
|
begin
|
98 |
|
|
if ( Rst_i_n = '0' ) then
|
99 |
|
|
iPC <= (others=>'0');
|
100 |
|
|
elsif ( rising_edge(Clk_i) ) then
|
101 |
|
|
if (Enable_i = '1') then
|
102 |
|
|
iPC <= iPcNext;
|
103 |
|
|
end if;
|
104 |
|
|
end if;
|
105 |
|
|
end process PC_Proc;
|
106 |
|
|
|
107 |
|
|
PC_o <= iPC;
|
108 |
|
|
|
109 |
|
|
end rtl;
|
110 |
|
|
|