fault_injection_async25_paper/test-circuit/testbench.act
2025-01-09 18:43:15 +01:00

61 lines
1.3 KiB
Text

import "simlib.act";
import "mult_wrapper.act";
template<pint IN_WIDTH, OUT_WIDTH>
defproc mul_model (chan(int<IN_WIDTH>)? A,B; chan(int<OUT_WIDTH>)! RES; bool res) {
int<IN_WIDTH> a, b;
int<OUT_WIDTH>res;
chp {
*[
[#A];
B?b, A?a;
RES!(a*b)
]
}
}
defproc tb() {
pint IN_WIDTH = 4;
pint OUT_WIDTH = 8;
pint IN_SEQ_L = 8;
pint in_seq_a[IN_SEQ_L];
pint in_seq_b[IN_SEQ_L];
in_seq_a = {7, 6, 5, 1, 2, 3, 0, 4};
in_seq_b = {4, 0, 3, 2, 1, 5, 6, 7};
// model and DUT
mul_model<IN_WIDTH, OUT_WIDTH> model;
pipelined_mult dut;
// simulation harness
lockstep<IN_WIDTH, OUT_WIDTH, 2, 1, 1, true> sb;
source_sequence_multi<true, IN_D_WIDTH, 3, IN_SEQ_L, in_seq_a, true, 1, true> a_src;
source_sequence_multi<true, IN_D_WIDTH, 3, IN_SEQ_L, in_seq_b, true, 2, true> b_src;
// model inputs
model.A = a_src.O[0];
model.B = b_src.O[0];
// DUT inputs
dut.A = a_src.O[1];
dut.b = b_src.O[1];
// scoreboard inputs
sb.IN[0] = a_src[2];
sb.IN[1] = b_src[2];
sb.OUT_M[0] = model.RES;
sb.OUT_D[0] = dut.RES;
chp {
a_src.enable-, b_src.enable-;
dut.reset+;
[after=1000];
dut.reset-;
a_src.enable+, b_src.enable+
}
}