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 4

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
        signal dataBus1, dataBus2: std_logic_vector(15 downto 0); -- For ALU data1 and data2
48
        signal accumulator: std_logic_vector(15 downto 0);
49
        signal mainDataBus: std_logic_vector(15 downto 0);
50
 
51
        signal opCode:  ALU_OPCODE;
52
        signal register_control:  std_logic_vector(7 downto 0); -- re1 we1 re2 we2 re3 we3 re4 we4
53
        signal stack_control :  std_logic_vector(1 downto 0); -- en push/pop
54
        signal PC_control :  std_logic;
55
        signal inc_PC:  std_logic;
56
 
57
        signal uP_id: std_logic_vector(7 downto 0);
58
 
59
 
60
        signal watchdog_left: std_logic_vector(15 downto 0);
61
        signal watchdog_rst_value: std_logic_vector(15 downto 0);
62
        signal watchdog_rst: std_logic;
63
        signal watchdog_control : std_logic_vector(1 downto 0);
64
 
65
 
66
        component decoder_controler_x16
67
                port (  clk: in std_logic;
68
                                        reset: in std_logic;
69
                                        code: in std_logic_vector(15 downto 0);
70
                                        opCode: out ALU_OPCODE;
71
                                        register_control: out std_logic_vector(7 downto 0); -- re1 we1 re2 we2 re3 we3 re4 we4
72
                                        stack_control : out std_logic_vector(1 downto 0); -- en push/pop
73
                                        PC_control : out std_logic;
74
                                        inc_PC: out std_logic;
75
                                        watchdog_reset: out std_logic;
76
                                        watchdog_control: out std_logic -- re we
77
                                        );
78
        end component;
79
 
80
        component binary_counter_x16
81
                port (  clk: in std_logic;
82
                                        set: in std_logic;
83
                                        set_value: in std_logic_vector(15 downto 0);
84
                                        inc: in std_logic;
85
                                        count: out std_logic_vector(15 downto 0));
86
 
87
        end component;
88
 
89
        component watchdog_identifier_x16
90
                port (  clk     : in std_logic;
91
                                        reset   : in std_logic;
92
                                        prevId: in std_logic_vector(7 downto 0);
93
                                        myId    : out std_logic_vector(7 downto 0);
94
 
95
                                        watchdog_left: out std_logic_vector(15 downto 0);
96
                                        watchdog_rst_value: in std_logic_vector(15 downto 0);
97
                                        watchdog_rst: in std_logic);
98
        end component;
99
 
100
        component bus_access_x16
101
                port (  clk: in std_logic;
102
                                        en      : in std_logic;
103
                                        dataWrite: out std_logic_vector(15 downto 0);
104
                                        dataRead : in std_logic_vector(15 downto 0));
105
        end component;
106
 
107
        component bus_register_x16
108
                port (  clk: in std_logic;
109
                                        re: in std_logic; -- read enable
110
                                        we: in std_logic; -- write enable
111
                                        reset: in std_logic;
112
                                        dataport: inout std_logic_vector(15 downto 0));
113
        end component;
114
 
115
        component stack_x16
116
                generic ( STACK_SIZE : natural);
117
                port (  clk: in std_logic;
118
                                        reset: in std_logic;
119
                                        dataPort: inout std_logic_vector(15 downto 0);
120
                                        push: in std_logic;
121
                                        pop: in std_logic);
122
        end component;
123
 
124
        component ALU
125
   Port ( data1 : in  STD_LOGIC_VECTOR (15 downto 0);
126
          data2 : in  STD_LOGIC_VECTOR (15 downto 0);
127
          dataA : out  STD_LOGIC_VECTOR (15 downto 0);
128
          op : in  ALU_OPCODE;
129
                         overflow: out STD_LOGIC );
130
        end component;
131
begin
132
        program_counter: binary_counter_x16
133
                port map(       clk => clk,
134
                                                set => PC_control,
135
                                                inc => inc_PC,
136
                                                set_value => mainDataBus,
137
                                                count => PC);
138
 
139
        watchdog_re: bus_access_x16
140
                port map (      clk => clk,
141
                                                en      => watchdog_control(1),
142
                                                dataRead => mainDataBus,
143
                                                dataWrite => watchdog_rst_value);
144
 
145
        watchdog_we: bus_access_x16
146
                port map (      clk => clk,
147
                                                en      => watchdog_control(0),
148
                                                dataRead => watchdog_left,
149
                                                dataWrite => mainDataBus);
150
 
151
        watchdog_id: watchdog_identifier_x16
152
                port map(       clk => clk,
153
                                                reset   => reset,
154
                                                prevId => prev_uP,
155
                                                myId => uP_id,
156
 
157
                                                watchdog_left => watchdog_left,
158
                                                watchdog_rst_value => watchdog_rst_value,
159
                                                watchdog_rst => watchdog_rst);
160
        stack: stack_x16
161
                generic map( STACK_SIZE => 8)
162
                port map(       clk => clk,
163
                                                reset => reset,
164
                                                dataPort => mainDataBus,
165
                                                push => stack_control(1),
166
                                                pop => stack_control(0));
167
 
168
        -- The 4 Registers
169
        R1: bus_register_x16
170
                port (  clk=>clk ,
171
                                        re=>register_control(0),
172
                                        we=>register_control(1),
173
                                        reset=>reset,
174
                                        dataport=> mainDataBus);
175
 
176
        R2: bus_register_x16
177
                port (  clk=>clk ,
178
                                        re=>register_control(2),
179
                                        we=>register_control(3),
180
                                        reset=>reset,
181
                                        dataport=> mainDataBus);
182
 
183
        R3: bus_register_x16
184
                port (  clk=>clk ,
185
                                        re=>register_control(4),
186
                                        we=>register_control(5),
187
                                        reset=>reset,
188
                                        dataport=> mainDataBus);
189
 
190
        R4: bus_register_x16
191
                port (  clk=>clk ,
192
                                        re=>register_control(6),
193
                                        we=>register_control(7),
194
                                        reset=>reset,
195
                                        dataport=> mainDataBus);
196
 
197
        -- The ALU                                                      
198
        alu : ALU
199
        port(           data1 => dataBus1;
200
                                data2 => dataBus2;
201
                                dataA => accumulator;
202
                                op => op;
203
                                overflow => overflow);
204
 
205
end Behavioral;
206
 

powered by: WebSVN 2.1.0

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