From 5612ca7041d1f1ca1bf1131c2f5aea3f22f3557b Mon Sep 17 00:00:00 2001 From: David Harris Date: Thu, 9 Jun 2022 17:26:47 +0000 Subject: [PATCH] qslc_r4a2 generator --- .gitignore | 4 +- pipelined/regression/sim-wally | 2 +- pipelined/regression/wave.do | 4 +- pipelined/src/uncore/uncore.sv | 2 +- pipelined/srt/Makefile | 13 ++- pipelined/srt/qslc_r4a2.c | 202 +++++++++++++++++++++++++++++++++ pipelined/srt/qst2.c | 201 -------------------------------- 7 files changed, 217 insertions(+), 211 deletions(-) create mode 100644 pipelined/srt/qslc_r4a2.c delete mode 100644 pipelined/srt/qst2.c diff --git a/.gitignore b/.gitignore index bed29cae1..c42bfc4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,6 @@ pipelined/config/rv64ic_orig synthDC/Summary.csv pipelined/srt/exptestgen pipelined/srt/testgen -pipelined/srt/qst2 +pipelined/srt/qslc_r4a2 +pipelined/srt/qslc_r4a2.sv +pipelined/srt/testvectors diff --git a/pipelined/regression/sim-wally b/pipelined/regression/sim-wally index a7dffc9ed..069851489 100755 --- a/pipelined/regression/sim-wally +++ b/pipelined/regression/sim-wally @@ -1,2 +1,2 @@ -vsim -do "do wally-pipelined.do rv32gc arch32f" +vsim -do "do wally-pipelined.do rv32gc arch32i" diff --git a/pipelined/regression/wave.do b/pipelined/regression/wave.do index ab6cbc46a..ecfc06d11 100644 --- a/pipelined/regression/wave.do +++ b/pipelined/regression/wave.do @@ -6,7 +6,7 @@ add wave -noupdate /testbench/reset_ext add wave -noupdate /testbench/memfilename add wave -noupdate /testbench/dut/core/SATP_REGW add wave -noupdate -group HDU -group hazards /testbench/dut/core/hzu/BPPredWrongE -add wave -noupdate -group HDU -group hazards /testbench/dut/core/hzu/CSRWritePendingDEM +add wave -noupdate -group HDU -group hazards /testbench/dut/core/hzu/CSRWriteFencePendingDEM add wave -noupdate -group HDU -group hazards /testbench/dut/core/hzu/RetM add wave -noupdate -group HDU -group hazards -color Pink /testbench/dut/core/hzu/TrapM add wave -noupdate -group HDU -group hazards /testbench/dut/core/hzu/LoadStallD @@ -468,7 +468,7 @@ add wave -noupdate -group {debug trace} -expand -group wb /testbench/PCW add wave -noupdate -group {pc selection} /testbench/dut/core/ifu/PCNext2F add wave -noupdate -group {pc selection} /testbench/dut/core/ifu/PrivilegedNextPCM add wave -noupdate -group {pc selection} /testbench/dut/core/ifu/PrivilegedChangePCM -add wave -noupdate -group ifu -color Gold /testbench/dut/core/lsu/bus/busdp/busfsm/BusCurrState +add wave -noupdate -group ifu -color Gold /testbench/dut/core/ifu/bus/busdp/busfsm/BusCurrState add wave -noupdate -group ifu /testbench/dut/core/ifu/IFUBusRead add wave -noupdate -group ifu /testbench/dut/core/ifu/IFUBusAdr add wave -noupdate -group ifu /testbench/dut/core/ifu/IFUBusAck diff --git a/pipelined/src/uncore/uncore.sv b/pipelined/src/uncore/uncore.sv index 488a61e0c..a69b7cd0c 100644 --- a/pipelined/src/uncore/uncore.sv +++ b/pipelined/src/uncore/uncore.sv @@ -92,7 +92,7 @@ module uncore ( // generate // on-chip RAM if (`RAM_SUPPORTED) begin : ram - ram_orig #( + ram #( .BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram ( .HCLK, .HRESETn, .HSELRam, .HADDR, diff --git a/pipelined/srt/Makefile b/pipelined/srt/Makefile index 6789c234c..759ca2393 100644 --- a/pipelined/srt/Makefile +++ b/pipelined/srt/Makefile @@ -1,16 +1,19 @@ -all: sqrttestgen testgen qst2 +all: exptestgen testgen qslc_r4a2 sqrttestgen: sqrttestgen.c gcc sqrttestgen.c -lm -o sqrttestgen testgen: testgen.c gcc testgen.c -lm -o testgen - -qst2: qst2.c - gcc qst2.c -lm -o qst2 - gcc -lm -o testgen testgen.c ./testgen exptestgen: exptestgen.c gcc -lm -o exptestgen exptestgen.c ./exptestgen + +qslc_r4a2: qslc_r4a2.c + gcc qslc_r4a2.c -lm -o qslc_r4a2 + ./qslc_r4a2 >> qslc_r4a2.sv + +clean: + rm -f testgen exptestgen qslc_r4a2 \ No newline at end of file diff --git a/pipelined/srt/qslc_r4a2.c b/pipelined/srt/qslc_r4a2.c new file mode 100644 index 000000000..07616979c --- /dev/null +++ b/pipelined/srt/qslc_r4a2.c @@ -0,0 +1,202 @@ +/* + 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) + printf(" "); + + 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) + //printf(" "); + + } + +} + + +int main() { + int m; + int n; + int o; + pla.divisor = 0; + pla.tot = 0; + + printf(" case({D[5:3],Wmsbs})"); + printf(" \n"); + for (o=0; o < pow(2.0, DIVISOR_SIZE); o++) { + for (m=0; m < pow(2.0, TOT_SIZE); m++) { + printf(" 10'b"); + disp_binary((double) pla.divisor, DIVISOR_SIZE, 0); + printf("_"); + disp_binary((double) pla.tot, TOT_SIZE, 0); + printf(": q = 4'b"); + + /* + 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("1000"); + else if ((pla.tot) >= 4) + printf("0100"); + else if ((pla.tot) >= -4) + printf("0000"); + else if ((pla.tot) >= -13) + printf("0010"); + else + printf("0001"); + break; + case 1: + if ((pla.tot) >= 14) + printf("1000"); + else if ((pla.tot) >= 4) + printf("0100"); + else if ((pla.tot) >= -6) + printf("0000"); + else if ((pla.tot) >= -15) + printf("0010"); + else + printf("0001"); + break; + case 2: + if ((pla.tot) >= 15) + printf("1000"); + else if ((pla.tot) >= 4) + printf("0100"); + else if ((pla.tot) >= -6) + printf("0000"); + else if ((pla.tot) >= -16) + printf("0010"); + else + printf("0001"); + break; + case 3: + if ((pla.tot) >= 16) + printf("1000"); + else if ((pla.tot) >= 4) + printf("0100"); + else if ((pla.tot) >= -6) + printf("0000"); + else if ((pla.tot) >= -18) + printf("0010"); + else + printf("0001"); + break; + case 4: + if ((pla.tot) >= 18) + printf("1000"); + else if ((pla.tot) >= 6) + printf("0100"); + else if ((pla.tot) >= -8) + printf("0000"); + else if ((pla.tot) >= -20) + printf("0010"); + else + printf("0001"); + break; + case 5: + if ((pla.tot) >= 20) + printf("1000"); + else if ((pla.tot) >= 6) + printf("0100"); + else if ((pla.tot) >= -8) + printf("0000"); + else if ((pla.tot) >= -20) + printf("0010"); + else + printf("0001"); + break; + case 6: + if ((pla.tot) >= 20) + printf("1000"); + else if ((pla.tot) >= 8) + printf("0100"); + else if ((pla.tot) >= -8) + printf("0000"); + else if ((pla.tot) >= -22) + printf("0010"); + else + printf("0001"); + break; + case 7: + if ((pla.tot) >= 24) + printf("1000"); + else if ((pla.tot) >= 8) + printf("0100"); + else if ((pla.tot) >= -8) + printf("0000"); + else if ((pla.tot) >= -24) + printf("0010"); + else + printf("0001"); + break; + default: printf ("XXX"); + + } + + printf(";\n"); + (pla.tot)++; + } + (pla.divisor)++; + } + printf(" endcase\n"); +} diff --git a/pipelined/srt/qst2.c b/pipelined/srt/qst2.c deleted file mode 100644 index 503a240a0..000000000 --- a/pipelined/srt/qst2.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - Program: qst2.c - Description: Prints out QST (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) - printf(" "); - - 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) - printf(" "); - - } - -} - - -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++) { - disp_binary((double) pla.divisor, DIVISOR_SIZE, 0); - disp_binary((double) pla.tot, TOT_SIZE, 0); - - /* - 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(" 1000"); - else if ((pla.tot) >= 4) - printf(" 0100"); - else if ((pla.tot) >= -4) - printf(" 0000"); - else if ((pla.tot) >= -13) - printf(" 0010"); - else - printf(" 0001"); - break; - case 1: - if ((pla.tot) >= 14) - printf(" 1000"); - else if ((pla.tot) >= 4) - printf(" 0100"); - else if ((pla.tot) >= -6) - printf(" 0000"); - else if ((pla.tot) >= -15) - printf(" 0010"); - else - printf(" 0001"); - break; - case 2: - if ((pla.tot) >= 15) - printf(" 1000"); - else if ((pla.tot) >= 4) - printf(" 0100"); - else if ((pla.tot) >= -6) - printf(" 0000"); - else if ((pla.tot) >= -16) - printf(" 0010"); - else - printf(" 0001"); - break; - case 3: - if ((pla.tot) >= 16) - printf(" 1000"); - else if ((pla.tot) >= 4) - printf(" 0100"); - else if ((pla.tot) >= -6) - printf(" 0000"); - else if ((pla.tot) >= -18) - printf(" 0010"); - else - printf(" 0001"); - break; - case 4: - if ((pla.tot) >= 18) - printf(" 1000"); - else if ((pla.tot) >= 6) - printf(" 0100"); - else if ((pla.tot) >= -8) - printf(" 0000"); - else if ((pla.tot) >= -20) - printf(" 0010"); - else - printf(" 0001"); - break; - case 5: - if ((pla.tot) >= 20) - printf(" 1000"); - else if ((pla.tot) >= 6) - printf(" 0100"); - else if ((pla.tot) >= -8) - printf(" 0000"); - else if ((pla.tot) >= -20) - printf(" 0010"); - else - printf(" 0001"); - break; - case 6: - if ((pla.tot) >= 20) - printf(" 1000"); - else if ((pla.tot) >= 8) - printf(" 0100"); - else if ((pla.tot) >= -8) - printf(" 0000"); - else if ((pla.tot) >= -22) - printf(" 0010"); - else - printf(" 0001"); - break; - case 7: - if ((pla.tot) >= 24) - printf(" 1000"); - else if ((pla.tot) >= 8) - printf(" 0100"); - else if ((pla.tot) >= -8) - printf(" 0000"); - else if ((pla.tot) >= -24) - printf(" 0010"); - else - printf(" 0001"); - break; - default: - printf (" XXX"); - - } - - printf("\n"); - (pla.tot)++; - } - (pla.divisor)++; - } - - -}