OpenCores
URL https://opencores.org/ocsvn/distributed_intelligence/distributed_intelligence/trunk

Subversion Repositories distributed_intelligence

[/] [distributed_intelligence/] [trunk/] [LIB/] [MY_FUNCS.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 leoel
--      Package File Template
2
--
3
--      Purpose: This package defines useful functions
4
 
5
 
6
library IEEE;
7
use IEEE.STD_LOGIC_1164.all;
8
 
9
package MY_FUNCS is
10 5 leoel
        -- Operator sll and srl for a std_logic_vector
11 4 leoel
        function "sll"(val : std_logic_vector; shift : integer) return std_logic_vector;
12
        function "srl"(val : std_logic_vector; shift : integer) return std_logic_vector;
13
end MY_FUNCS;
14
 
15
 
16
package body MY_FUNCS is
17 5 leoel
  function "sll"(val : std_logic_vector; shift : integer) return std_logic_vector is
18
    variable ret : std_logic_vector(val'range) := val;
19
  begin
20
    if (shift > 0) then
21
      for i in 1 to shift loop
22
        ret := ret(val'high - 1 downto val'low) & '0';
23
      end loop;
24
    end if;
25
    return ret;
26
  end;
27 4 leoel
 
28
  function "srl"(val : std_logic_vector; shift : integer) return std_logic_vector is
29
    variable ret : std_logic_vector(val'range) := val;
30
  begin
31
    if (shift > 0) then
32
      for i in 1 to shift loop
33
        ret := '0' & ret(val'high downto val'low + 1) ;
34
      end loop;
35
    end if;
36
    return ret;
37
  end;
38
end MY_FUNCS;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.