59 lines
1.2 KiB
Text
59 lines
1.2 KiB
Text
|
|
import "simlib.act";
|
|
import "mult_wrapper.act";
|
|
import "globals.act";
|
|
|
|
template<pint IN_WIDTH, OUT_WIDTH>
|
|
defproc mul_model (chan(int<IN_WIDTH>)? A,B; chan(int<OUT_WIDTH>)! RES; bool reset) {
|
|
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 = 5;
|
|
pint in_seq_a[IN_SEQ_L];
|
|
pint in_seq_b[IN_SEQ_L];
|
|
in_seq_a = {7, 6, 5, 1, 3};
|
|
in_seq_b = {4, 0, 3, 5, 9};
|
|
|
|
// 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<IN_WIDTH, 3, IN_SEQ_L, in_seq_a, false, 1, true> a_src;
|
|
source_sequence_multi<IN_WIDTH, 3, IN_SEQ_L, in_seq_b, false, 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.O[2];
|
|
sb.IN[1] = b_src.O[2];
|
|
sb.OUT_M[0] = model.RES;
|
|
sb.OUT_D[0] = dut.RES;
|
|
|
|
}
|
|
|
|
Initialize {
|
|
actions { Reset+ };
|
|
actions { Reset- }
|
|
}
|