diff --git a/pipelined/srt/Makefile b/pipelined/srt/Makefile index c3c69df8c..63146339c 100644 --- a/pipelined/srt/Makefile +++ b/pipelined/srt/Makefile @@ -1,4 +1,4 @@ -all: exptestgen testgen qslc_r4a2 +all: exptestgen testgen qslc_r4a2 qslc_r4a2b sqrttestgen: sqrttestgen.c gcc sqrttestgen.c -o sqrttestgen -lm @@ -15,5 +15,9 @@ qslc_r4a2: qslc_r4a2.c gcc qslc_r4a2.c -o qslc_r4a2 -lm ./qslc_r4a2 > qslc_r4a2.sv +qslc_r4a2b: qslc_r4a2b.c + gcc qslc_r4a2b.c -o qslc_r4a2b -lm + ./qslc_r4a2b > qslc_r4a2b.tv + clean: rm -f testgen exptestgen qslc_r4a2 diff --git a/pipelined/srt/qslc_r4a2b b/pipelined/srt/qslc_r4a2b new file mode 100755 index 000000000..f719bbf47 Binary files /dev/null and b/pipelined/srt/qslc_r4a2b differ diff --git a/pipelined/srt/qslc_r4a2b.c b/pipelined/srt/qslc_r4a2b.c new file mode 100644 index 000000000..94a3a4cd4 --- /dev/null +++ b/pipelined/srt/qslc_r4a2b.c @@ -0,0 +1,190 @@ +/* + Program: qslc_r4a2.c + Description: Prints out Quotient Selection Table (assumes CPA is utilized to reduce memory) + User: James E. Stine + +*/ + +#include +#include + +#define DIVISOR_SIZE 3 +#define CARRY_SIZE 7 +#define SUM_SIZE 7 +#define TOT_SIZE 7 + +void disp_binary(double, int, int); + +struct bits { + unsigned int divisor : DIVISOR_SIZE; + int tot : TOT_SIZE; +} pla; + +/* + + Function: disp_binary + Description: This function displays a Double-Precision number into + four 16 bit integers using the global union variable + dp_number + Argument List: double x The value to be converted + int bits_to_left Number of bits left of radix point + int bits_to_right Number of bits right of radix point + Return value: none + +*/ +void disp_binary(double x, int bits_to_left, int bits_to_right) { + int i; + double diff; + + if (fabs(x) < pow(2.0, ((double) -bits_to_right)) ) { + for (i = -bits_to_left + 1; i <= bits_to_right; i++) { + printf("0"); + } + if (i == bits_to_right+1) + ; + + return; + } + + if (x < 0.0) + x = pow(2.0, ((double) bits_to_left)) + x; + + for (i = -bits_to_left + 1; i <= bits_to_right; i++) { + diff = pow(2.0, ((double) -i) ); + if (x < diff) + printf("0"); + else { + printf("1"); + x -= diff; + } + if (i == 0) + ; + + } + +} + +int main() { + int m; + int n; + int o; + pla.divisor = 0; + pla.tot = 0; + for (o=0; o < pow(2.0, DIVISOR_SIZE); o++) { + for (m=0; m < pow(2.0, TOT_SIZE); m++) { + /* + 4 bits for Radix 4 (a=2) + 1000 = +2 + 0100 = +1 + 0000 = 0 + 0010 = -1 + 0001 = -2 + */ + switch (pla.divisor) { + case 0: + if ((pla.tot) >= 12) + printf("8"); + else if ((pla.tot) >= 4) + printf("4"); + else if ((pla.tot) >= -4) + printf("0"); + else if ((pla.tot) >= -13) + printf("2"); + else + printf("1"); + break; + case 1: + if ((pla.tot) >= 14) + printf("8"); + else if ((pla.tot) >= 4) + printf("4"); + else if ((pla.tot) >= -6) + printf("0"); + else if ((pla.tot) >= -15) + printf("2"); + else + printf("1"); + break; + case 2: + if ((pla.tot) >= 15) + printf("8"); + else if ((pla.tot) >= 4) + printf("4"); + else if ((pla.tot) >= -6) + printf("0"); + else if ((pla.tot) >= -16) + printf("2"); + else + printf("1"); + break; + case 3: + if ((pla.tot) >= 16) + printf("8"); + else if ((pla.tot) >= 4) + printf("4"); + else if ((pla.tot) >= -6) + printf("0"); + else if ((pla.tot) >= -18) + printf("2"); + else + printf("1"); + break; + case 4: + if ((pla.tot) >= 18) + printf("8"); + else if ((pla.tot) >= 6) + printf("4"); + else if ((pla.tot) >= -8) + printf("0"); + else if ((pla.tot) >= -20) + printf("2"); + else + printf("1"); + break; + case 5: + if ((pla.tot) >= 20) + printf("8"); + else if ((pla.tot) >= 6) + printf("4"); + else if ((pla.tot) >= -8) + printf("0"); + else if ((pla.tot) >= -20) + printf("2"); + else + printf("1"); + break; + case 6: + if ((pla.tot) >= 20) + printf("8"); + else if ((pla.tot) >= 8) + printf("4"); + else if ((pla.tot) >= -8) + printf("0"); + else if ((pla.tot) >= -22) + printf("2"); + else + printf("1"); + break; + case 7: + if ((pla.tot) >= 24) + printf("8"); + else if ((pla.tot) >= 8) + printf("4"); + else if ((pla.tot) >= -8) + printf("0"); + else if ((pla.tot) >= -24) + printf("2"); + else + printf("1"); + break; + default: printf ("X"); + + } + + printf("\n"); + (pla.tot)++; + } + (pla.divisor)++; + } + +} diff --git a/pipelined/srt/qslc_r4a2b.tv b/pipelined/srt/qslc_r4a2b.tv new file mode 100644 index 000000000..b92d81e8e --- /dev/null +++ b/pipelined/srt/qslc_r4a2b.tv @@ -0,0 +1,1024 @@ +0 +0 +0 +0 +4 +4 +4 +4 +4 +4 +4 +4 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +2 +2 +2 +2 +2 +2 +2 +2 +2 +0 +0 +0 +0 +0 +0 +0 +0 +4 +4 +4 +4 +4 +4 +4 +4 +4 +4 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1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4 +4 +4 +4 +4 +4 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/pipelined/srt/stine/notes b/pipelined/srt/stine/notes index 83be0f203..77311b177 100644 --- a/pipelined/srt/stine/notes +++ b/pipelined/srt/stine/notes @@ -9,7 +9,7 @@ D = 197/256 = 0.76953125 Note: Add lg(r) extra iterations due to shifting of computed q q_{computed} = q / radix -./srt4div 0.68359375 0.76953125 4 10 +./srt4div 0.68359375 0.76953125 8 10 r=2 X = 0.10011111