Advertisement
gunigma

Kolos Piątek 2

Jan 7th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.39 KB | None | 0 0
  1. entity kolos is
  2.     Port ( DATA_A : in STD_LOGIC;
  3.            DATA_B : in STD_LOGIC;
  4.            CLK_A : in STD_LOGIC;
  5.            CLK_B : in STD_LOGIC;
  6.            FIRST_A : in STD_LOGIC;
  7.            FIRST_B : in STD_LOGIC;
  8.            DATA_C : out STD_LOGIC_VECTOR (7 downto 0);
  9.            CLK_C : out STD_LOGIC);
  10. end kolos;
  11.  
  12. architecture Behavioral of kolos is
  13.     signal BUF_A: STD_LOGIC_VECTOR(3 downto 0);
  14.     signal BUF_B: std_logic_vector(3 downto 0);
  15.     signal BUF: std_logic_vector(7 downto 0);
  16.    
  17.     READ_A : process(CLK_A)
  18.         variable temp : std_logic_vector(7 downto 0);
  19.         variable indeks : INTEGER := 0 ;
  20.    
  21.          begin  
  22.             if falling_edge(CLK_A) then
  23.                 if FIRST_A = '1' then
  24.                     indeks=0;
  25.                 end if
  26.                 if indeks < 8 then
  27.                     temp(indeks) := DATA_A;
  28.                 end if
  29.                 indeks := indeks +1
  30.                 if indeks = 8 then  -- czyli jak dostaliśmy właśnie ostatni bit
  31.                     BUF_A <= temp(1)&temp(0)&temp(2)&temp(3);
  32.                 end if
  33.             end if
  34.     end process;
  35.  
  36.     READ_B : process(CLK_B)
  37.         variable temp: std_logic_vector(7 downto 0);
  38.         variable indeks: INTEGER := 0;
  39.    
  40.         begin  
  41.             if falling_edge(CLK_B) then
  42.                 if FIRST_B = '1' then
  43.                     indeks:=0;
  44.                 end if
  45.                 if indeks <8 then
  46.                     temp(indeks) := DATA_B;
  47.                 end if
  48.                 indeks := indeks +1
  49.                 if indeks = 8 then  -- czyli jak dostaliśmy właśnie ostatni bit
  50.                     BUF_B <= temp(0)&temp(1)&temp(7)&temp(3);
  51.                 end if
  52.             end if
  53.     end process
  54.  
  55.     BUF <= BUF_A && BUF_B
  56.  
  57.     WRITE : process(CLK_C)
  58.         variable counter : INTEGER := 0;
  59.         begin
  60.             if falling_edge(CLK_C)then
  61.                 case counter is
  62.                     when 1 =>
  63.                         DATA_C <= BUF;
  64.                     when 1001 =>
  65.                         CLK_C := '0';
  66.                     when 3501 =>
  67.                         CLK_C := '1';
  68.                     when 5001 =>
  69.                         DATA_C <= '11111111';
  70.                     when others => null;
  71.                 end case
  72.                 counter := counter +1;
  73.             end if
  74.     end process;
  75.  
  76. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement