1 |
2 |
yacinenet |
--=============================================================================
|
2 |
|
|
-- Project: basic Microprocessor(ZA208) http://za208.blogspot.com
|
3 |
|
|
-- Copyright: GNU General Public License version 3 (GPLv3) (http://www.gnu.org)(http://www.fsf.org/)
|
4 |
|
|
-- Author: Hadef Mohamed Yacine, Barkat Cherif
|
5 |
|
|
-- created : 14/04/2008
|
6 |
|
|
-- Revision: 26/05/2008 ; 29/05/2008
|
7 |
|
|
-- Last revised: 12/06/2008
|
8 |
|
|
-- Synthesis : synthesis and implement in 'Xilinx :"SPARTAN 3 VQ100"'
|
9 |
|
|
-- Workfile: upro.vhd ;; Workspace : PFE
|
10 |
|
|
-- University: Mentouri - Constantine
|
11 |
|
|
-------------------------------------------------------------------------------
|
12 |
|
|
-- Description:
|
13 |
|
|
-- Microprocessor with 28 instructions
|
14 |
|
|
-- (9 instructions of arithmitic and logic calculates)
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
--=============================================================================
|
18 |
|
|
|
19 |
|
|
library IEEE;
|
20 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
21 |
|
|
|
22 |
|
|
entity upro is
|
23 |
|
|
port (
|
24 |
|
|
data_in : in std_logic_vector (7 downto 0);
|
25 |
|
|
data_out : out std_logic_vector (7 downto 0);
|
26 |
|
|
addrs : out std_logic_vector (15 downto 0);
|
27 |
|
|
reset : in std_logic ;
|
28 |
|
|
wo : out std_logic ;
|
29 |
|
|
oe : out std_logic ;
|
30 |
|
|
clk : in std_logic ;
|
31 |
|
|
per_i : in std_logic ;
|
32 |
|
|
per_o : out std_logic
|
33 |
|
|
);
|
34 |
|
|
end upro;
|
35 |
|
|
|
36 |
|
|
architecture archi_upro of upro is
|
37 |
|
|
|
38 |
|
|
signal s_alu_in : std_logic_vector (7 downto 0) ;
|
39 |
|
|
signal s_alu_out : std_logic_vector (7 downto 0) ;
|
40 |
|
|
signal s_alu : std_logic_vector (3 downto 0) ;
|
41 |
|
|
signal s_adress8 : std_logic_vector (7 downto 0) ;
|
42 |
|
|
signal s_c_adress : std_logic_vector (1 downto 0) ;
|
43 |
|
|
signal s_comp_in : std_logic_vector (7 downto 0) ;
|
44 |
|
|
signal s_fonc_compar: std_logic_vector (1 downto 0);
|
45 |
|
|
signal s_c_adress1 : std_logic_vector (15 downto 0) ;
|
46 |
|
|
signal s_c_adress2 : std_logic_vector (15 downto 0) ;
|
47 |
|
|
signal s_data2ALU : std_logic_vector (7 downto 0) ;
|
48 |
|
|
signal s_reg_out : std_logic_vector (7 downto 0);
|
49 |
|
|
signal s_reg_f : std_logic_vector (4 downto 0) ;
|
50 |
|
|
signal s_out : std_logic_vector (1 downto 0) ;
|
51 |
|
|
signal s_d2compar : std_logic_vector (7 downto 0) ;
|
52 |
|
|
signal s_incr : std_logic ;
|
53 |
|
|
signal s_compar : std_logic ;
|
54 |
|
|
signal s_cc_adres : std_logic ;
|
55 |
|
|
signal s_carry : std_logic ;
|
56 |
|
|
signal s_overf : std_logic ;
|
57 |
|
|
signal s_inALU : std_logic ;
|
58 |
|
|
signal s_c_in_compar : std_logic ;
|
59 |
|
|
signal s_c_out_PC : std_logic ;
|
60 |
|
|
signal s_lock_pc : std_logic ;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
component FA_8bits
|
64 |
|
|
port (
|
65 |
|
|
clk : in std_logic ;
|
66 |
|
|
selec : in std_logic_vector (3 downto 0);
|
67 |
|
|
FA_in1 : in std_logic_vector (7 downto 0);
|
68 |
|
|
FA_in2 : in std_logic_vector (7 downto 0);
|
69 |
|
|
FA_out : out std_logic_vector (7 downto 0);
|
70 |
|
|
carry : out std_logic ;
|
71 |
|
|
overf : out std_logic
|
72 |
|
|
);
|
73 |
|
|
end component ;
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
component adress_data
|
77 |
|
|
port(
|
78 |
|
|
ctrl_adress : in std_logic_vector (1 downto 0);
|
79 |
|
|
adress_8 : in std_logic_vector (7 downto 0);
|
80 |
|
|
adress_16 : out std_logic_vector (15 downto 0)
|
81 |
|
|
);
|
82 |
|
|
end component ;
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
component pc_adress
|
86 |
|
|
port (
|
87 |
|
|
pc_inc : in std_logic ;
|
88 |
|
|
reset : in std_logic ;
|
89 |
|
|
adress : out std_logic_vector (15 downto 0);
|
90 |
|
|
adress_16_in : in std_logic_vector (15 downto 0);
|
91 |
|
|
ctrl_adress_pc : in std_logic ;
|
92 |
|
|
ctrl_adress_out : in std_logic ;
|
93 |
|
|
ret_adress_out : out std_logic_vector (15 downto 0);
|
94 |
|
|
lock_pc : in std_logic
|
95 |
|
|
);
|
96 |
|
|
|
97 |
|
|
end component ;
|
98 |
|
|
|
99 |
|
|
component ctrl
|
100 |
|
|
port (
|
101 |
|
|
clk : in std_logic ;
|
102 |
|
|
data_in : in std_logic_vector (7 downto 0);
|
103 |
|
|
reset : in std_logic ;
|
104 |
|
|
d_compar2ctrl : in std_logic ;
|
105 |
|
|
wo : out std_logic ;
|
106 |
|
|
oe : out std_logic ;
|
107 |
|
|
pc_inc : out std_logic ;
|
108 |
|
|
d_ctrl2compar : out std_logic_vector (7 downto 0);
|
109 |
|
|
selec_fonc_compar: out std_logic_vector (1 downto 0);
|
110 |
|
|
adress_in : in std_logic_vector (15 downto 0);
|
111 |
|
|
ctrl_alu : out std_logic_vector (3 downto 0);
|
112 |
|
|
ctrl_adress : out std_logic_vector (1 downto 0);
|
113 |
|
|
adress_8 : out std_logic_vector (7 downto 0);
|
114 |
|
|
d_ALU2ctrl : in std_logic_vector (7 downto 0);
|
115 |
|
|
d_ctrl2ALU : out std_logic_vector (7 downto 0);
|
116 |
|
|
c_adress_out : out std_logic ;
|
117 |
|
|
carry_flag : in std_logic ;
|
118 |
|
|
ovf_flag : in std_logic ;
|
119 |
|
|
c_inALU : out std_logic ;
|
120 |
|
|
data_flag : out std_logic_vector (4 downto 0);
|
121 |
|
|
selec_data_out : out std_logic_vector (1 downto 0);
|
122 |
|
|
out_data : out std_logic_vector (7 downto 0);
|
123 |
|
|
c_inCompar : out std_logic ;
|
124 |
|
|
c_AdressOut2 : out std_logic ;
|
125 |
|
|
p2ctrl : in std_logic ;
|
126 |
|
|
ctrl2p : out std_logic ;
|
127 |
|
|
lock_ctrl2pc : out std_logic
|
128 |
|
|
);
|
129 |
|
|
end component ;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
component compar
|
133 |
|
|
port (
|
134 |
|
|
d_in1 : in std_logic_vector (8 downto 1);
|
135 |
|
|
d_in2 : in std_logic_vector (8 downto 1);
|
136 |
|
|
selec_f : in std_logic_vector (1 downto 0);
|
137 |
|
|
clk : in std_logic ;
|
138 |
|
|
d_out : out std_logic
|
139 |
|
|
);
|
140 |
|
|
end component ;
|
141 |
|
|
|
142 |
|
|
begin
|
143 |
|
|
|
144 |
|
|
upro_a : entity work.FA_8bits(archi_FA_8bits)
|
145 |
|
|
port map (clk,s_alu,s_data2ALU,s_alu_in,s_alu_out,s_carry,s_overf);
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
upro_b : entity work.adress_data(archi_adress_data)
|
149 |
|
|
port map (s_c_adress,s_adress8,s_c_adress1);
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
upro_c : entity work.pc_adress(archi_pc_adress)
|
153 |
|
|
port map (s_incr,reset,addrs,s_c_adress1,s_cc_adres,s_c_out_PC,s_c_adress2,s_lock_pc);
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
upro_d : entity work.ctrl(archi_ctrl)
|
157 |
|
|
port map (clk,data_in,reset,s_compar,wo,oe,s_incr,s_comp_in,
|
158 |
|
|
s_fonc_compar,s_c_adress2,s_alu,s_c_adress,
|
159 |
|
|
s_adress8,s_alu_out,s_alu_in,s_cc_adres,s_carry,s_overf,
|
160 |
|
|
s_inALU,s_reg_f,s_out,s_reg_out,s_c_in_compar,s_c_out_PC,per_i,per_o,s_lock_pc);
|
161 |
|
|
|
162 |
|
|
upro_e : entity work.compar(archi_compar)
|
163 |
|
|
port map (s_d2compar,s_comp_in,s_fonc_compar,clk,s_compar);
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
process (clk,s_inALU,s_c_in_compar,s_out,s_reg_out,s_reg_f)
|
168 |
|
|
begin
|
169 |
|
|
|
170 |
|
|
if rising_edge(CLK) then
|
171 |
|
|
if s_inALU='1'then
|
172 |
|
|
s_data2ALU <= data_in ;
|
173 |
|
|
end if ;
|
174 |
|
|
end if ;
|
175 |
|
|
|
176 |
|
|
if rising_edge(CLK) then
|
177 |
|
|
if s_c_in_compar='1'then
|
178 |
|
|
s_d2compar <= data_in ;
|
179 |
|
|
end if ;
|
180 |
|
|
end if ;
|
181 |
|
|
|
182 |
|
|
case s_out is
|
183 |
|
|
when "01"=>
|
184 |
|
|
data_out <=s_reg_out ;
|
185 |
|
|
when "10"=>
|
186 |
|
|
data_out <= "000"&s_reg_f ;
|
187 |
|
|
when others =>
|
188 |
|
|
end case ;
|
189 |
|
|
|
190 |
|
|
end process ;
|
191 |
|
|
|
192 |
|
|
end archi_upro;
|