diff --git a/pipelined/srt/Makefile b/pipelined/srt/Makefile index f2ed6f8c..5d7898b1 100644 --- a/pipelined/srt/Makefile +++ b/pipelined/srt/Makefile @@ -1,7 +1,8 @@ -all: exptestgen testgen qslc_r4a2 qslc_r4a2b qslc_sqrt_r4a2 +all: exptestgen testgen qslc_r4a2 qslc_r4a2b qslc_sqrt_r4a2 sqrttestgen sqrttestgen: sqrttestgen.c gcc sqrttestgen.c -o sqrttestgen -lm + ./sqrttestgen testgen: testgen.c gcc testgen.c -o testgen -lm @@ -28,5 +29,5 @@ inttestgen: inttestgen.c ./inttestgen clean: - rm -f testgen exptestgen qslc_r4a2 qslc_r4a2b qslc_sqrt_r4a2 + rm -f testgen exptestgen qslc_r4a2 qslc_r4a2b qslc_sqrt_r4a2 sqrttestgen diff --git a/pipelined/srt/sqrttestgen b/pipelined/srt/sqrttestgen index d4b68062..dadc5dc5 100755 Binary files a/pipelined/srt/sqrttestgen and b/pipelined/srt/sqrttestgen differ diff --git a/pipelined/srt/sqrttestgen.c b/pipelined/srt/sqrttestgen.c index 7b8cacd3..32c93f34 100644 --- a/pipelined/srt/sqrttestgen.c +++ b/pipelined/srt/sqrttestgen.c @@ -19,7 +19,7 @@ /* Prototypes */ -void output(FILE *fptr, double a, double r); +void output(FILE *fptr, int aExp, double aFrac, int rExp, double rFrac); void printhex(FILE *fptr, double x); double random_input(void); @@ -28,12 +28,16 @@ double random_input(void); void main(void) { FILE *fptr; - double a, b, r; - double list[ENTRIES] = {1, 1.5, 1.25, 1.125, 1.0625, + double aFrac, rFrac; + int aExp, rExp; + double mans[ENTRIES] = {1, 1.5, 1.25, 1.125, 1.0625, 1.75, 1.875, 1.99999, 1.1, 1.2, 1.01, 1.001, 1.0001, 1/1.1, 1/1.5, 1/1.25, 1/1.125}; - int i, j; + double exps[ENTRIES] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16}; + int i; + int bias = 1023; if ((fptr = fopen("sqrttestvectors","w")) == NULL) { fprintf(stderr, "Couldn't write sqrttestvectors file\n"); @@ -41,28 +45,31 @@ void main(void) } for (i=0; i 1) | ($signed(diffp) > 1) | (diffn === 64'bx) | (diffp === 64'bx)) // check if accurate to 1 ulp - begin - errors = errors+1; - $display("result was %h, should be %h %h %h\n", rInt, correctr, diffn, diffp); - $display("failed\n"); - $stop; - end - if (afrac === 52'hxxxxxxxxxxxxx) + end else if (~Sqrt) begin + req <= #5 1; + diffp = correctr[63:0] - rInt; + diffn = rInt - correctr[63:0]; + if (($signed(diffn) > 1) | ($signed(diffp) > 1) | (diffn === 64'bx) | (diffp === 64'bx)) // check if accurate to 1 ulp begin - $display("%d Tests completed successfully", testnum); + errors = errors+1; + $display("result was %h, should be %h %h %h\n", rInt, correctr, diffn, diffp); + $display("failed\n"); $stop; end - end + if (afrac === 52'hxxxxxxxxxxxxx) + begin + $display("%d Tests completed successfully", testnum); + $stop; + end + end else begin + req <= #5 1; + diffp = correctr[51:0] - r; + diffn = r - correctr[51:0]; + if (($signed(diffn) > 1) | ($signed(diffp) > 1) | (diffn === 64'bx) | (diffp === 64'bx)) // check if accurate to 1 ulp + begin + errors = errors + 1; + $display("result was %h, should be %h %h %h\n", rSqrt, correctr, diffn, diffp); + $display("failed\n"); + $stop; + end + if (afrac === 52'hxxxxxxxxxxxxx) begin + $display("%d Tests completed successfully", testnum); + $stop; end end + end if (req) begin req <= #5 0; correctr = nextr; @@ -169,7 +182,6 @@ module testbench; {bsign, bExp, bfrac} = b; nextr = Vec[`memr]; end - end - + end endmodule