
202 CHAPTER 8 TIE
operation ADD {out AR res, in AR in0, in AR in1} {
assign res = in0 + in1;
}
operation SUB {out AR res, in AR in0, in AR in1} {
assign res = in0 – in1;
}
semantic addsub {ADD, SUB} {
wire carry = SUB;
wire [31:0] tmp = ADD ? in1 : ∼ in1;
assign res = TIEadd(in0, tmp, carry);
}
The semantic addsub implements the instructions ADD and SUB. It uses the simple
principle of 2’s complement arithmetic that (
a ⫺ b) is equal to (a ⫹ ∼b ⫹ 1). For
every instr uction implemented in aTIE semantic,a 1-hot signal with the same name
as the instruction is available in the semantic. This signal is true when the corre-
sponding instruction is being executed, ...