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

Subversion Repositories microprocessor

[/] [microprocessor/] [trunk/] [bench/] [VHDL/] [Controle.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 yacinenet
-------------------------------------------------------------------------------
2
-- Control Unit
3
-- 
4
-- 
5
-------------------------------------------------------------------------------
6
 
7
library IEEE;
8
 
9
use IEEE.STD_LOGIC_1164.all;
10
 
11
entity ctrl is
12
        port (
13
        clk :              in std_logic ;
14
        data_in :          in std_logic_vector (7 downto 0);
15
        reset :            in std_logic ;
16
        d_compar2ctrl :    in std_logic ;
17
    wo :               out std_logic ;
18
    oe :               out std_logic ;
19
        pc_inc :           out std_logic ;
20
        d_ctrl2compar :    out std_logic_vector (7 downto 0);
21
        selec_fonc_compar: out std_logic_vector (1 downto 0);
22
        adress_in :        in std_logic_vector (15 downto 0);
23
        ctrl_alu :         out std_logic_vector (3 downto 0);
24
        ctrl_adress :      out std_logic_vector (1 downto 0);
25
        adress_8 :         out std_logic_vector (7 downto 0);
26
        d_ALU2ctrl :       in std_logic_vector (7 downto 0);
27
        d_ctrl2ALU :       out std_logic_vector (7 downto 0);
28
        c_adress_out :     out std_logic ;
29
        carry_flag :       in std_logic ;
30
        ovf_flag :                 in std_logic ;
31
        c_inALU    :       out std_logic ;
32
        data_flag :        out std_logic_vector (4 downto 0);
33
        selec_data_out :   out std_logic_vector (1 downto 0);
34
        out_data  :        out std_logic_vector (7 downto 0);
35
        c_inCompar   :     out std_logic ;
36
        c_AdressOut2 :     out std_logic ;
37
        p2ctrl :           in std_logic ;
38
        ctrl2p :               out std_logic ;
39
        lock_ctrl2pc :     out std_logic
40
               );
41
end ctrl ;
42
 
43
architecture archi_ctrl  of ctrl  is
44
 
45
signal c_reg_resu1 :  std_logic_vector (2 downto 0);
46
signal reg1 :         std_logic_vector (7 downto 0);
47
signal reg2:          std_logic_vector (7 downto 0);
48
signal reg_flag :     std_logic_vector (4 downto 0);
49
signal s_flag2FSM :   std_logic_vector (4 downto 0);
50
signal s_flag_compar: std_logic ;
51
signal s_addres_out : std_logic ;
52
signal s_inALU :      std_logic ;
53
signal s_data_out :   std_logic ;
54
signal s_flag_out  :  std_logic ;
55
signal s_compar :     std_logic ;
56
 
57
 
58
component FSM
59
        port (
60
        clk :              in std_logic ;
61
        d_in_FSM :         in std_logic_vector (7 downto 0);
62
        reset :            in std_logic ;
63
        compar2FSM :       in std_logic ;
64
    wo :               out std_logic ;
65
    oe :               out std_logic ;
66
        pc_inc :           out std_logic ;
67
        data2compar :      out std_logic_vector (7 downto 0);
68
        selec_fonc_compar: out std_logic_vector (1 downto 0);
69
        selec_reg_resu1 :  out std_logic_vector (2 downto 0);
70
        adress_in :        in std_logic_vector (15 downto 0);
71
        ctrl_alu :         out std_logic_vector (3 downto 0);
72
        ctrl_adress :      out std_logic_vector (1 downto 0);
73
        adress_8 :         out std_logic_vector (7 downto 0);
74
        c_data_out :       out std_logic ;
75
        c_adress_out :     out std_logic ;
76
        s_flag_out :       out std_logic ;
77
        c_inALU :              out std_logic ;
78
        resu_compar :      out std_logic ;
79
        reg_resu2 :        in std_logic_vector (7 downto 0);
80
        c_in_compar :      out std_logic ;
81
        c_adress2_out :    out std_logic ;
82
        reg_flag2FSM :     in std_logic_vector (4 downto 0);
83
        p2fsm :            in std_logic ;
84
        fsm2p :            out std_logic ;
85
        lock_fsm2pc :      out std_logic
86
              );
87
end component;
88
 
89
 
90
 
91
begin
92
 
93
FSM_state : entity work.FSM(archi_FSM)
94
        port map (clk,data_in,reset,d_compar2ctrl,wo,oe,pc_inc,
95
        d_ctrl2compar,selec_fonc_compar,c_reg_resu1,
96
        adress_in,ctrl_alu,ctrl_adress,adress_8,
97
        s_data_out,s_addres_out,s_flag_out,
98
        s_inALU,s_flag_compar,reg1,s_compar,
99
        c_AdressOut2,s_flag2FSM,p2ctrl,ctrl2p,lock_ctrl2pc);
100
 
101
        c_inALU<=s_inALU ;
102
        d_ctrl2ALU<=reg1 ;
103
        c_inCompar<=s_compar ;
104
        c_adress_out<=s_addres_out ;
105
 
106
reg_flag(0) <= (not reg1(0))and (not reg1(1))and (not reg1(2))and (not reg1(3))and (not reg1(4))and (not reg1(5))and (not reg1(6))and (not reg1(7));   -- zero flag
107
reg_flag(1) <= (((((((reg1(0)xor reg1(1))xor reg1(2))xor reg1(3))xor reg1(4))xor reg1(5))xor reg1(6))xor reg1(7));       -- parity flag
108
reg_flag(2) <= carry_flag ;        -- carry flag
109
reg_flag(3) <= ovf_flag ;      -- overflow flag 
110
reg_flag(4) <= s_flag_compar ; -- comparison flag 
111
 
112
data_flag<=reg_flag ;
113
selec_data_out<= s_flag_out & s_data_out ;
114
s_flag2FSM<=reg_flag ;
115
 
116
process (reset,clk)
117
begin
118
 
119
if reset ='1' then
120
  reg1<="00000000" ;
121
  out_data<="00000000" ;
122
  reg2<="00000000" ;
123
else
124
  if rising_edge(clk) then
125
    case c_reg_resu1 is
126
          when "000"=>
127
          reg2 <= reg1 ;                                    -- result. out
128
          out_data <= reg2 ;
129
          when "001"=>
130
          reg2<='0'&reg1(7 downto 1);        -- shift right with 0       
131
          when "010"=>
132
          reg2<='1'&reg1(7 downto 1);       -- shift right with 1
133
          when "011"=>
134
          reg2<=reg1(6 downto 0)&'0';         -- shift left with 0
135
          when "100"=>
136
      reg2<=reg1(6 downto 0)&'1';            -- shift left with 1
137
          when "101"=>
138
          reg2<=reg1(0)&reg1(7 downto 1);        -- rot right
139
          out_data <= reg2 ;
140
          when "110"=>
141
          reg2<=reg1(6 downto 0)&reg1(7);        -- rot left 
142
          out_data <= reg2 ;
143
          when "111"=>
144
          reg1<=d_ALU2ctrl ;
145
          when others =>
146
    end case ;
147
  end if ;
148
end if ;
149
 
150
end process ;
151
 
152
end archi_ctrl ;
153
 

powered by: WebSVN 2.1.0

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