Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
import "primitives/core.fil";
// M is some mystery parameter that is used to calculate L
comp Mul[W, M]<'G:1>(
go: interface['G],
left: ['G, 'G+1] W,
right: ['G, 'G+1] W
) -> (
out: ['G+L, 'G+L+1] W
) with {
some L where L > 0;
} where W > 0, M > 0 {
mult := new MultComb[W]<'G>(left, right);
sh := new Shift[W, M*M]<'G>(mult.out);
// This is the hidden value of the quantified parameter. This value is not
// visible to callers but is used to typecheck the body.
L := M*M;
out = sh.out;
}
// The main component is allowed to use existentially quantified variables.
// These are removed during monomorphization.
comp main<'G:1>(
go: interface['G],
in0: ['G, 'G+1] 32, in1: ['G+F, 'G+F+1] 32, in2: ['G+F2, 'G+F2+1] 32
) -> (out: ['G+L, 'G+L+1] 32) with {
some F; // The time when the second multiplication starts.
some F2; // The time when the third multiplication starts.
some L where L > 0; // The latency of the module.
} {
// Explicitly define the instance because we need to access the parameter.
M0 := new Mul[32, 2];
mul0 := M0<'G>(in0, in0);
// The next invoke is scheduled using the existentially quantified parameter.
M1 := new Mul[32, 3];
mul1 := M1<'G+M0::L>(mul0.out, in1);
// Next, test a reuse of the same instance.
mul2 := M1<'G+M0::L+M1::L>(mul1.out, in2);
// This module defines the (hidden) relationship that the latency is the sum of the
// the latencies of the two instances.
L := M0::L + 2*M1::L;
F := M0::L;
F2 := M0::L + M1::L;
out = mul2.out;
}7aa19ccf2This file is pinned to the selected release. Download the original to open it in your design tool.