Advertisement
wojtas626

[VHDL] processor

Jan 27th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.53 KB | None | 0 0
  1. entity proc is
  2.     port(PAM_PROG_ADR : out std_logic_vector(31 downto 0);
  3.          PAM_PROG_DANE : in std_logic_vector(31 downto 0);
  4.          PAM_DAN_ADR1 : out std_logic_vector(31 downto 0);
  5.          PAM_DAN_DANE1 : in std_logic_vector(31 downto 0);
  6.          PAM_DAN_ADR2 : out std_logic_vector(31 downto 0);
  7.          PAM_DAN_DANE2 : out std_logic_vector(31 downto 0);
  8.          CLK : in std_logic;
  9.          RESET : in std_logic;
  10.          ZAPIS_PAM : out std_logic);
  11. end proc;
  12. architecture arch_proc of proc is
  13.     signal CYKL : std_logic_vector(1 downto 0);
  14.     signal LICZNIK_ROZKAZOW, REJ_ROZKAZOW, REJ_ARG, A, B, C : std_logic_vector(31 downto 0);
  15.     begin
  16.         process(CLK, RESET)
  17.         begin
  18.             if (RESET='1') then
  19.                 PAM_PROG_ADR <= (others => '0');
  20.                 PAM_DAN_ADR1 <= (others => '0');
  21.                 PAM_DAN_ADR2 <= (others => '0');
  22.                 PAM_DAN_DANE2 <= (others => '0');
  23.                 ZAPIS_PAM <= '0';
  24.                 LICZNIK_ROZKAZOW <= (others => '0');
  25.             elsif (CLK'event and CLK='1') then
  26.                 CYKL <= CYKL + 1;
  27.                 ZAPIS_PAM <= '0';
  28.                 if (CYKL = 0) then 
  29.                     REJ_ROZKAZOW <= PAM_PROG_DANE;
  30.                 else
  31.                     if (REJ_ROZKAZOW = 1) then      // PAM->A
  32.                         if (CYKL = 1) then
  33.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  34.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  35.                         elsif (CYKL = 2) then
  36.                             REJ_ARG <= PAM_PROG_DANE;
  37.                         else
  38.                             A <= PAM_DAN_DANE1;
  39.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  40.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  41.                             CYKL <= (others => '0');
  42.                         end if;
  43.                     elsif (REJ_ROZKAZOW = 2) then   // PAM->B
  44.                         if (CYKL = 1) then
  45.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  46.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  47.                         elsif (CYKL = 2) then
  48.                             REJ_ARG <= PAM_PROG_DANE;
  49.                         else
  50.                             B <= PAM_DAN_DANE1;
  51.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  52.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  53.                             CYKL <= (others => '0');
  54.                         end if;
  55.                     elsif (REJ_ROZKAZOW = 3) then   // C->PAM      
  56.                         if (CYKL = 1) then
  57.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  58.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  59.                         elsif (CYKL = 2) then
  60.                             REJ_ARG <= PAM_PROG_DANE;
  61.                         elsif (CYKL = 3)
  62.                             PAM_DAN_ADR2 <= REJ_ARG;
  63.                             PAM_DAN_DANE2 <= C;
  64.                         else
  65.                             ZAPIS_PAM <= '1';
  66.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  67.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  68.                             CYKL <= (others => '0');
  69.                         end if;
  70.                     elsif (REJ_ROZKAZOW = 4) then   // SKOK BEZWARUNKOWY
  71.                         if (CYKL = 1) then
  72.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  73.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  74.                         elsif (CYKL = 2) then
  75.                             REJ_ARG <= PAM_PROG_DANE;
  76.                         else
  77.                             PAM_PROG_ADR <= REJ_ARG;
  78.                             LICZNIK_ROZKAZOW <= REJ_ARG;
  79.                             CYKL <= (others => '0');
  80.                         end if;
  81.                     elsif (REJ_ROZKAZOW = 5) then   // SKOK WARUNKOWY
  82.                         if (CYKL = 1) then
  83.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  84.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  85.                         elsif (CYKL = 2) then
  86.                             REJ_ARG <= PAM_PROG_DANE;
  87.                         else
  88.                             if (C = 0) then
  89.                                 PAM_PROG_ADR <= REJ_ARG;
  90.                                 LICZNIK_ROZKAZOW <= REJ_ARG;
  91.                             else
  92.                                 PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  93.                                 LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  94.                             end if;
  95.                             CYKL <= (others => '0');
  96.                         end if;
  97.                     elsif (REJ_ROZKAZOW = 6) then   // OR
  98.                         if (CYKL = 1) then
  99.                             C <= A or B; // C <= A and B // C <= not A // C <= A + B
  100.                             PAM_PROG_ADR <= LICZNIK_ROZKAZOW + 1;
  101.                             LICZNIK_ROZKAZOW <= LICZNIK_ROZKAZOW + 1;
  102.                             CYKL <= (others => '0');
  103.                         end if;
  104.                     end if;
  105.                 end if;
  106.             end if;
  107.         end process;
  108.     end arch_proc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement