This repository was archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackPointer.vhd
More file actions
54 lines (46 loc) · 1.77 KB
/
StackPointer.vhd
File metadata and controls
54 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--------------------------------------------------------------------------------
-- Team: Tyler Heucke & Matt Hennes
--
-- Create Date: 14:07:52 10/14/2014
-- Module Name: StackPointer - Behavioral
-- Project Name: RAT MCU
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity StackPointer is
Port ( SP_LD : in STD_LOGIC;
RST : in STD_LOGIC;
SP_MUX_SEL : in STD_LOGIC_VECTOR (1 downto 0);
MULTI_BUS : in STD_LOGIC_VECTOR (7 downto 0);
SP_OUT_DECREMENT : in STD_LOGIC_VECTOR (7 downto 0);
SP_OUT_INCREMENT : in STD_LOGIC_VECTOR (7 downto 0);
CLK : in STD_LOGIC;
SP_OUT : out STD_LOGIC_VECTOR (7 downto 0));
end StackPointer;
architecture Behavioral of StackPointer is
signal pointer_in : STD_LOGIC_VECTOR(7 downto 0);
signal pointer_out : STD_LOGIC_VECTOR(7 downto 0);
begin
multiplexer : process( SP_MUX_SEL, MULTI_BUS, SP_OUT_DECREMENT, SP_OUT_INCREMENT )
begin
case( SP_MUX_SEL ) is
when "00" => pointer_in <= MULTI_BUS;
when "10" => pointer_in <= SP_OUT_DECREMENT;
when "11" => pointer_in <= SP_OUT_INCREMENT;
when others => pointer_in <= "00000000";
end case ;
end process ; -- multiplexer
instructions : process( pointer_in, SP_LD, RST, CLK, pointer_out )
begin
if (RST = '0') then
if (SP_LD = '1') then
if (rising_edge(CLK)) then
SP_OUT <= pointer_in;
end if;
end if;
else
SP_OUT <= "00000000";
end if ;
end process; -- instructions
end Behavioral;