
8.6 Language Constructs for Efficient Hardware Implementation 203
is to encapsulate the computation for modular code development. The following
example demonstrates the use of shared functions for the
ADD and SUB instruction
of Section 8.6.1.
function [31:0] addsub([31:0]in0, [31:0]in1, cin) shared {
assign addsub = TIEadd(in0, in1, cin);
}
operation ADD {out AR res, in AR input0, in AR input1 } {
assign res = addsub(input0, input1, 1’b0);
}
operation SUB {out AR res, in AR input0, in AR input1 } {
assign res = addsub(input0, ∼ input1, 1’b1);
}
Instead of writing a semantic for the two instructions to share the 32-bit adder,
the adder is encapsulated in a