Skip to content

Commit 970c489

Browse files
committed
ghdl_ug: cleanup
1 parent cb0d2ef commit 970c489

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

ghdl_ug/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ghdl -a hello.vhd
99

1010
ghdl -e hello_world
1111

12-
./hello_world.exe
12+
./hello_world
1313
```
1414

1515
Notes:
@@ -28,9 +28,9 @@ ghdl -a heartbeat.vhdl
2828

2929
ghdl -e heartbeat
3030

31-
./heartbeat.exe
31+
./heartbeat
3232

33-
./heartbeat.exe --wave=wave.ghw
33+
./heartbeat --wave=wave.ghw
3434

3535
gtkwave wave.ghw
3636
```
@@ -50,7 +50,7 @@ ghdl -a tb_adder.vhd
5050
ghdl -e tb_adder
5151
./tb_adder
5252

53-
./tb_adder.exe --wave=wave.ghw
53+
./tb_adder --wave=wave.ghw
5454
gtkwave wave.ghw
5555
```
5656

ghdl_ug/tb_adder.vhd

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
library vunit_lib;
2-
context vunit_lib.vunit_context;
3-
41
-- A testbench has no ports.
52
entity tb_adder is
6-
generic (runner_cfg : string);
73
end tb_adder;
84

95
architecture behav of tb_adder is
@@ -39,7 +35,6 @@ begin
3935
('1', '1', '0', '0', '1'),
4036
('1', '1', '1', '1', '1'));
4137
begin
42-
test_runner_setup(runner, runner_cfg);
4338
-- Check each pattern.
4439
for i in patterns'range loop
4540
-- Set the inputs.
@@ -56,8 +51,7 @@ begin
5651
end loop;
5752
assert false report "end of test" severity note;
5853
-- Wait forever; this will finish the simulation.
59-
--wait;
60-
test_runner_cleanup(runner); -- Simulation ends here
54+
wait;
6155
end process;
6256

6357
end behav;

ghdl_ug/tb_adder_vunit.vhd

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
library vunit_lib;
2+
context vunit_lib.vunit_context;
3+
4+
-- A testbench has no ports.
5+
entity tb_adder is
6+
generic (runner_cfg : string);
7+
end tb_adder;
8+
9+
architecture behav of tb_adder is
10+
-- Declaration of the component that will be instantiated.
11+
component adder
12+
port (i0, i1 : in bit; ci : in bit; s : out bit; co : out bit);
13+
end component;
14+
15+
-- Specifies which entity is bound with the component.
16+
for adder_0: adder use entity work.adder;
17+
signal i0, i1, ci, s, co : bit;
18+
begin
19+
-- Component instantiation.
20+
adder_0: adder port map (i0 => i0, i1 => i1, ci => ci, s => s, co => co);
21+
22+
-- This process does the real job.
23+
process
24+
type pattern_type is record
25+
-- The inputs of the adder.
26+
i0, i1, ci : bit;
27+
-- The expected outputs of the adder.
28+
s, co : bit;
29+
end record;
30+
-- The patterns to apply.
31+
type pattern_array is array (natural range <>) of pattern_type;
32+
constant patterns : pattern_array :=
33+
(('0', '0', '0', '0', '0'),
34+
('0', '0', '1', '1', '0'),
35+
('0', '1', '0', '1', '0'),
36+
('0', '1', '1', '0', '1'),
37+
('1', '0', '0', '1', '0'),
38+
('1', '0', '1', '0', '1'),
39+
('1', '1', '0', '0', '1'),
40+
('1', '1', '1', '1', '1'));
41+
begin
42+
test_runner_setup(runner, runner_cfg);
43+
-- Check each pattern.
44+
for i in patterns'range loop
45+
-- Set the inputs.
46+
i0 <= patterns(i).i0;
47+
i1 <= patterns(i).i1;
48+
ci <= patterns(i).ci;
49+
-- Wait for the results.
50+
wait for 1 ns;
51+
-- Check the outputs.
52+
assert s = patterns(i).s
53+
report "bad sum value" severity error;
54+
assert co = patterns(i).co
55+
report "bad carry out value" severity error;
56+
end loop;
57+
assert false report "end of test" severity note;
58+
-- Wait forever; this will finish the simulation.
59+
--wait;
60+
test_runner_cleanup(runner); -- Simulation ends here
61+
end process;
62+
63+
end behav;

0 commit comments

Comments
 (0)