template defproc source_sequence_multi (chan!(int) O[OUT_CHANNELS]) { int i; int buf; chp { *[ i := 0; *[ i < N -> // select the right data element [([]k:N: i=k -> buf := DATA[k])]; // and send it to every channel (, j : OUT_CHANNELS : O[j]!buf; // if logging was enabled, log the send [ LOG -> log ("Source ", SOURCE_ID, " (Channel ", j, "): Sent value ", buf, "%x (0x", buf, ")") [] else -> skip ] ); i := i + 1 ] <- LOOP ]; log ("Source ", SOURCE_ID, ": Sequence ended.") } } template defproc lockstep (chan?(int) IN[IN_CHANNELS]; chan?(int) OUT_M[OUT_CHANNELS], OUT_D[OUT_CHANNELS]) { int input[IN_CHANNELS]; int output_m[OUT_CHANNELS], output_d[OUT_CHANNELS]; bool not_failed; int num; chp { num := 0; *[ // receive the data (, i : IN_CHANNELS : IN[i]?input[i]), (, i : OUT_CHANNELS : OUT_M[i]?output_m[i]), (, j : OUT_CHANNELS : OUT_D[j]?output_d[j]); // check the results not_failed+; (; i : OUT_CHANNELS : [not_failed -> not_failed := output_m[i] = output_d[i] [] else -> skip]); // print the output [ not_failed -> ( // only print successful tests if verbose testing is enabled [ VERBOSE_TESTING -> ( log_st (""); log_p ("Scoreboard ", SB_ID, ": TEST SUCCESS (", num, "); inputs {"); (; i : IN_CHANNELS : log_p (i, ": ", input[i], "%x (0x", input[i], "); ")); log_p ("}, outputs {"); (; i : OUT_CHANNELS : log_p (i, ": ", output_d[i], "%x (0x", output_d[i], "); ")); log_p ("}"); log_nl ("") ) [] else -> ( skip )] ) [] else -> ( log_st (""); log_p ("Scoreboard ", SB_ID, ": TEST FAILED (", num, "); inputs {"); (; i : IN_CHANNELS : log_p (i, ": ", input[i], "%x (0x", input[i], "); ")); log_p ("}, outputs {"); (; i : OUT_CHANNELS : log_p (i, ": expected ", output_m[i], "%x (0x", output_m[i], "), got ", output_d[i], "%x (0x", output_d[i], "); ")); log_p ("}"); log_nl ("") )]; num := num + 1 ] } }