Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.28 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  4. use IEEE.NUMERIC_STD.ALL;
  5.  
  6. entity Processor is
  7.  port (
  8.     clk: in std_logic;
  9.    SBB: in std_logic_vector( 3 downto 0);
  10.     SBC: in std_logic_vector( 3 downto 0);
  11.     SBA: in std_logic_vector( 3 downto 0);
  12.     SA: in std_logic_vector(1 downto 0);
  13.     Sid: inout std_logic_vector(1 downto 0)
  14.    );
  15. end Processor;
  16.  
  17. architecture Behavioral of Processor is
  18.     signal IR,TMP,A,B,C,D,E,F,ADh,ADl,DI: std_logic_vector(15 downto 0);
  19.     signal PC,SP, ATMP: std_logic_vector(31 downto 0);
  20.     signal Y, BB, BC : std_logic_vector(15 downto 0); --ALU
  21.     signal A2: std_logic_vector(31 downto 0);
  22.     signal hex_out1,hex_out2:std_logic_vector(6 downto 0);
  23. begin
  24.  
  25. process(SBA,IR,Y, TMP, A,B,C,D,E,F,ADh,ADl,PC,SP,ATMP)
  26. begin
  27.     case(SBA) is
  28.      when "0000" => IR <= Y;
  29.      when "0001" => TMP <= Y;
  30.      when "0010" => A <= Y;
  31.      when "0011" => B <= Y;
  32.      when "0100" => C <= Y;
  33.      when "0101" => D <= Y;
  34.      when "0110" => E <= Y;
  35.      when "0111" => F <= Y;
  36.      when "1000" => ADh <=Y;
  37.      when "1001" => ADl <= Y;
  38.      when "1010" => PC(31 downto 16) <= Y;
  39.      when "1011" => SP(31 downto 16) <= Y;
  40.      when others => ATMP(31 downto 16) <= Y;
  41.     end case;
  42. end process;
  43.  
  44. process(SBB,IR,BB,DI,TMP,hex_out1, A,B,C,D,E,F,ADh,ADl,PC,SP,ATMP)
  45. begin
  46.     case SBB is
  47.      when "0000" => BB <= DI;
  48.                          hex_out1 <= "0000001";
  49.      when "0001" => BB <= IR;
  50.                          hex_out1 <= "1001111";
  51.      when "0010" => BB <= TMP;
  52.                          hex_out1 <= "0010010";
  53.      when "0011" => BB <= A;
  54.                          hex_out1 <= "0000010";
  55.      when "0100" => BB <= B;
  56.                          hex_out1 <= "1100000";
  57.      when "0101" => BB <= C;
  58.                          hex_out1 <= "0110001";
  59.      when "0110" => BB <= D;
  60.                          hex_out1 <= "1000010";
  61.      when "0111" => BB <= E;
  62.                          hex_out1 <= "0110000";
  63.      when "1000" => BB <= F;
  64.                          hex_out1 <= "0111000";
  65.      when "1001" => BB <= ADh;
  66.                          hex_out1 <= "0000110";
  67.      when "1010" => BB <= ADl;
  68.                          hex_out1 <= "1001100";
  69.      when "1011" => BB <= PC(31 downto 16);
  70.                          hex_out1 <= "0100100";
  71.      when "1100" => BB <= PC(15 downto 0);
  72.                          hex_out1 <= "0100100";
  73.      when "1101" => BB <= SP(31 downto 16);
  74.                          hex_out1 <= "0100000";
  75.      when "1110" => BB <= SP(15 downto 0);
  76.                          hex_out1 <= "0100000";
  77.      when "1111" => BB <= ATMP(31 downto 16);
  78.                         hex_out1 <= "0100000";
  79.    
  80.     end case;
  81. end process;
  82.  
  83. process(SBC,IR,BC,DI, TMP, A,B,C,D,E,F,ADh,ADl,PC,SP,ATMP)
  84. begin
  85.     case SBC is
  86.      when "0000" => BC <= DI;
  87.      when "0001" => BC <= IR;
  88.      when "0010" => BC <= TMP;
  89.      when "0011" => BC <= A;
  90.      when "0100" => BC <= B;
  91.      when "0101" => BC <= C;
  92.      when "0110" => BC <= D;
  93.      when "0111" => BC <= E;
  94.      when "1000" => BC <= F;
  95.      when "1001" => BC <= ADh;
  96.      when "1010" => BC <= ADl;
  97.      when "1011" => BC <= PC(31 downto 16);
  98.      when "1100" => BC <= PC(15 downto 0);
  99.      when "1101" => BC <= SP(31 downto 16);
  100.      when "1110" => BC <= SP(15 downto 0);
  101.      when "1111" => BC <= ATMP(31 downto 16);
  102.     end case;
  103. end process;
  104.  
  105. process(SA,A2,ADh,ADl,PC,SP,ATMP,hex_out2)
  106. begin
  107.     case SA is
  108.      when "00" => A2(31 downto 16) <= ADh;
  109.                       A2(15 downto 0) <= ADl;
  110.                       hex_out2 <= "0000110";
  111.      when "01" => A2<= PC;
  112.                       hex_out2 <= "0100100";
  113.      when "10" => A2<= SP;
  114.                       hex_out2 <= "0100000";
  115.      when "11" => A2<= ATMP;
  116.                       hex_out2 <= "0100000";
  117.     end case;
  118. end process;
  119.  
  120. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement