|
8 | 8 | ## Purpose: Runs one or more of the test cases described in
|
9 | 9 | ## dev_testcases.txt.
|
10 | 10 | ##
|
| 11 | +## This module is now multi-tasked. Multiple simulations may run |
| 12 | +## concurrently, up to (the internal value) $maxtasks. |
| 13 | +## |
11 | 14 | ## Creator: Dan Gisselquist, Ph.D.
|
12 | 15 | ## Gisselquist Technology, LLC
|
13 | 16 | ##
|
|
51 | 54 | $cputop = "tb_cpu";
|
52 | 55 | $testd = "test/";
|
53 | 56 | $vivado = 0;
|
| 57 | +$ntasks = 0; |
| 58 | +$maxtasks = 16; |
54 | 59 |
|
55 | 60 | ## Usage: perl sim_sim.pl all
|
56 | 61 | ## or
|
|
170 | 175 | ## {{{
|
171 | 176 | ## Remove any prior build products, so we can detect a failed
|
172 | 177 | ## build.
|
| 178 | + $exefile = $testd . $tstname; |
173 | 179 | if (-e $exefile) {
|
174 | 180 | unlink $exefile;
|
175 | 181 | }
|
|
256 | 262 | ## Run the simulation
|
257 | 263 | ## {{{
|
258 | 264 | $tstamp = timestamp();
|
| 265 | + $pid = fork; |
| 266 | + if ($pid ne 0) { |
| 267 | + return; |
| 268 | + } |
| 269 | + |
259 | 270 | system "echo \"$tstamp -- Starting simulation\" | tee -a $sim_log";
|
260 | 271 | system "$exefile >> $sim_log";
|
261 | 272 |
|
@@ -285,28 +296,30 @@ ($)
|
285 | 296 | system "grep -iq \'TEST PASS\' $sim_log";
|
286 | 297 | $errS = $?;
|
287 | 298 |
|
288 |
| - open (SUM,">> $report"); |
289 | 299 | if ($errE == 0 or $errA == 0 or $errF == 0) {
|
290 | 300 | ## ERRORs found, either assertion or other fail
|
291 |
| - print SUM "ERRORS $msg\n"; |
292 |
| - print "ERRORS $msg\n"; |
| 301 | + $msg = sprintf("ERRORS %s\n", $msg); |
293 | 302 | push @failed,$tstname;
|
294 | 303 | } elsif ($errT == 0) {
|
295 | 304 | # Timing violations present
|
296 |
| - print SUM "TIMING-ER $msg\n"; |
297 |
| - print "TIMING-ER $msg\n"; |
| 305 | + $msg = sprintf("TIMING-ER %s\n", $msg); |
298 | 306 | push @failed,$tstname;
|
299 | 307 | } elsif ($errS != 0) {
|
300 | 308 | # No success (TEST_PASS) message present
|
301 |
| - print SUM "FAIL $msg\n"; |
302 |
| - print "FAIL $msg\n"; |
| 309 | + $msg = sprintf("FAIL %s\n", $msg); |
303 | 310 | push @failed,$tstname;
|
304 | 311 | } else {
|
305 |
| - print SUM "Pass $msg\n"; |
306 |
| - print "Pass $msg\n"; |
| 312 | + $msg = sprintf("Pass %s\n", $msg); |
307 | 313 | push @passed,$tstname;
|
308 |
| - } close SUM; |
| 314 | + } |
| 315 | + |
| 316 | + open (SUM,">> $report"); |
| 317 | + print SUM $msg; |
| 318 | + close SUM; |
| 319 | + print $msg; |
309 | 320 | ## }}}
|
| 321 | + |
| 322 | + exit 0; |
310 | 323 | ## }}}
|
311 | 324 | } else {
|
312 | 325 | ## Report that the simulation failed to build
|
|
360 | 373 | open(TL, $testlist);
|
361 | 374 | while($line = <TL>) {
|
362 | 375 | next if ($line =~ /^\s*#/);
|
| 376 | + |
| 377 | + if ($ntasks >= $maxtasks) { |
| 378 | + if (waitpid(-1,0) eq 0) { |
| 379 | + $ntasks = 0; |
| 380 | + } else { |
| 381 | + $ntasks = $ntasks - 1; |
| 382 | + } |
| 383 | + } |
| 384 | + |
363 | 385 | simline($line);
|
| 386 | + $ntasks = $ntasks + 1; |
| 387 | + } |
| 388 | + |
| 389 | + while(waitpid(-1,0) gt 0) { |
| 390 | + ; |
364 | 391 | }
|
365 | 392 |
|
366 | 393 | open(SUM,">> $report");
|
|
371 | 398 | $line = gettest($akey);
|
372 | 399 | next if ($line =~ /FAIL/);
|
373 | 400 | simline($line);
|
| 401 | + |
| 402 | + while(waitpid(-1,0) gt 0) { |
| 403 | + ; |
| 404 | + } |
374 | 405 | }
|
375 | 406 | }
|
376 | 407 | ## }}}
|
|
0 commit comments