Advertisement
Guest User

Untitled

a guest
May 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.40 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_arith.all;
  4. use ieee.std_logic_unsigned.all;
  5.  
  6. entity calculator_core is port(
  7.     inc, sel, rst : in std_logic;
  8.     stageOut : out std_logic_vector(2 downto 0);
  9.     outputVal : out std_logic_vector(7 downto 0));
  10. end calculator_core;
  11.  
  12. architecture behavioral of calculator_core is
  13. signal temp : std_logic_vector (7 downto 0);
  14. signal mode : std_logic_vector (1 downto 0);
  15. shared variable operand : std_logic_vector (7 downto 0);
  16. signal operandtwo : std_logic_vector (7 downto 0);
  17. signal incflag : std_logic_vector(1 downto 0);
  18. begin
  19.     process(sel,rst,incflag)    -- process the opcode selection (sel button -- S3)
  20.     begin
  21.         if(sel'event and sel = '0') then
  22.             case mode(1 downto 0) is
  23.                 when "00" =>
  24.                     stageOut <= "001";
  25.                     mode <= "01";
  26.                 when "01" =>
  27.                     stageOut <= "010";
  28.                     mode <= "10";
  29.                 when "10" =>
  30.                     stageOut <= "011";
  31.                     mode <= "11";
  32.                 when "11" =>
  33.                     stageOut <= "000";
  34.                     mode <= "00";
  35.             end case;
  36.         end if;
  37.         -- reset the calc if rst is pressed
  38.         if(rst = '0') then
  39.             stageOut(2 downto 0) <= "000";
  40.             mode(1 downto 0) <= "00";
  41.             temp(7 downto 0) <= "00000000";
  42.             incflag(1 downto 0) <= "00";
  43.             operandtwo(7 downto 0) <= "00000000";
  44.         end if;
  45.         if(inc'event and inc = '0') then
  46.             operand := operand + 1;
  47.             outputVal <= operand;
  48.         end if;
  49.     end process;
  50.     -- outputVal <= temp;
  51. end behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement