Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------------------
- -- Company: CPE 233
- -- Engineer: Zach Bunce, Kaioli Bessert, and Garrett Maxon
- --
- -- Create Date: 02/11/2017 03:59:55 PM
- -- Design Name: Stack Pointer
- -- Module Name: SP - Counter
- -- Project Name: Experiment 8 - Get 'er Done
- -- Description: 8-bit Stack Pointer which either loads in a value, increments or
- -- decrements the previous pointer value, or resets the pointer to 0 based off of the
- -- CPU control lines.
- ---------------------------------------------------------------------------------------
- LIBRARY IEEE;
- USE IEEE.STD_LOGIC_1164.ALL;
- USE IEEE.STD_LOGIC_ARITH.ALL;
- USE IEEE.STD_LOGIC_UNSIGNED.ALL;
- ENTITY SP is
- PORT (
- RST : in STD_LOGIC;
- LD : in STD_LOGIC;
- INCR : in STD_LOGIC;
- DECR : in STD_LOGIC;
- D_IN : in STD_LOGIC_VECTOR (7 downto 0);
- CLK : in STD_LOGIC;
- D_OUT : out STD_LOGIC_VECTOR (7 downto 0)
- );
- END SP;
- ARCHITECTURE Counter of SP is
- -- Sets up a intermediary wire to allow for incrementation.
- SIGNAL D_TEMP : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
- BEGIN
- -- Links the temporary data wire to the output line.
- D_OUT <= D_TEMP;
- -- Determines the pointer value based off of the control lines.
- countProc: PROCESS(D_IN, LD, INCR, DECR, RST, CLK)
- BEGIN
- if(rising_edge(CLK)) then
- -- Resets the pointer to 0x00 when the reset line is high.
- if (RST = '1') then
- D_TEMP <= x"00";
- -- Sets the output to the input when the load line is high.
- elsif (LD = '1') then
- D_TEMP <= D_IN;
- -- Increments the output by one when the increment line is high.
- elsif (INCR = '1') then
- D_TEMP <= (D_TEMP + 1);
- -- Decrements the output by one when the decrement line is high.
- elsif (DECR = '1') then
- D_TEMP <= (D_TEMP - 1);
- -- Otherwise, holds the output.
- else
- D_TEMP <= D_TEMP;
- end if;
- end if;
- END PROCESS countProc;
- END Counter;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement