From 14fe1d87681c4d01ad4175074bc60dd15be14fef Mon Sep 17 00:00:00 2001 From: Michele Date: Fri, 21 Oct 2022 15:59:49 +0200 Subject: [PATCH] helloworld works --- act/actsim_test_bench_lib.conf | 4 +- act/test_bench_lib.act | 70 +++++++++++++++++++++++++--------- act/test_bench_lib.c | 2 +- test/examples/helloworld.act | 8 ++-- 4 files changed, 59 insertions(+), 25 deletions(-) diff --git a/act/actsim_test_bench_lib.conf b/act/actsim_test_bench_lib.conf index 2268ed4..c34316e 100644 --- a/act/actsim_test_bench_lib.conf +++ b/act/actsim_test_bench_lib.conf @@ -3,8 +3,8 @@ begin sim begin extern string_tablex libs "test_bench_lib" begin test_bench_lib - string path "$ACT_HOME/lib/actsim_test_bench_lib.so" - string sim::testbench::fsource_init "source_init" + string path "${ACT_HOME}/lib/actsim_test_bench_lib.so" + string sim::testbench::finit "init_tb" string sim::testbench::fsource_next "source_next" string sim::testbench::fsource_get "source_get" string sim::testbench::fcheck_out_of_order "check_out_of_order" diff --git a/act/test_bench_lib.act b/act/test_bench_lib.act index 96e1aab..ff6c9d9 100644 --- a/act/test_bench_lib.act +++ b/act/test_bench_lib.act @@ -39,8 +39,8 @@ function fcontrol_get(int dontcare) : int; function fcontrol_wait(int dontcare) : int; -template -defproc channel_source(chan!(int) out; chan?(int) sim_step; chan!(int) done) +export template +defproc channel_source(chan!(int) out; chan?(int) sim_step; chan!(int<1>) done) { int current_step, t,data; chp { @@ -54,8 +54,8 @@ defproc channel_source(chan!(int) out; chan?(int) sim_step; chan!(int } } -template -defproc channel_checker_in_order(chan?(int) in; chan?(int) sim_step; chan!(int) done) +export template +defproc channel_checker_in_order(chan?(int) in; chan?(int) sim_step; chan!(int<1>) done) { int current_step, t, check, data; chp { @@ -72,7 +72,7 @@ defproc channel_checker_in_order(chan?(int) in; chan?(int) sim_step; } } -template +export template defproc channel_checker_out_of_order(chan?(int) in; chan?(int) sim_step; chan!(int<1>) done) { int current_step, t, check, data; @@ -90,7 +90,7 @@ defproc channel_checker_out_of_order(chan?(int) in; chan?(int) sim_st } } -template +export template defproc channel_dump(chan?(int) in; chan?(int) sim_step) { int current_step, t,in_tmp; @@ -103,31 +103,63 @@ defproc channel_dump(chan?(int) in; chan?(int) sim_step) } } -template -defproc control(chan(int) sim_step_source[NUMBER_SOURCE]; chan(int) sim_step_checker[NUMBER_CHECKER]; chan(int) sim_step_dump[NUMBER_DUMP]; chan?(int<1>) done_source[NUMBER_SOURCE]; chan?(int<1>) done_checker[NUMBER_CHECKER]) +defproc channel_dump_dummy(chan?(int) sim_step) +{ + chp { + *[ sim_step? ] + } +} + +defproc channel_source_dummy(chan?(int) sim_step; chan!(int<1>) done) +{ + chp { + *[ sim_step?;done!1 ] + } +} + +defproc channel_checker_dummy(chan?(int) sim_step; chan!(int<1>) done) +{ + chp { + *[ sim_step?;done!1 ] + } +} + +export template +defproc control(chan(int) sim_step_source[NUMBER_SOURCE+1]; chan(int) sim_step_checker[NUMBER_CHECKER+1]; chan(int) sim_step_dump[NUMBER_DUMP+1]; chan?(int<1>) done_source[NUMBER_SOURCE+1]; chan?(int<1>) done_checker[NUMBER_CHECKER+1]) { int current_step, wait; int<1> t, success, failure_free; + + //This is a workaround to permit to have 0 instances of a type. + channel_checker_dummy dummy1(.sim_step=sim_step_checker[NUMBER_CHECKER],.done=done_checker[NUMBER_CHECKER]); + channel_source_dummy dummy2(.sim_step=sim_step_source[NUMBER_SOURCE],.done=done_source[NUMBER_SOURCE]); + channel_dump_dummy dummy3(.sim_step=sim_step_dump[NUMBER_DUMP]); + chp { - t:=1; + log("I entered control"); + + t:=finit(1); failure_free:=1; - *[ t = 1 -> current_step := fcontrol_get(); + *[ t = 1 -> current_step := fcontrol_get(0); + log("I entered the t loop at current step:",current_step); [ current_step = 0 -> skip // reset here [] else -> - (,j:1..NUMBER_SOURCE: sim_step_source[j]!current_step), - (,j:1..NUMBER_CHECKER: sim_step_checker[j]!current_step), - (,j:1..NUMBER_DUMP: sim_step_dump[j]!current_step); - (;j:1..NUMBER_SOURCE: done_source[j]?success; failure_free := failure_free & success); - (;j:1..NUMBER_CHECKER: done_checker[j]?success; failure_free := failure_free & success) + (,j:0..NUMBER_SOURCE: sim_step_source[j]!current_step), + (,j:0..NUMBER_CHECKER: sim_step_checker[j]!current_step), + (,j:0..NUMBER_DUMP: sim_step_dump[j]!current_step); + (;j:0..NUMBER_SOURCE: done_source[j]?success; failure_free := failure_free & success); + (;j:0..NUMBER_CHECKER: done_checker[j]?success; failure_free := failure_free & success) ]; - wait := fcontrol_wait(); + wait := fcontrol_wait(0); [ wait > 0 -> skip // exec cycle [] else -> skip ]; - [ HALT_ON_FALIURE & ~failure_free -> t := 0; log("stopped testbech because of failure") - [] else -> t:=fcontrol_next() + [ HALT_ON_FALIURE & 0=failure_free -> t := 0; log("stopped testbech because of failure") + [] else -> t:=fcontrol_next(0); + log("I finished the t loop at current step:",current_step) ] - ] + ]; + log("I finished the program") } } } diff --git a/act/test_bench_lib.c b/act/test_bench_lib.c index 069890a..f6c8fb7 100644 --- a/act/test_bench_lib.c +++ b/act/test_bench_lib.c @@ -88,7 +88,7 @@ static unsigned int check_errors = 0; * verbose: 0 for normal pinting, 1 for verbose printing * it returns true on success */ -struct expr_res init (int num, struct expr_res *args) +struct expr_res init_tb (int num, struct expr_res *args) { struct expr_res t; t.v = 0; diff --git a/test/examples/helloworld.act b/test/examples/helloworld.act index da34fad..1c41327 100644 --- a/test/examples/helloworld.act +++ b/test/examples/helloworld.act @@ -25,10 +25,12 @@ import "../../act/test_bench_lib.act"; import globals; +open sim::testbench; defproc test(){ chan(int<5>) channel; - //sim::testbench::control<1,1,0,1> control; - //sim::testbench::channel_source<5,0> source(.out=channel,.sim_step=control.sim_step_source[0],.done=control.done_source[0]); - //sim::testbench::channel_checker_in_order<5,0> sink(.in=channel,.sim_step=control.sim_step_checker,.done=control.done_checker[0]); + control<1,1,0,true> control; + channel_source<5,0> source(.out=channel,.sim_step=control.sim_step_source[0],.done=control.done_source[0]); + channel_checker_in_order<5,0> sink(.in=channel,.sim_step=control.sim_step_checker[0],.done=control.done_checker[0]); + } \ No newline at end of file