Skip to content

Commit c2853eb

Browse files
committed
Introduced test cases, one failing base on the original code, and one passing to make the examples more complete.
1 parent 979458b commit c2853eb

3 files changed

Lines changed: 40 additions & 26 deletions

File tree

examples/osvvm_integration/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ui = VUnit.from_argv()
1717
ui.add_osvvm()
1818

19-
lib = ui.add_library('uart_lib')
19+
lib = ui.add_library('lib')
2020
lib.add_source_files(join(dirname(__file__), 'src', '*.vhd'))
2121

2222
ui.main()

examples/osvvm_integration/src/tb_AlertLog_Demo_Global.vhd

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,28 @@ begin
107107
SetLogEnable(DEBUG, true); -- Enable DEBUG Messages for all levels of the hierarchy
108108

109109
-- Uncomment this line to justify alert and log reports
110-
-- SetAlertLogJustify ;
111-
for i in 1 to 5 loop
112-
wait until Clk = '1';
113-
if i = 4 then SetLogEnable(DEBUG, false); end if; -- DEBUG Mode OFF
114-
wait for 1 ns;
115-
Alert("Tb.P1.E alert " & to_string(i) & " of 5"); -- ERROR by default
116-
Log ("Tb.P1.D log " & to_string(i) & " of 5", DEBUG);
110+
-- SetAlertLogJustify ;
111+
112+
while test_suite loop
113+
if run("Test failing alerts") then
114+
for i in 1 to 5 loop
115+
wait until Clk = '1';
116+
if i = 4 then SetLogEnable(DEBUG, false); end if; -- DEBUG Mode OFF
117+
wait for 1 ns;
118+
Alert("Tb.P1.E alert " & to_string(i) & " of 5"); -- ERROR by default
119+
Log ("Tb.P1.D log " & to_string(i) & " of 5", DEBUG);
120+
end loop;
121+
wait until Clk = '1';
122+
wait until Clk = '1';
123+
wait for 1 ns;
124+
-- Report Alerts with expected errors expressed as a negative ExternalErrors value
125+
ReportAlerts(Name => "AlertLog_Demo_Hierarchy with expected errors", ExternalErrors => -(failure => 0, error => 20, warning => 15));
126+
elsif run("Test passing alerts") then
127+
AlertIf(false, "This should not fail");
128+
end if;
117129
end loop;
118-
wait until Clk = '1';
119-
wait until Clk = '1';
120-
wait for 1 ns;
130+
121131
ReportAlerts;
122-
print("");
123-
-- Report Alerts with expected errors expressed as a negative ExternalErrors value
124-
ReportAlerts(Name => "AlertLog_Demo_Hierarchy with expected errors", ExternalErrors => -(failure => 0, error => 20, warning => 15));
125132
TranscriptClose;
126133

127134
test_runner_cleanup(runner, get_alert_statistics);

examples/osvvm_integration/src/tb_AlertLog_Demo_Hierarchy.vhd

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,28 @@ begin
117117

118118
-- Uncomment this line to justify alert and log reports
119119
-- SetAlertLogJustify ;
120-
for i in 1 to 5 loop
121-
wait until Clk = '1';
122-
if i = 4 then SetLogEnable(DEBUG, false); end if; -- DEBUG Mode OFF
123-
wait for 1 ns;
124-
Alert(TB_P1_ID, "Tb.P1.E alert " & to_string(i) & " of 5"); -- ERROR by default
125-
Log (TB_P1_ID, "Tb.P1.D log " & to_string(i) & " of 5", DEBUG);
120+
121+
while test_suite loop
122+
if run("Test failing alerts") then
123+
for i in 1 to 5 loop
124+
wait until Clk = '1';
125+
if i = 4 then SetLogEnable(DEBUG, false); end if; -- DEBUG Mode OFF
126+
wait for 1 ns;
127+
Alert(TB_P1_ID, "Tb.P1.E alert " & to_string(i) & " of 5"); -- ERROR by default
128+
Log (TB_P1_ID, "Tb.P1.D log " & to_string(i) & " of 5", DEBUG);
129+
end loop;
130+
wait until Clk = '1';
131+
wait until Clk = '1';
132+
wait for 1 ns;
133+
-- Report Alerts with expected errors expressed as a negative ExternalErrors value
134+
ReportAlerts(Name => "AlertLog_Demo_Hierarchy with expected errors", ExternalErrors => -(failure => 0, error => 20, warning => 15));
135+
elsif run("Test passing alerts") then
136+
AlertIf(false, "This should not fail");
137+
end if;
126138
end loop;
127-
wait until Clk = '1';
128-
wait until Clk = '1';
129-
wait for 1 ns;
139+
130140
-- Report Alerts without expected errors
131141
ReportAlerts;
132-
print("");
133-
-- Report Alerts with expected errors expressed as a negative ExternalErrors value
134-
ReportAlerts(Name => "AlertLog_Demo_Hierarchy with expected errors", ExternalErrors => -(failure => 0, error => 20, warning => 15));
135142
TranscriptClose;
136143

137144
test_runner_cleanup(runner, get_alert_statistics);

0 commit comments

Comments
 (0)