Skip to content

Commit 62ee0ee

Browse files
authored
Some PoC.arith tests converted to OSVVM
2 parents 3b99b32 + d5617f3 commit 62ee0ee

20 files changed

+1805
-0
lines changed

tb/arith/RunAllTests.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# =============================================================================
22
# Authors: Jonas Schreiner
3+
# Gustavo Martin
34
#
45
# License:
56
# =============================================================================
@@ -23,3 +24,7 @@ TestSuite PoC.arith
2324
library tb_arith
2425

2526
include ./prng/RunAllTests.pro
27+
include ./prefix_and/RunAllTests.pro
28+
include ./prefix_or/RunAllTests.pro
29+
include ./addw/RunAllTests.pro
30+
include ./counter_bcd/RunAllTests.pro

tb/arith/addw/RunAllTests.pro

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# =============================================================================
2+
# Authors:
3+
# Gustavo Martin
4+
#
5+
# License:
6+
# =============================================================================
7+
# Copyright 2025-2025 The PoC-Library Authors
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
# =============================================================================
21+
22+
analyze arith_addw_TestController_pkg.vhdl
23+
analyze arith_addw_TestController.vhdl
24+
analyze arith_addw_TestHarness.vhdl
25+
26+
RunTest arith_addw_Simple.vhdl
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
-- EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*-
2+
-- vim: tabstop=2:shiftwidth=2:noexpandtab
3+
-- kate: tab-width 2; replace-tabs off; indent-width 2;
4+
-- =============================================================================
5+
-- Authors: Thomas B. Preusser
6+
-- Gustavo Martin
7+
--
8+
-- Entity: arith_addw_Simple
9+
--
10+
-- Description:
11+
-- -------------------------------------
12+
-- Simple OSVVM test for arith_addw
13+
--
14+
-- License:
15+
-- =============================================================================
16+
-- Copyright 2025-2025 The PoC-Library Authors
17+
--
18+
-- Licensed under the Apache License, Version 2.0 (the "License");
19+
-- you may not use this file except in compliance with the License.
20+
-- You may obtain a copy of the License at
21+
--
22+
-- http://www.apache.org/licenses/LICENSE-2.0
23+
--
24+
-- Unless required by applicable law or agreed to in writing, software
25+
-- distributed under the License is distributed on an "AS IS" BASIS,
26+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
-- See the License for the specific language governing permissions and
28+
-- limitations under the License.
29+
-- =============================================================================
30+
31+
library IEEE;
32+
use IEEE.std_logic_1164.all;
33+
use IEEE.numeric_std.all;
34+
35+
library osvvm;
36+
context osvvm.OsvvmContext;
37+
38+
library PoC;
39+
use PoC.strings.all;
40+
use PoC.physical.all;
41+
use PoC.arith.all;
42+
43+
use work.arith_addw_TestController_pkg.all;
44+
45+
architecture Simple of arith_addw_TestController is
46+
signal TestDone : integer_barrier := 1;
47+
constant TCID : AlertLogIDType := NewID("AddWTest");
48+
constant TPERIOD_CLOCK : time := 10 ns;
49+
50+
begin
51+
52+
ControlProc: process
53+
constant ProcID : AlertLogIDType := NewID("ControlProc", TCID);
54+
constant TIMEOUT : time := 10 ms;
55+
begin
56+
SetTestName("arith_addw_Simple");
57+
58+
SetLogEnable(PASSED, FALSE);
59+
SetLogEnable(INFO, FALSE);
60+
SetLogEnable(DEBUG, FALSE);
61+
wait for 0 ns; wait for 0 ns;
62+
63+
TranscriptOpen;
64+
SetTranscriptMirror(TRUE);
65+
66+
wait until Reset = '0';
67+
ClearAlerts;
68+
69+
WaitForBarrier(TestDone, TIMEOUT);
70+
AlertIf(ProcID, now >= TIMEOUT, "Test finished due to timeout");
71+
AlertIf(ProcID, GetAffirmCount < 1, "Test is not Self-Checking");
72+
73+
EndOfTestReports(ReportAll => TRUE);
74+
std.env.stop;
75+
end process;
76+
77+
CheckerProc: process
78+
constant ProcID : AlertLogIDType := NewID("CheckerProc", TCID);
79+
variable ai, bi : integer;
80+
variable expected : natural;
81+
variable actual_sum : unsigned(9 downto 0);
82+
begin
83+
wait until Reset = '0';
84+
WaitForClock(Clock);
85+
86+
for i in 0 to 2**9-1 loop
87+
a <= std_logic_vector(to_unsigned(i, 9));
88+
for j in 0 to 2**9-1 loop
89+
b <= std_logic_vector(to_unsigned(j, 9));
90+
cin <= '0';
91+
WaitForClock(Clock);
92+
for arch in tArch loop
93+
for skip in tSkipping loop
94+
-- Test with P_INCLUSIVE = false
95+
expected := (i + j) mod 2**10;
96+
actual_sum := unsigned(cout(arch, skip, false) & s(arch, skip, false));
97+
AffirmIf(ProcID, expected = to_integer(actual_sum),
98+
"Output Error: " & integer'image(i) & "+" & integer'image(j) &
99+
" arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=false"
100+
);
101+
102+
-- Test with P_INCLUSIVE = true
103+
actual_sum := unsigned(cout(arch, skip, true) & s(arch, skip, true));
104+
AffirmIf(ProcID, expected = to_integer(actual_sum),
105+
"Output Error: " & integer'image(i) & "+" & integer'image(j) &
106+
" arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=true"
107+
);
108+
end loop;
109+
end loop;
110+
111+
cin <= '1';
112+
WaitForClock(Clock);
113+
for arch in tArch loop
114+
for skip in tSkipping loop
115+
-- Test with P_INCLUSIVE = false
116+
expected := (i + j + 1) mod 2**10;
117+
actual_sum := unsigned(cout(arch, skip, false) & s(arch, skip, false));
118+
AffirmIf(ProcID, expected = to_integer(actual_sum),
119+
"Output Error with carry: " & integer'image(i) & "+" & integer'image(j) & "+1" &
120+
" arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=false"
121+
);
122+
123+
-- Test with P_INCLUSIVE = true
124+
actual_sum := unsigned(cout(arch, skip, true) & s(arch, skip, true));
125+
AffirmIf(ProcID, expected = to_integer(actual_sum),
126+
"Output Error with carry: " & integer'image(i) & "+" & integer'image(j) & "+1" &
127+
" arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=true"
128+
);
129+
end loop;
130+
end loop;
131+
132+
end loop;
133+
end loop;
134+
135+
WaitForBarrier(TestDone);
136+
wait;
137+
end process;
138+
end architecture;
139+
140+
configuration arith_addw_Simple of arith_addw_TestHarness is
141+
for TestHarness
142+
for TestCtrl: arith_addw_TestController
143+
use entity work.arith_addw_TestController(Simple);
144+
end for;
145+
end for;
146+
end configuration;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*-
2+
-- vim: tabstop=2:shiftwidth=2:noexpandtab
3+
-- kate: tab-width 2; replace-tabs off; indent-width 2;
4+
-- =============================================================================
5+
-- Authors: Thomas B. Preusser
6+
-- Gustavo Martin
7+
--
8+
-- Entity: arith_addw_TestController
9+
--
10+
-- Description:
11+
-- -------------------------------------
12+
-- Test controller for arith_addw
13+
--
14+
-- License:
15+
-- =============================================================================
16+
-- Copyright 2025-2025 The PoC-Library Authors
17+
--
18+
-- Licensed under the Apache License, Version 2.0 (the "License");
19+
-- you may not use this file except in compliance with the License.
20+
-- You may obtain a copy of the License at
21+
--
22+
-- http://www.apache.org/licenses/LICENSE-2.0
23+
--
24+
-- Unless required by applicable law or agreed to in writing, software
25+
-- distributed under the License is distributed on an "AS IS" BASIS,
26+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
-- See the License for the specific language governing permissions and
28+
-- limitations under the License.
29+
-- =============================================================================
30+
31+
library IEEE;
32+
use IEEE.std_logic_1164.all;
33+
34+
library osvvm;
35+
context osvvm.OsvvmContext;
36+
37+
library PoC;
38+
use PoC.arith.all;
39+
40+
use work.arith_addw_TestController_pkg.all;
41+
42+
entity arith_addw_TestController is
43+
port (
44+
Clock : in std_logic;
45+
Reset : in std_logic;
46+
47+
-- DUT ports (arrays for all variants)
48+
a : out word;
49+
b : out word;
50+
cin : out std_logic;
51+
s : in word_vector;
52+
cout : in carry_vector
53+
);
54+
end entity;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*-
2+
-- vim: tabstop=2:shiftwidth=2:noexpandtab
3+
-- kate: tab-width 2; replace-tabs off; indent-width 2;
4+
-- =============================================================================
5+
-- Authors: Thomas B. Preusser
6+
-- Gustavo Martin
7+
--
8+
-- Entity: arith_addw_TestController_pkg
9+
--
10+
-- Description:
11+
-- -------------------------------------
12+
-- Test controller package for arith_addw
13+
--
14+
-- License:
15+
-- =============================================================================
16+
-- Copyright 2025-2025 The PoC-Library Authors
17+
--
18+
-- Licensed under the Apache License, Version 2.0 (the "License");
19+
-- you may not use this file except in compliance with the License.
20+
-- You may obtain a copy of the License at
21+
--
22+
-- http://www.apache.org/licenses/LICENSE-2.0
23+
--
24+
-- Unless required by applicable law or agreed to in writing, software
25+
-- distributed under the License is distributed on an "AS IS" BASIS,
26+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
-- See the License for the specific language governing permissions and
28+
-- limitations under the License.
29+
-- =============================================================================
30+
31+
library IEEE;
32+
use IEEE.std_logic_1164.all;
33+
34+
library osvvm;
35+
context osvvm.OsvvmContext;
36+
37+
library PoC;
38+
use PoC.arith.all;
39+
40+
package arith_addw_TestController_pkg is
41+
42+
constant N : positive := 9;
43+
constant K : positive := 2;
44+
45+
subtype tArch_test is tArch;
46+
subtype tSkip_test is tSkipping;
47+
48+
subtype word is std_logic_vector(N-1 downto 0);
49+
type word_vector is array(tArch_test, tSkip_test, boolean) of word;
50+
type carry_vector is array(tArch_test, tSkip_test, boolean) of std_logic;
51+
52+
end package arith_addw_TestController_pkg;

0 commit comments

Comments
 (0)