aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1999/t1_p.vhdl
blob: cc55b6883b47bd6d706ad89bfa0694ee7da1b55e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-----
---  testcase for operator overload "/"
-----

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.unsigned;
use ieee.numeric_std.resize;

package t1_p is
  function resize(signal i : std_logic_vector; constant n : integer)
    return std_logic_vector;
  function "/" (signal a : std_logic_vector; signal b : std_logic_vector)
    return std_logic_vector;
end package t1_p;

package body t1_p is
  function resize(
    signal i : std_logic_vector; constant n : integer) return std_logic_vector is
  begin
    return std_logic_vector(ieee.numeric_std.resize(unsigned(i), n));
  end function;

  -- purpose: or signals with different sizes
  function "/" (   -- this is NOT a divider operand  !!!
    signal a : std_logic_vector;
    signal b : std_logic_vector)
    return std_logic_vector is
    variable s : integer;
  begin  -- 
    s := a'length;
    if b'length > a'length then
      s := b'length;
    end if;
    return resize(a, s) or resize(b, s);
  end "/";
end t1_p;