Advertisement
leonardo_aly7

Driver

Mar 11th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.47 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 Driver is
  7.     Port ( clk : in  STD_LOGIC;
  8.            A : out  STD_LOGIC_VECTOR (15 downto 0);
  9.            B : out  STD_LOGIC_VECTOR (15 downto 0);
  10.            op_code : out  STD_LOGIC_VECTOR (2 downto 0));
  11. end Driver;
  12.  
  13. architecture Behavioral of Driver is
  14.  
  15. type int_array is array (0 to 7) of Integer ;
  16.  
  17. signal cnt :Integer:=0 ;
  18. signal op_count : Integer   range 0 to 3;
  19. --signal lastOp:Integer:=0;
  20.  
  21. signal x:int_array ;
  22. signal y: int_array ;
  23. signal code : int_array ;
  24.  
  25. begin
  26. x(0) <= 0 ;x(1) <= 1 ;x(2) <= 2 ;x(3) <= 3 ;x(4) <= 4 ;x(5) <= 5 ;x(6) <= 6 ;x(7) <= 7 ;
  27.  
  28. y(0) <= 8;y(1) <=  9;y(2) <=  10;y(3) <=  11;y(4) <=  12;y(5) <=  13;y(6) <=  14;y(7) <=  15;
  29.  
  30. code(0) <= 0;code(1) <= 1;code(2) <= 2;code(3) <= 3;code(4) <= 4;code(5) <= 5;code(6) <= 6;code(7) <= 7;
  31.  
  32.     --x <=(0,1,2,3,4,5,6,7);
  33.     --y <=(8,9,10,11,12,13,14,15);
  34.     --code  <=(0,1,2,3,4,5,6,7);
  35.    
  36.     driver_process :process(clk)
  37.    
  38.     begin
  39.             if(clk'event and clk = '1') then
  40.                 cnt <= cnt + 1;
  41.                 if (cnt = 3)    then  -- clock counter                 
  42.                 --don't forget to change the range
  43.                     A <=conv_std_logic_vector(x(op_count), 16);
  44.                     B <=conv_std_logic_vector(y(op_count), 16);
  45.                     op_code <= conv_std_logic_vector(code(op_count), 3);
  46.                    
  47.     --              lastOp<=op_count+1;
  48.                     op_count <= (op_count+1 mod 8);
  49.                    
  50.                     cnt<=0;
  51.                 end if;
  52.             end if;
  53.     end process;
  54. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement