helloworld works

This commit is contained in:
M. Mastella 2022-10-21 15:59:49 +02:00
parent 23390aab88
commit 14fe1d8768
4 changed files with 59 additions and 25 deletions

View File

@ -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"

View File

@ -39,8 +39,8 @@ function fcontrol_get(int dontcare) : int;
function fcontrol_wait(int dontcare) : int;
template<pint BIT_WIDTH;pint ID>
defproc channel_source(chan!(int<BIT_WIDTH>) out; chan?(int) sim_step; chan!(int) done)
export template<pint BIT_WIDTH;pint ID>
defproc channel_source(chan!(int<BIT_WIDTH>) out; chan?(int) sim_step; chan!(int<1>) done)
{
int current_step, t,data;
chp {
@ -54,8 +54,8 @@ defproc channel_source(chan!(int<BIT_WIDTH>) out; chan?(int) sim_step; chan!(int
}
}
template<pint BIT_WIDTH;pint ID>
defproc channel_checker_in_order(chan?(int<BIT_WIDTH>) in; chan?(int) sim_step; chan!(int) done)
export template<pint BIT_WIDTH;pint ID>
defproc channel_checker_in_order(chan?(int<BIT_WIDTH>) 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<BIT_WIDTH>) in; chan?(int) sim_step;
}
}
template<pint BIT_WIDTH;pint ID>
export template<pint BIT_WIDTH;pint ID>
defproc channel_checker_out_of_order(chan?(int<BIT_WIDTH>) 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<BIT_WIDTH>) in; chan?(int) sim_st
}
}
template<pint BIT_WIDTH;pint ID>
export template<pint BIT_WIDTH;pint ID>
defproc channel_dump(chan?(int<BIT_WIDTH>) in; chan?(int) sim_step)
{
int current_step, t,in_tmp;
@ -103,31 +103,63 @@ defproc channel_dump(chan?(int<BIT_WIDTH>) in; chan?(int) sim_step)
}
}
template<pint NUMBER_SOURCE,NUMBER_CHECKER,NUMBER_DUMP;pbool HALT_ON_FALIURE>
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<pint NUMBER_SOURCE,NUMBER_CHECKER,NUMBER_DUMP;pbool HALT_ON_FALIURE>
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")
}
}
}

View File

@ -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;

View File

@ -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]);
}