Following is a sample run of the compiler to compile a simple program, a four-bit ripple-carry adder. The program is:
/* return two bit result of x+y+c */
ADDSTAGE(x<1>, y<1>, c<1>)
{
DECL sum<1>, carry<1>, sum2<1>, carry2<1>, carryout<1>;
sum, carry = ADD(x, y);
sum2, carry2 = ADD(sum, c);
carryout = OR(carry, carry2);
RETURN sum2, carryout;
}
/* add 4bits+4bits -> 5 bits */
ADD4(x<4>, y<4>)
{
DECL sum<5>, c<1>;
sum<0>, c = ADD(x<0>, b<0>);
sum<1>, c = ADDSTAGE(x<1>, y<1>, c);
sum<2>, c = ADDSTAGE(x<2>, y<2>, c);
sum<3>, c = ADDSTAGE(x<3>, y<3>, c);
sum<4> = c;
RETURN sum;
}
INPUT a<4>@[0,2,4,6], b<4>@[1,3,5,7];
OUTPUT sum<5>@2;
sum = ADD4(a, b);
Here is a transcript of the compiler run. The resultant array is shown in Figure A.2. This array is printed with a very small scale so that it can fit on one page, and is thus hard to read.
CMD> arch arch/slant
CMD> dir lib
CMD> lib test
Reading definitions from lib/klibtest
OR...AND...NOT...ADD...ANDOR...
CMD> parse tests/new/ripple-4
Simulating...
CMD> set optimization sa
CMD> set sa_start_temp 1
CMD> set sa_num_iters 10
CMD> set sa_temp_scale .95
CMD> route2d
Placement Pass 1: 0..1..2..3..4..5..6..7..8..
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp 1, new cost 132...Picked node OR_11 for moving ideal pos
Old pos 5 new pos 4
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp 0.95, new cost 164...Rejecting!
Picked node OR_11 for moving ideal pos
Old pos 5 new pos 6
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp 0.9025, new cost 124...Accepting!
Picked node ADD_7 to change module - selected 1
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .857375, new cost 132...Rejecting!
Picked node ADD_9 to change module - selected 1
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .814506, new cost 132...Rejecting!
Picked node ADD_6 to change module - selected 1
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .773781, new cost 132...Rejecting!
Picked node OR_11 for moving ideal pos
Old pos 6 new pos 5
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .735092, new cost 132...Rejecting!
Picked node ADD_6 to change module - selected 1
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .698337, new cost 132...Rejecting!
Picked node ADD_7 to change module - selected 1
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp 0.66342, new cost 132...Rejecting!
Picked node ADD_10 for moving ideal pos
Old pos 4 new pos 3
Placement Pass 2: *0..1..2..3..4..5..6..7..8..*
Routing: 6..5..4..3..2..1..
Temp .630249, new cost 124...Accepting!
Routing: 6..5..4..3..2..1..
SA Optimization: 10 tried, initial cost 132, final cost 124
Final array size: 4 by 31 = 124
CMD> set ps_latex
CMD> set ps_nogrid
CMD> set ps_scale 17
CMD> postscript ripple-4.ps
Printout will take 1 by 1 = 1 pages total
Page 0,0
CMD> quit