Skip to content

Commit 8d2c74d

Browse files
committed
resolution function
1 parent eb995a5 commit 8d2c74d

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package resolution_pgk is
2+
3+
type v4l is ('X', '0', '1', 'Z');
4+
type v4l_vector is array (natural range <>) of v4l;
5+
6+
function resolution_fn (drivers : v4l_vector) return v4l;
7+
8+
type v4l_resolution_vector is array (v4l, v4l) of v4l;
9+
constant v4l_resolution_table : v4l_resolution_vector := (
10+
-- 'X' '0', '1' 'Z'
11+
'X' => ('X', 'X', 'X', 'X'),
12+
'0' => ('X', '0', 'X', '0'),
13+
'1' => ('X', 'X', '1', '1'),
14+
'Z' => ('X', '0', '1', 'Z')
15+
);
16+
17+
end package;
18+
19+
20+
package body resolution_pgk is
21+
22+
function resolution_fn(drivers : v4l_vector) return v4l is
23+
variable accumulate : v4l := 'Z';
24+
begin
25+
for i in drivers'range loop
26+
accumulate := v4l_resolution_table(accumulate, drivers(i));
27+
report "accu: " & v4l'image(accumulate) & ", driver: " & v4l'image(drivers(i));
28+
end loop;
29+
return accumulate;
30+
end function;
31+
32+
end package body;

resolution-function/test.vhd

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library ieee;
2+
use ieee.std_logic_1164.all;
3+
-- Import resolution_pgk package content.
4+
use work.resolution_pgk.all;
5+
6+
7+
entity test is
8+
end entity;
9+
10+
11+
architecture tb of test is
12+
13+
signal test : resolution_fn v4l;
14+
15+
subtype resolved_v4l is resolution_fn v4l;
16+
type resolved_v4l_vector is array (natural range <>) of resolved_v4l;
17+
signal test_vector : resolved_v4l_vector(1 downto 0);
18+
19+
signal end_simulation : boolean := true;
20+
21+
begin
22+
23+
test <= '1';
24+
test <= 'Z';
25+
--test_vector <= "11";
26+
--test_vector <= "11";
27+
28+
end_simulation <= false after 1 ps;
29+
assert end_simulation
30+
-- resolved test: '1'
31+
report "resolved test: " & v4l'image(test)
32+
severity failure;
33+
34+
assert false
35+
report "resolved test_vector: " & resolved_v4l'image(test_vector(1)) &
36+
resolved_v4l'image(test_vector(0))
37+
severity note;
38+
39+
end architecture;

resolution-function/vimhdl.prj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
builder = msim
2+
target_dir = .build
3+
4+
vhdl work test.vhd -2002
5+
vhdl work resolution_pkg.vhd -2002

0 commit comments

Comments
 (0)