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 6

Go to most recent revision | 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
                port (  clk: in std_logic;
108
                                        en      : in std_logic;
109
                                        dataWrite: out std_logic_vector(15 downto 0);
110
                                        dataRead : in std_logic_vector(15 downto 0));
111
        end component;
112
 
113
        component bus_register_x16
114
                port (  clk: in std_logic;
115
                                        re: in std_logic; -- read enable
116
                                        we: in std_logic; -- write enable
117
                                        reset: in std_logic;
118
                                        dataport: inout std_logic_vector(15 downto 0));
119
        end component;
120
 
121
        component stack_x16
122
                generic ( STACK_SIZE : natural);
123
                port (  clk: in std_logic;
124
                                        reset: in std_logic;
125
                                        dataPort: inout std_logic_vector(15 downto 0);
126
                                        push: in std_logic;
127
                                        pop: in std_logic);
128
        end component;
129
 
130
        component ALU
131
   Port ( data1 : in  STD_LOGIC_VECTOR (15 downto 0);
132
          data2 : in  STD_LOGIC_VECTOR (15 downto 0);
133
          dataA : out  STD_LOGIC_VECTOR (15 downto 0);
134
          op : in  ALU_OPCODE;
135
                         overflow: out STD_LOGIC );
136
        end component;
137
begin
138 5 leoel
        -- The program counter
139 4 leoel
        program_counter: binary_counter_x16
140
                port map(       clk => clk,
141
                                                set => PC_control,
142
                                                inc => inc_PC,
143
                                                set_value => mainDataBus,
144
                                                count => PC);
145
 
146 5 leoel
        -- The watchdog and its access to the main databus
147 4 leoel
        watchdog_re: bus_access_x16
148
                port map (      clk => clk,
149
                                                en      => watchdog_control(1),
150
                                                dataRead => mainDataBus,
151
                                                dataWrite => watchdog_rst_value);
152
 
153
        watchdog_we: bus_access_x16
154
                port map (      clk => clk,
155
                                                en      => watchdog_control(0),
156
                                                dataRead => watchdog_left,
157
                                                dataWrite => mainDataBus);
158
 
159
        watchdog_id: watchdog_identifier_x16
160
                port map(       clk => clk,
161
                                                reset   => reset,
162
                                                prevId => prev_uP,
163
                                                myId => uP_id,
164
 
165
                                                watchdog_left => watchdog_left,
166
                                                watchdog_rst_value => watchdog_rst_value,
167
                                                watchdog_rst => watchdog_rst);
168 5 leoel
 
169
        -- The stack
170 4 leoel
        stack: stack_x16
171
                generic map( STACK_SIZE => 8)
172
                port map(       clk => clk,
173
                                                reset => reset,
174
                                                dataPort => mainDataBus,
175
                                                push => stack_control(1),
176
                                                pop => stack_control(0));
177
 
178
        -- The 4 Registers
179
        R1: bus_register_x16
180 5 leoel
                port map (      clk=>clk ,
181
                                                re=>register_control(0),
182
                                                we=>register_control(1),
183
                                                reset=>reset,
184
                                                dataport=> mainDataBus);
185 4 leoel
 
186
        R2: bus_register_x16
187 5 leoel
                port map (      clk=>clk ,
188
                                                re=>register_control(2),
189
                                                we=>register_control(3),
190
                                                reset=>reset,
191
                                                dataport=> mainDataBus);
192 4 leoel
 
193
        R3: bus_register_x16
194 5 leoel
                port map (      clk=>clk ,
195
                                                re=>register_control(4),
196
                                                we=>register_control(5),
197
                                                reset=>reset,
198
                                                dataport=> mainDataBus);
199 4 leoel
 
200
        R4: bus_register_x16
201 5 leoel
                port map (      clk=>clk ,
202
                                                re=>register_control(6),
203
                                                we=>register_control(7),
204
                                                reset=>reset,
205
                                                dataport=> mainDataBus);
206 4 leoel
 
207
        -- The ALU                                                      
208 5 leoel
        the_alu : ALU
209
                port map(       data1 => dataBus1,
210
                                                data2 => dataBus2,
211
                                                dataA => accumulator,
212
                                                op => opCode,
213
                                                overflow => ALUoverflow);
214 6 leoel
 
215
        -- Controler
216
        controler : decoder_controler_x16
217
                port map(       clk=> clk,
218
                                                reset=>  reset,
219
                                                code=>  code,
220
                                                opCode=>  opCode,
221
                                                register_control=> register_control, -- re1 we1 re2 we2 re3 we3 re4 we4
222
                                                stack_control => stack_control, -- push pop
223
                                                PC_control =>  PC_control,
224
                                                inc_PC=> inc_PC,
225
                                                watchdog_reset=> watchdog_rst,
226
                                                watchdog_control=> watchdog_control  -- re(reset_value) we(left)
227
                                                );
228 4 leoel
end Behavioral;
229
 

powered by: WebSVN 2.1.0

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