From 2faa8847f475ce278d18493a22726f06482cf1af Mon Sep 17 00:00:00 2001 From: cturek Date: Tue, 5 Jul 2022 21:34:49 +0000 Subject: [PATCH] Radix 2 Integer division working (without signs or remainder) --- pipelined/srt/inttestgen | Bin 0 -> 18496 bytes pipelined/srt/inttestgen.c | 83 +++++++++++++++++++++ pipelined/srt/srt-waves.do | 2 + pipelined/srt/srt.sv | 128 ++++++++++--------------------- pipelined/srt/testbench.sv | 149 ++++++++++++++++++++----------------- 5 files changed, 205 insertions(+), 157 deletions(-) create mode 100755 pipelined/srt/inttestgen create mode 100644 pipelined/srt/inttestgen.c diff --git a/pipelined/srt/inttestgen b/pipelined/srt/inttestgen new file mode 100755 index 0000000000000000000000000000000000000000..2f7e6819945a6b827154fdc1c264eb7d77a29312 GIT binary patch literal 18496 zcmeHPe{fty9pAf4)1`X=lf%Kzq@bW?%r;0j`sEVeLhCP&pyL2HQA_gNPII^q6nZW>txOF z{c-j&)(Ghaj=>kFs*TP`(?pv%m$3j))a&#MpwqAN2+{Ke%!pD6k^i{CbioY|{E!EJ zs|S7w;0k=4K?lGs-!FRLH+kS209WAS3^@SY?B4+RVz!L!ZQ09JsDCnOzhP{y4NUKi zZPgP-&KOMPO(PfEx;dTA7_s=iw83bekh6$Enw!kjUhGFdV^Vq{oy zq+kxPN1z%cq+rT^!0Xa*4KvDhSy`U zeb9HrKZ*&893Sfk3F^;<<*8=uCg0(;Wo$aMm&fqgz`jIb#)8u`guGb`ZhfBSEVz6$ zxhe81j!6qSBEFVMf6s>`^?T$f799IOg;f^ZI=;1AaI{6C(}Gvp6qu?72S-$bX2J2< zpzycQ$KTS%UvJVT=DpagFzwco=`SDG#(&l{#YM{NUjn$i@@4oAtxzF`=^^Bum@Y$D z`8!ObYfl{K>1Q#GRX$PT>0e+Pt9s&Lp8hGO(d8#5dHP3~#wwpU%+o)>G`jx87^Ja$ z9e?R9K68y$d`TOBdA2{+d#u#HKxNvoqormf#}3YiaxGmBdVfER@>9uhXvHmHfw9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zUc$6IXrTbl8c3h$tH8ACSN45n2K`oLh?5@CHyrx3e(#t1&i0bksaXAov`OWs^t|w9{zUPbHr)|K8QPb=MP~fi$4FC9xB5`uw@RvEks6cF w0ltTJz=!-s<1gMnq`C_Y@m=Z^^i^tj$)s|VEZ*gE)4%r$A#tul!I5PD2GMl$c>n+a literal 0 HcmV?d00001 diff --git a/pipelined/srt/inttestgen.c b/pipelined/srt/inttestgen.c new file mode 100644 index 000000000..17ec9299e --- /dev/null +++ b/pipelined/srt/inttestgen.c @@ -0,0 +1,83 @@ +/* testgen.c */ + +/* Written 10/31/96 by David Harris + + This program creates test vectors for mantissa component + of an IEEE floating point divider. + */ + +/* #includes */ + +#include +#include +#include + +/* Constants */ + +#define ENTRIES 10 +#define RANDOM_VECS 500 + +/* Prototypes */ + +void output(FILE *fptr, long a, long b, long r, long rem); +void printhex(FILE *fptr, long x); +double random_input(void); + +/* Main */ + +void main(void) +{ + FILE *fptr; + long a, b, r, rem; + long list[ENTRIES] = {1, 3, 5, 18, 25, 33, 42, 65, 103, 255}; + int i, j; + + if ((fptr = fopen("inttestvectors","w")) == NULL) { + fprintf(stderr, "Couldn't write testvectors file\n"); + exit(1); + } + + 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_%h, should be %h %h %h\n", rExp, r, correctr, diffn, diffp); - $display("failed\n"); - $stop; - end - if (r !== rOTFC) // Check if OTFC works - begin - errors = errors+1; - $display("OTFC is %h, should be %h\n", rOTFC, r); - $display("failed\n"); - // $stop; + rInt = Quot; + if (done) begin + if (~Int) begin + req <= #5 1; + diffp = correctr[51:0] - r; + diffn = r - correctr[51:0]; + if ((rsign !== correctr[63]) | (rExp !== correctr[62:52]) | ($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_%h, should be %h %h %h\n", rExp, r, correctr, diffn, diffp); + $display("failed\n"); + $stop; + end + if (afrac === 52'hxxxxxxxxxxxxx) + begin + $display("%d Tests completed successfully", testnum); + $stop; + end + end else 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 + 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) + begin + $display("%d Tests completed successfully", testnum); + $stop; + end + end end - if (afrac === 52'hxxxxxxxxxxxxx) - begin - $display("%d Tests completed successfully", testnum); - $stop; - end - end - if (req) - begin - req <= #5 0; - correctr = nextr; - testnum = testnum+1; - Vec = Tests[testnum]; - $display("a = %h b = %h",a,b); - a = Vec[`mema]; - {asign, aExp, afrac} = a; - b = Vec[`memb]; - {bsign, bExp, bfrac} = b; - nextr = Vec[`memr]; - end + if (req) begin + req <= #5 0; + correctr = nextr; + testnum = testnum+1; + Vec = Tests[testnum]; + $display("a = %h b = %h",a,b); + a = Vec[`mema]; + {asign, aExp, afrac} = a; + b = Vec[`memb]; + {bsign, bExp, bfrac} = b; + nextr = Vec[`memr]; + end end endmodule