Skip to content

Commit 1b38f7a

Browse files
authored
All PoC.sync tests converted to OSVVM-style.
2 parents 6aedc46 + aef72e4 commit 1b38f7a

27 files changed

+1693
-612
lines changed

tb/RunAllTests.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
include ./arith/RunAllTests.pro
2323
include ./bus/RunAllTests.pro
24+
include ./sync/RunAllTests.pro
2425
#include ./cache/RunAllTests.pro
2526
#include ./common/RunAllTests.pro
2627
#include ./dstruct/RunAllTests.pro

tb/sync/Bits/RunAllTests.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 sync_Bits_TestController.vhdl
23+
analyze sync_Bits_TestHarness.vhdl
24+
25+
RunTest sync_Bits_Simple.vhdl

tb/sync/Bits/sync_Bits_Simple.vhdl

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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: Patrick Lehmann
6+
-- Gustavo Martin
7+
--
8+
-- Entity: sync_Bits_TestController (Simple architecture)
9+
--
10+
-- Description:
11+
-- -------------------------------------
12+
-- OSVVM simple test for flag signal synchronizer.
13+
-- Tests that signals propagate correctly across clock domains.
14+
--
15+
-- License:
16+
-- =============================================================================
17+
-- Copyright 2025-2025 The PoC-Library Authors
18+
-- Copyright 2007-2016 Technische Universitaet Dresden - Germany
19+
-- Chair of VLSI-Design, Diagnostics and Architecture
20+
--
21+
-- Licensed under the Apache License, Version 2.0 (the "License");
22+
-- you may not use this file except in compliance with the License.
23+
-- You may obtain a copy of the License at
24+
--
25+
-- http://www.apache.org/licenses/LICENSE-2.0
26+
--
27+
-- Unless required by applicable law or agreed to in writing, software
28+
-- distributed under the License is distributed on an "AS IS" BASIS,
29+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30+
-- See the License for the specific language governing permissions and
31+
-- limitations under the License.
32+
-- =============================================================================
33+
34+
library IEEE;
35+
use IEEE.std_logic_1164.all;
36+
use IEEE.numeric_std.all;
37+
38+
library osvvm;
39+
context osvvm.OsvvmContext;
40+
41+
library PoC;
42+
use PoC.utils.all;
43+
44+
45+
architecture Simple of sync_Bits_TestController is
46+
signal TestDone : integer_barrier := 1;
47+
48+
constant TCID : AlertLogIDType := NewID("TestCtrl");
49+
50+
constant INIT : std_logic_vector(Sync_out'range) := (others => '0');
51+
52+
begin
53+
ControlProc : process
54+
constant ProcID : AlertLogIDType := NewID("ControlProc", TCID);
55+
constant TIMEOUT : time := 10 ms;
56+
begin
57+
SetTestName("sync_Bits_Simple");
58+
59+
SetLogEnable(PASSED, FALSE);
60+
SetLogEnable(INFO, FALSE);
61+
SetLogEnable(DEBUG, FALSE);
62+
wait for 0 ns; wait for 0 ns;
63+
64+
TranscriptOpen;
65+
SetTranscriptMirror(TRUE);
66+
67+
wait until Reset = '0';
68+
ClearAlerts;
69+
70+
WaitForBarrier(TestDone, TIMEOUT);
71+
AlertIf(ProcID, now >= TIMEOUT, "Test finished due to timeout");
72+
AlertIf(ProcID, GetAffirmCount < 1, "Test is not Self-Checking");
73+
74+
EndOfTestReports(ReportAll => TRUE);
75+
std.env.stop;
76+
end process;
77+
78+
StimuliProc : process
79+
constant ProcID : AlertLogIDType := NewID("StimuliProc", TCID);
80+
begin
81+
-- Initialize
82+
Sync_in <= INIT;
83+
84+
wait until Reset = '0';
85+
WaitForClock(Clock1, 4);
86+
87+
-- Toggle input several times with different patterns
88+
Sync_in <= "1";
89+
WaitForClock(Clock1, 2);
90+
91+
Sync_in <= "0";
92+
WaitForClock(Clock1, 2);
93+
94+
Sync_in <= "1";
95+
WaitForClock(Clock1, 2);
96+
97+
Sync_in <= "0";
98+
WaitForClock(Clock1, 6);
99+
100+
Sync_in <= "1";
101+
WaitForClock(Clock1, 16);
102+
103+
Sync_in <= "0";
104+
WaitForClock(Clock1, 2);
105+
106+
Sync_in <= "1";
107+
WaitForClock(Clock1, 2);
108+
109+
Sync_in <= "0";
110+
WaitForClock(Clock1, 6);
111+
112+
wait;
113+
end process;
114+
115+
CheckerProc : process
116+
constant ProcID : AlertLogIDType := NewID("CheckerProc", TCID);
117+
variable toggled : natural := 0;
118+
variable Sync_out_old : std_logic_vector(Sync_out'range);
119+
begin
120+
wait until Reset = '0';
121+
WaitForClock(Clock2);
122+
123+
-- Check initial value
124+
AffirmIf(ProcID, Sync_out = INIT, "Initial value should be " & to_string(INIT));
125+
Sync_out_old := Sync_out;
126+
127+
-- Count toggle events for a maximum of 50 clock cycles
128+
for i in 1 to 50 loop
129+
WaitForClock(Clock2);
130+
if Sync_out /= Sync_out_old then
131+
toggled := toggled + 1;
132+
Sync_out_old := Sync_out;
133+
end if;
134+
end loop;
135+
136+
-- Should see 8 toggle events based on stimuli
137+
AffirmIf(ProcID, toggled = 8,
138+
"Expected 8 toggle events, got " & integer'image(toggled));
139+
140+
WaitForBarrier(TestDone);
141+
wait;
142+
end process;
143+
144+
end architecture;
145+
146+
147+
configuration sync_Bits_Simple of sync_Bits_TestHarness is
148+
for TestHarness
149+
for TestCtrl : sync_Bits_TestController
150+
use entity work.sync_Bits_TestController(Simple);
151+
end for;
152+
end for;
153+
end configuration;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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: Patrick Lehmann
6+
-- Gustavo Martin
7+
--
8+
-- Entity: sync_Bits_TestController
9+
--
10+
-- Description:
11+
-- -------------------------------------
12+
-- OSVVM test controller entity for flag signal synchronizer
13+
--
14+
-- License:
15+
-- =============================================================================
16+
-- Copyright 2025-2025 The PoC-Library Authors
17+
-- Copyright 2007-2016 Technische Universitaet Dresden - Germany
18+
-- Chair of VLSI-Design, Diagnostics and Architecture
19+
--
20+
-- Licensed under the Apache License, Version 2.0 (the "License");
21+
-- you may not use this file except in compliance with the License.
22+
-- You may obtain a copy of the License at
23+
--
24+
-- http://www.apache.org/licenses/LICENSE-2.0
25+
--
26+
-- Unless required by applicable law or agreed to in writing, software
27+
-- distributed under the License is distributed on an "AS IS" BASIS,
28+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29+
-- See the License for the specific language governing permissions and
30+
-- limitations under the License.
31+
-- =============================================================================
32+
33+
library IEEE;
34+
use IEEE.std_logic_1164.all;
35+
36+
library osvvm;
37+
context osvvm.OsvvmContext;
38+
39+
40+
entity sync_Bits_TestController is
41+
port (
42+
Clock1 : in std_logic;
43+
Clock2 : in std_logic;
44+
Reset : in std_logic;
45+
Sync_in : out std_logic_vector;
46+
Sync_out : in std_logic_vector
47+
);
48+
end entity;
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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: Gustavo Martin
6+
--
7+
-- Entity: sync_Bits_TestHarness
8+
--
9+
-- Description:
10+
-- -------------------------------------
11+
-- OSVVM testbench harness for flag signal synchronizer
12+
--
13+
-- License:
14+
-- =============================================================================
15+
-- Copyright 2025-2025 The PoC-Library Authors
16+
--
17+
-- Licensed under the Apache License, Version 2.0 (the "License");
18+
-- you may not use this file except in compliance with the License.
19+
-- You may obtain a copy of the License at
20+
--
21+
-- http://www.apache.org/licenses/LICENSE-2.0
22+
--
23+
-- Unless required by applicable law or agreed to in writing, software
24+
-- distributed under the License is distributed on an "AS IS" BASIS,
25+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26+
-- See the License for the specific language governing permissions and
27+
-- limitations under the License.
28+
-- =============================================================================
29+
30+
library IEEE;
31+
use IEEE.std_logic_1164.all;
32+
use IEEE.numeric_std.all;
33+
34+
library osvvm;
35+
context osvvm.OsvvmContext;
36+
37+
library PoC;
38+
39+
40+
entity sync_Bits_TestHarness is
41+
end entity;
42+
43+
44+
architecture TestHarness of sync_Bits_TestHarness is
45+
-- Clock periods (100 MHz and 60 MHz)
46+
constant TPERIOD_CLOCK_1 : time := 10 ns;
47+
constant TPERIOD_CLOCK_2 : time := 16.667 ns;
48+
49+
constant BITS : positive := 1;
50+
constant INIT : std_logic_vector(BITS - 1 downto 0) := (others => '0');
51+
52+
signal Clock1 : std_logic := '1';
53+
signal Clock2 : std_logic := '1';
54+
signal Reset : std_logic := '1';
55+
56+
signal Sync_in : std_logic_vector(BITS - 1 downto 0);
57+
signal Sync_out : std_logic_vector(BITS - 1 downto 0);
58+
59+
60+
component sync_Bits_TestController is
61+
port (
62+
Clock1 : in std_logic;
63+
Clock2 : in std_logic;
64+
Reset : in std_logic;
65+
Sync_in : out std_logic_vector;
66+
Sync_out : in std_logic_vector
67+
);
68+
end component;
69+
70+
begin
71+
Osvvm.ClockResetPkg.CreateClock(
72+
Clk => Clock1,
73+
Period => TPERIOD_CLOCK_1
74+
);
75+
76+
Osvvm.ClockResetPkg.CreateClock(
77+
Clk => Clock2,
78+
Period => TPERIOD_CLOCK_2
79+
);
80+
81+
Osvvm.ClockResetPkg.CreateReset(
82+
Reset => Reset,
83+
ResetActive => '1',
84+
Clk => Clock1,
85+
Period => 5 * TPERIOD_CLOCK_1,
86+
tpd => 0 ns
87+
);
88+
89+
DUT : entity PoC.sync_Bits
90+
generic map (
91+
BITS => BITS,
92+
INIT => INIT
93+
)
94+
port map (
95+
Clock => Clock2,
96+
Input => Sync_in,
97+
Output => Sync_out
98+
);
99+
100+
TestCtrl : component sync_Bits_TestController
101+
port map (
102+
Clock1 => Clock1,
103+
Clock2 => Clock2,
104+
Reset => Reset,
105+
Sync_in => Sync_in,
106+
Sync_out => Sync_out
107+
);
108+
109+
end architecture;

tb/sync/Command/RunAllTests.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 sync_Command_TestController.vhdl
23+
analyze sync_Command_TestHarness.vhdl
24+
25+
RunTest sync_Command_Simple.vhdl

0 commit comments

Comments
 (0)