1 |
2 |
ameziti |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
--
|
4 |
|
|
-- File: cp_copyBlaze_ecoSystem.vhd
|
5 |
|
|
--
|
6 |
|
|
-- Description:
|
7 |
|
|
-- projet copyblaze
|
8 |
|
|
-- copyBlaze processor + ROM => system
|
9 |
|
|
--
|
10 |
|
|
-- File history:
|
11 |
|
|
-- v1.0: 11/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_copyBlaze_ecoSystem
|
25 |
|
|
--
|
26 |
|
|
-- Description:
|
27 |
|
|
--
|
28 |
|
|
-- REMARQUE:
|
29 |
|
|
--
|
30 |
|
|
--
|
31 |
|
|
-- History:
|
32 |
|
|
-- 11/10/11 AM: Creation
|
33 |
|
|
-- ---------------------
|
34 |
|
|
-- xx/xx/xx AM:
|
35 |
|
|
--
|
36 |
|
|
--------------------------------------------------------------------------------
|
37 |
|
|
entity cp_copyBlaze_ecoSystem is
|
38 |
|
|
generic
|
39 |
|
|
(
|
40 |
|
|
GEN_WIDTH_DATA : positive := 8;
|
41 |
|
|
GEN_WIDTH_PC : positive := 10;
|
42 |
|
|
GEN_WIDTH_INST : positive := 18;
|
43 |
|
|
|
44 |
|
|
GEN_DEPTH_STACK : positive := 15; -- Taille (en octet) de la Stack
|
45 |
|
|
GEN_DEPTH_BANC : positive := 16; -- Taille (en octet) du Banc Register
|
46 |
|
|
GEN_DEPTH_SCRATCH : positive := 64; -- Taille (en octet) du Scratch Pad
|
47 |
|
|
|
48 |
|
|
GEN_INT_VECTOR : std_ulogic_vector(11 downto 0) := x"3FF"
|
49 |
|
|
);
|
50 |
|
|
Port (
|
51 |
|
|
--------------------------------------------------------------------------------
|
52 |
|
|
-- Signaux Systeme
|
53 |
|
|
--------------------------------------------------------------------------------
|
54 |
|
|
Clk_i : in std_ulogic;
|
55 |
|
|
--Rst_i_n : in std_ulogic;
|
56 |
|
|
|
57 |
|
|
--------------------------------------------------------------------------------
|
58 |
|
|
-- Signaux Fonctionels
|
59 |
|
|
--------------------------------------------------------------------------------
|
60 |
|
|
Interrupt_i : in std_ulogic;
|
61 |
|
|
Interrupt_Ack_o : out std_ulogic;
|
62 |
|
|
|
63 |
|
|
IN_PORT_i : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
64 |
|
|
OUT_PORT_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
65 |
|
|
PORT_ID_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
66 |
|
|
READ_STROBE_o : out std_ulogic;
|
67 |
|
|
WRITE_STROBE_o : out std_ulogic;
|
68 |
|
|
--------------------------------------------------------------------------------
|
69 |
|
|
-- Signaux WishBone
|
70 |
|
|
--------------------------------------------------------------------------------
|
71 |
|
|
Freeze_i : in std_ulogic;
|
72 |
|
|
|
73 |
|
|
--------------------------------------------------------------------------------
|
74 |
|
|
-- Signaux Wishbone Interface
|
75 |
|
|
--------------------------------------------------------------------------------
|
76 |
6 |
ameziti |
-- RST_I : in std_ulogic;
|
77 |
2 |
ameziti |
-- CLK_I : in std_ulogic;
|
78 |
|
|
|
79 |
|
|
ADR_O : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
80 |
|
|
DAT_I : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
81 |
|
|
DAT_O : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
82 |
|
|
WE_O : out std_ulogic;
|
83 |
|
|
SEL_O : out std_ulogic_vector(1 downto 0);
|
84 |
|
|
|
85 |
|
|
STB_O : out std_ulogic;
|
86 |
|
|
ACK_I : in std_ulogic;
|
87 |
6 |
ameziti |
CYC_O : out std_ulogic
|
88 |
2 |
ameziti |
);
|
89 |
|
|
end cp_copyBlaze_ecoSystem;
|
90 |
|
|
|
91 |
|
|
--------------------------------------------------------------------------------
|
92 |
|
|
-- Architecture: RTL
|
93 |
|
|
-- of entity : cp_copyBlaze_ecoSystem
|
94 |
|
|
--------------------------------------------------------------------------------
|
95 |
|
|
architecture rtl of cp_copyBlaze_ecoSystem is
|
96 |
|
|
|
97 |
|
|
--------------------------------------------------------------------------------
|
98 |
|
|
-- Définition des constantes
|
99 |
|
|
--------------------------------------------------------------------------------
|
100 |
|
|
constant RESET_LENGTH : positive := 7;
|
101 |
|
|
|
102 |
|
|
--------------------------------------------------------------------------------
|
103 |
|
|
-- Déclaration des composants
|
104 |
|
|
--------------------------------------------------------------------------------
|
105 |
|
|
component cp_copyBlaze
|
106 |
|
|
generic
|
107 |
|
|
(
|
108 |
|
|
GEN_WIDTH_DATA : positive := 8;
|
109 |
|
|
GEN_WIDTH_PC : positive := 10;
|
110 |
|
|
GEN_WIDTH_INST : positive := 18;
|
111 |
|
|
|
112 |
|
|
GEN_DEPTH_STACK : positive := 15; -- Taille (en octet) de la Stack
|
113 |
|
|
GEN_DEPTH_BANC : positive := 16; -- Taille (en octet) du Banc Register
|
114 |
|
|
GEN_DEPTH_SCRATCH : positive := 64; -- Taille (en octet) du Scratch Pad
|
115 |
|
|
|
116 |
|
|
GEN_INT_VECTOR : std_ulogic_vector(11 downto 0) := x"3FF" -- Interrupt Vector
|
117 |
|
|
);
|
118 |
|
|
port (
|
119 |
|
|
--------------------------------------------------------------------------------
|
120 |
|
|
-- Signaux Systeme
|
121 |
|
|
--------------------------------------------------------------------------------
|
122 |
|
|
Clk_i : in std_ulogic; -- signal d'horloge générale
|
123 |
|
|
Rst_i_n : in std_ulogic; -- signal de iReset générale
|
124 |
|
|
|
125 |
|
|
--------------------------------------------------------------------------------
|
126 |
|
|
-- Signaux Fonctionels
|
127 |
|
|
--------------------------------------------------------------------------------
|
128 |
|
|
Address_o : out std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
|
129 |
|
|
Instruction_i : in std_ulogic_vector(GEN_WIDTH_INST-1 downto 0);
|
130 |
|
|
|
131 |
|
|
Interrupt_i : in std_ulogic; --
|
132 |
|
|
Interrupt_Ack_o : out std_ulogic; --
|
133 |
|
|
|
134 |
|
|
IN_PORT_i : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0); --
|
135 |
|
|
OUT_PORT_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0); --
|
136 |
|
|
PORT_ID_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0); --
|
137 |
|
|
READ_STROBE_o : out std_ulogic;
|
138 |
|
|
WRITE_STROBE_o : out std_ulogic;
|
139 |
|
|
--------------------------------------------------------------------------------
|
140 |
|
|
-- Signaux Speciaux
|
141 |
|
|
--------------------------------------------------------------------------------
|
142 |
|
|
Freeze_i : in std_ulogic;
|
143 |
|
|
|
144 |
|
|
--------------------------------------------------------------------------------
|
145 |
|
|
-- Signaux Wishbone Interface
|
146 |
|
|
--------------------------------------------------------------------------------
|
147 |
6 |
ameziti |
--RST_I : in std_ulogic;
|
148 |
2 |
ameziti |
--CLK_I : in std_ulogic;
|
149 |
|
|
|
150 |
|
|
ADR_O : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
151 |
|
|
DAT_I : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
152 |
|
|
DAT_O : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
153 |
|
|
WE_O : out std_ulogic;
|
154 |
|
|
SEL_O : out std_ulogic_vector(1 downto 0);
|
155 |
|
|
|
156 |
|
|
STB_O : out std_ulogic;
|
157 |
|
|
ACK_I : in std_ulogic;
|
158 |
6 |
ameziti |
CYC_O : out std_ulogic
|
159 |
2 |
ameziti |
);
|
160 |
|
|
end component;
|
161 |
|
|
|
162 |
|
|
component cp_ROM_Code
|
163 |
|
|
generic
|
164 |
|
|
(
|
165 |
|
|
GEN_WIDTH_PC : positive := 10;
|
166 |
|
|
GEN_WIDTH_INST : positive := 18
|
167 |
|
|
);
|
168 |
|
|
port(
|
169 |
|
|
Clk_i : in std_ulogic;
|
170 |
|
|
Address_i : in std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
|
171 |
|
|
Dout_o : out std_ulogic_vector(GEN_WIDTH_INST-1 downto 0)
|
172 |
|
|
);
|
173 |
|
|
end component;
|
174 |
|
|
|
175 |
|
|
--------------------------------------------------------------------------------
|
176 |
|
|
-- Définition des signaux interne
|
177 |
|
|
--------------------------------------------------------------------------------
|
178 |
|
|
signal iAddress : std_ulogic_vector(9 downto 0);
|
179 |
|
|
signal iInstruction : std_ulogic_vector(17 downto 0);
|
180 |
|
|
|
181 |
|
|
signal iReset : std_ulogic := '0';
|
182 |
|
|
signal iReset_counter : natural range 0 to RESET_LENGTH := RESET_LENGTH; -- VERY BAD SOLUTION
|
183 |
|
|
|
184 |
|
|
begin
|
185 |
|
|
|
186 |
|
|
-- ************************** --
|
187 |
|
|
-- The copyBlaze CPU instance --
|
188 |
|
|
-- ************************** --
|
189 |
|
|
processor: cp_copyBlaze
|
190 |
|
|
generic map
|
191 |
|
|
(
|
192 |
|
|
GEN_WIDTH_DATA => GEN_WIDTH_DATA,
|
193 |
|
|
GEN_WIDTH_PC => GEN_WIDTH_PC,
|
194 |
|
|
GEN_WIDTH_INST => GEN_WIDTH_INST,
|
195 |
|
|
|
196 |
|
|
GEN_DEPTH_STACK => GEN_DEPTH_STACK,
|
197 |
|
|
GEN_DEPTH_BANC => GEN_DEPTH_BANC,
|
198 |
|
|
|
199 |
|
|
GEN_DEPTH_SCRATCH => GEN_DEPTH_SCRATCH,
|
200 |
|
|
GEN_INT_VECTOR => GEN_INT_VECTOR
|
201 |
|
|
)
|
202 |
|
|
port map(
|
203 |
|
|
--------------------------------------------------------------------------------
|
204 |
|
|
-- Signaux Systeme
|
205 |
|
|
--------------------------------------------------------------------------------
|
206 |
|
|
Clk_i => Clk_i,
|
207 |
|
|
Rst_i_n => iReset,
|
208 |
|
|
|
209 |
|
|
--------------------------------------------------------------------------------
|
210 |
|
|
-- Signaux Fonctionels
|
211 |
|
|
--------------------------------------------------------------------------------
|
212 |
|
|
Address_o => iAddress,
|
213 |
|
|
Instruction_i => iInstruction,
|
214 |
|
|
|
215 |
|
|
Interrupt_i => Interrupt_i,
|
216 |
|
|
Interrupt_Ack_o => Interrupt_Ack_o,
|
217 |
|
|
|
218 |
|
|
IN_PORT_i => IN_PORT_i,
|
219 |
|
|
OUT_PORT_o => OUT_PORT_o,
|
220 |
|
|
PORT_ID_o => PORT_ID_o,
|
221 |
|
|
READ_STROBE_o => READ_STROBE_o,
|
222 |
|
|
WRITE_STROBE_o => WRITE_STROBE_o,
|
223 |
|
|
--------------------------------------------------------------------------------
|
224 |
|
|
-- Signaux Speciaux
|
225 |
|
|
--------------------------------------------------------------------------------
|
226 |
|
|
Freeze_i => Freeze_i,
|
227 |
|
|
|
228 |
|
|
--------------------------------------------------------------------------------
|
229 |
|
|
-- Signaux Wishbone Interface
|
230 |
|
|
--------------------------------------------------------------------------------
|
231 |
6 |
ameziti |
--RST_I => RST_I,
|
232 |
2 |
ameziti |
--CLK_I => CLK_I,
|
233 |
|
|
|
234 |
|
|
ADR_O => ADR_O,
|
235 |
|
|
DAT_I => DAT_I,
|
236 |
|
|
DAT_O => DAT_O,
|
237 |
|
|
WE_O => WE_O,
|
238 |
|
|
SEL_O => SEL_O,
|
239 |
|
|
|
240 |
|
|
STB_O => STB_O,
|
241 |
|
|
ACK_I => ACK_I,
|
242 |
6 |
ameziti |
CYC_O => CYC_O
|
243 |
2 |
ameziti |
);
|
244 |
|
|
|
245 |
|
|
-- *************** --
|
246 |
|
|
-- ROM code memory --
|
247 |
|
|
-- *************** --
|
248 |
|
|
program : cp_ROM_Code
|
249 |
|
|
generic map
|
250 |
|
|
(
|
251 |
|
|
GEN_WIDTH_PC => GEN_WIDTH_PC,
|
252 |
|
|
GEN_WIDTH_INST => GEN_WIDTH_INST
|
253 |
|
|
)
|
254 |
|
|
port map
|
255 |
|
|
(
|
256 |
|
|
Clk_i => Clk_i,
|
257 |
|
|
Address_i => iAddress,
|
258 |
|
|
Dout_o => iInstruction
|
259 |
|
|
);
|
260 |
|
|
|
261 |
|
|
--------------------------------------------------------------------------------
|
262 |
|
|
-- Process : ProcessorReset_Proc
|
263 |
|
|
-- Description: Generate the reset of the processor
|
264 |
|
|
--------------------------------------------------------------------------------
|
265 |
|
|
ProcessorReset_Proc : process(Clk_i)
|
266 |
|
|
begin
|
267 |
|
|
if ( rising_edge(Clk_i) ) then
|
268 |
|
|
if ( iReset_counter = 0 ) then
|
269 |
|
|
iReset <= '1';
|
270 |
|
|
else
|
271 |
|
|
iReset <= '0';
|
272 |
|
|
iReset_counter <= iReset_counter - 1;
|
273 |
|
|
end if;
|
274 |
|
|
end if;
|
275 |
|
|
end process ProcessorReset_Proc;
|
276 |
|
|
|
277 |
|
|
end rtl;
|