blob: cbf1bd9c295c5c3d53a22ef2f4e9348bb8b0e9e9 (
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
39
40
41
42
43
44
45
46
47
48
49
50
|
-- Test release of stack2 for conditions.
entity repro1 is
end;
library ieee;
use ieee.numeric_std.all;
architecture behav of repro1 is
function ispow2a(i : integer) return boolean is
begin
if to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0 then
return true;
else
return false;
end if;
end;
function ispow2b(i : integer) return boolean is
begin
return to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0;
end;
function ispow2c(i : integer) return boolean is
begin
while to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0 loop
return true;
end loop;
return false;
end;
function ispow2d(i : integer) return boolean is
begin
loop
exit when to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0;
return False;
end loop;
return True;
end;
signal s : boolean;
begin
assert ispow2a (64);
assert not ispow2b (31);
assert ispow2c (64);
assert not ispow2c (31);
assert ispow2d (128);
assert not ispow2d (30);
end behav;
|