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

Subversion Repositories distributed_intelligence

[/] [distributed_intelligence/] [trunk/] [SRC/] [mini_uP_x16.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 leoel
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:  Léo Germond
4
-- 
5
-- Create Date:    16:00:40 11/08/2009 
6
-- Design Name: 
7
-- Module Name:    mini_uP_x16 - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.NUMERIC_STD.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
use work.ALU_INT.all;
26
 
27
---- Uncomment the following library declaration if instantiating
28
---- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity mini_uP_x16 is
33
    Port ( Code : in  STD_LOGIC_VECTOR (15 downto 0);
34
           PC : out  STD_LOGIC_VECTOR (15 downto 0);
35
           SR : out  STD_LOGIC_VECTOR (15 downto 0);
36
           MemBuffer : inout  STD_LOGIC_VECTOR (15 downto 0);
37
           MemAddress : out  STD_LOGIC_VECTOR (15 downto 0);
38
           MemState : in  STD_LOGIC_VECTOR (7 downto 0);
39
           clk : in  STD_LOGIC;
40
           reset : in  STD_LOGIC;
41
           sleep : in  STD_LOGIC;
42
           prev_uP : in  STD_LOGIC_VECTOR (7 downto 0);
43
           next_uP : out  STD_LOGIC_VECTOR (7 downto 0));
44
end mini_uP_x16;
45
 
46
architecture Behavioral of mini_uP_x16 is
47 5 leoel
        -- Data bus
48 4 leoel
        signal dataBus1, dataBus2: std_logic_vector(15 downto 0); -- For ALU data1 and data2
49
        signal mainDataBus: std_logic_vector(15 downto 0);
50
 
51 5 leoel
        -- ALU signals (driven by both the ALU and the identifier)
52
        signal accumulator: std_logic_vector(15 downto 0);
53
        signal ALUoverflow: std_logic;
54 4 leoel
        signal opCode:  ALU_OPCODE;
55 5 leoel
 
56
        -- Control signals (driven by the controler)
57 4 leoel
        signal register_control:  std_logic_vector(7 downto 0); -- re1 we1 re2 we2 re3 we3 re4 we4
58 6 leoel
        signal stack_control :  std_logic_vector(1 downto 0); --push pop
59 4 leoel
        signal PC_control :  std_logic;
60
        signal inc_PC:  std_logic;
61
 
62 5 leoel
        -- Id signal (driven by the identifier)
63 4 leoel
        signal uP_id: std_logic_vector(7 downto 0);
64
 
65 5 leoel
        -- Watchdog (driven by both the watchdog and the controler)
66 4 leoel
        signal watchdog_left: std_logic_vector(15 downto 0);
67
        signal watchdog_rst_value: std_logic_vector(15 downto 0);
68
        signal watchdog_rst: std_logic;
69
        signal watchdog_control : std_logic_vector(1 downto 0);
70
 
71
 
72
        component decoder_controler_x16
73
                port (  clk: in std_logic;
74
                                        reset: in std_logic;
75
                                        code: in std_logic_vector(15 downto 0);
76
                                        opCode: out ALU_OPCODE;
77
                                        register_control: out std_logic_vector(7 downto 0); -- re1 we1 re2 we2 re3 we3 re4 we4
78 6 leoel
                                        stack_control : out std_logic_vector(1 downto 0); -- push pop
79 4 leoel
                                        PC_control : out std_logic;
80
                                        inc_PC: out std_logic;
81
                                        watchdog_reset: out std_logic;
82 6 leoel
                                        watchdog_control: out std_logic_vector(1 downto 0) -- re(reset_value) we(left)
83 4 leoel
                                        );
84
        end component;
85
 
86
        component binary_counter_x16
87
                port (  clk: in std_logic;
88
                                        set: in std_logic;
89
                                        set_value: in std_logic_vector(15 downto 0);
90
                                        inc: in std_logic;
91
                                        count: out std_logic_vector(15 downto 0));
92
 
93
        end component;
94
 
95
        component watchdog_identifier_x16
96
                port (  clk     : in std_logic;
97
                                        reset   : in std_logic;
98
                                        prevId: in std_logic_vector(7 downto 0);
99
                                        myId    : out std_logic_vector(7 downto 0);
100
 
101
                                        watchdog_left: out std_logic_vector(15 downto 0);
102
                                        watchdog_rst_value: in std_logic_vector(15 downto 0);
103
                                        watchdog_rst: in std_logic);
104
        end component;
105
 
106
        component bus_access_x16
107 7 leoel
                port (  en      : in std_logic;
108 4 leoel
                                        dataWrite: out std_logic_vector(15 downto 0);
109
                                        dataRead : in std_logic_vector(15 downto 0));
110
        end component;
111
 
112
        component bus_register_x16
113
                port (  clk: in std_logic;
114
                                        re: in std_logic; -- read enable
115
                                        we: in std_logic; -- write enable
116
                                        reset: in std_logic;
117
                                        dataport: inout std_logic_vector(15 downto 0));
118
        end component;
119
 
120
        component stack_x16
121
                generic ( STACK_SIZE : natural);
122
                port (  clk: in std_logic;
123
                                        reset: in std_logic;
124
                                        dataPort: inout std_logic_vector(15 downto 0);
125
                                        push: in std_logic;
126
                                        pop: in std_logic);
127
        end component;
128
 
129
        component ALU
130
   Port ( data1 : in  STD_LOGIC_VECTOR (15 downto 0);
131
          data2 : in  STD_LOGIC_VECTOR (15 downto 0);
132
          dataA : out  STD_LOGIC_VECTOR (15 downto 0);
133
          op : in  ALU_OPCODE;
134
                         overflow: out STD_LOGIC );
135
        end component;
136
begin
137 5 leoel
        -- The program counter
138 4 leoel
        program_counter: binary_counter_x16
139
                port map(       clk => clk,
140
                                                set => PC_control,
141
                                                inc => inc_PC,
142
                                                set_value => mainDataBus,
143
                                                count => PC);
144
 
145 5 leoel
        -- The watchdog and its access to the main databus
146 4 leoel
        watchdog_re: bus_access_x16
147 7 leoel
                port map (      en      => watchdog_control(1),
148 4 leoel
                                                dataRead => mainDataBus,
149
                                                dataWrite => watchdog_rst_value);
150
 
151
        watchdog_we: bus_access_x16
152 7 leoel
                port map (      en      => watchdog_control(0),
153 4 leoel
                                                dataRead => watchdog_left,
154
                                                dataWrite => mainDataBus);
155
 
156
        watchdog_id: watchdog_identifier_x16
157
                port map(       clk => clk,
158
                                                reset   => reset,
159
                                                prevId => prev_uP,
160
                                                myId => uP_id,
161
 
162
                                                watchdog_left => watchdog_left,
163
                                                watchdog_rst_value => watchdog_rst_value,
164
                                                watchdog_rst => watchdog_rst);
165 5 leoel
 
166
        -- The stack
167 4 leoel
        stack: stack_x16
168
                generic map( STACK_SIZE => 8)
169
                port map(       clk => clk,
170
                                                reset => reset,
171
                                                dataPort => mainDataBus,
172
                                                push => stack_control(1),
173
                                                pop => stack_control(0));
174
 
175
        -- The 4 Registers
176
        R1: bus_register_x16
177 5 leoel
                port map (      clk=>clk ,
178
                                                re=>register_control(0),
179
                                                we=>register_control(1),
180
                                                reset=>reset,
181
                                                dataport=> mainDataBus);
182 4 leoel
 
183
        R2: bus_register_x16
184 5 leoel
                port map (      clk=>clk ,
185
                                                re=>register_control(2),
186
                                                we=>register_control(3),
187
                                                reset=>reset,
188
                                                dataport=> mainDataBus);
189 4 leoel
 
190
        R3: bus_register_x16
191 5 leoel
                port map (      clk=>clk ,
192
                                                re=>register_control(4),
193
                                                we=>register_control(5),
194
                                                reset=>reset,
195
                                                dataport=> mainDataBus);
196 4 leoel
 
197
        R4: bus_register_x16
198 5 leoel
                port map (      clk=>clk ,
199
                                                re=>register_control(6),
200
                                                we=>register_control(7),
201
                                                reset=>reset,
202
                                                dataport=> mainDataBus);
203 4 leoel
 
204
        -- The ALU                                                      
205 7 leoel
        arith_logic_unit : ALU
206 5 leoel
                port map(       data1 => dataBus1,
207
                                                data2 => dataBus2,
208
                                                dataA => accumulator,
209
                                                op => opCode,
210
                                                overflow => ALUoverflow);
211 6 leoel
 
212
        -- Controler
213
        controler : decoder_controler_x16
214
                port map(       clk=> clk,
215
                                                reset=>  reset,
216
                                                code=>  code,
217
                                                opCode=>  opCode,
218
                                                register_control=> register_control, -- re1 we1 re2 we2 re3 we3 re4 we4
219
                                                stack_control => stack_control, -- push pop
220
                                                PC_control =>  PC_control,
221
                                                inc_PC=> inc_PC,
222
                                                watchdog_reset=> watchdog_rst,
223
                                                watchdog_control=> watchdog_control  -- re(reset_value) we(left)
224
                                                );
225 4 leoel
end Behavioral;
226
 

powered by: WebSVN 2.1.0

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