Skip to content

Commit b9d8529

Browse files
committed
context example
1 parent 8a583b0 commit b9d8529

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

language-features/context/test.vhd

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
-- Make library visible to design.
12
library test_lib;
3+
-- Apply test_lib context to this design. This will include context includes
4+
-- visible to this design. No need to write or import ieee stuff.
25
context test_lib.lib_context;
36

47

@@ -8,11 +11,20 @@ end entity;
811

912
architecture tb of test is
1013

11-
signal test : std_logic := '1';
14+
-- std_logic type available because of the context.
15+
signal a, b, s : std_logic := '0';
16+
signal d : std_logic;
1217
signal end_simulation : boolean := true;
1318

1419
begin
15-
-- TODO: Write rest of this here.
20+
21+
-- Mux component available because of the context.
22+
mux1 : entity mux port map(a, b, s, d);
23+
24+
end_simulation <= false after 1 ps;
25+
assert end_simulation
26+
report "simulation ended"
27+
severity failure;
1628

1729
end architecture;
1830

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
-- Declare context which can be used in some other design with context
2+
-- keyword. This is like an entry point to this library.
3+
-- Using context make inlcuding multiple libraries less tedious and
4+
-- easier. This context is compiled to test_lib library.
15
context lib_context is
26
library ieee;
37
use ieee.std_logic_1164.all;
8+
-- Notice no library statement needed, because this file is compiled
9+
-- to the test_lib library.
410
use test_lib.all;
511
end context;

language-features/context/test_lib/mux.vhd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ library ieee;
22
use ieee.std_logic_1164.all;
33

44

5+
-- Compiled to test_lib library.
56
entity mux is
67
port (
78
a, b, s : in std_logic;

0 commit comments

Comments
 (0)