Merge branch 'main' of github.com:davidharrishmc/riscv-wally into main

This commit is contained in:
slmnemo 2022-05-19 17:51:45 -07:00
commit 79c28d34dc
18 changed files with 2902 additions and 292 deletions

@ -1 +1 @@
Subproject commit 307c77b26e070ae85ffea665ad9b642b40e33c86 Subproject commit be67c99bd461742aa1c100bcc0732657faae2230

View File

@ -38,12 +38,13 @@
`define IEEE754 1 `define IEEE754 1
// MISA RISC-V configuration per specification // MISA RISC-V configuration per specification
`define MISA (32'h00000104 | 1 << 5 | 0 << 3 | 1 << 18 | 1 << 20 | 1 << 12 | 1 << 0 ) //16 - quad 3 - double 5 - single
`define MISA (32'h00000104 | 1 << 5 | 1 << 3 | 1 << 16 | 1 << 18 | 1 << 20 | 1 << 12 | 1 << 0 )
`define ZICSR_SUPPORTED 1 `define ZICSR_SUPPORTED 1
`define ZIFENCEI_SUPPORTED 1 `define ZIFENCEI_SUPPORTED 1
`define COUNTERS 32 `define COUNTERS 32
`define ZICOUNTERS_SUPPORTED 1 `define ZICOUNTERS_SUPPORTED 1
`define ZFH_SUPPORTED 0 `define ZFH_SUPPORTED 1
/// Microarchitectural Features /// Microarchitectural Features
`define UARCH_PIPELINED 1 `define UARCH_PIPELINED 1

View File

@ -0,0 +1,52 @@
# wally-pipelined.do
#
# Modification by Oklahoma State University & Harvey Mudd College
# Use with Testbench
# James Stine, 2008; David Harris 2021
# Go Cowboys!!!!!!
#
# Takes 1:10 to run RV64IC tests using gui
# run with vsim -do "do wally-pipelined.do rv64ic riscvarchtest-64m"
# Use this wally-pipelined.do file to run this example.
# Either bring up ModelSim and type the following at the "ModelSim>" prompt:
# do wally-pipelined.do
# or, to run from a shell, type the following at the shell prompt:
# vsim -do wally-pipelined.do -c
# (omit the "-c" to see the GUI while running from the shell)
onbreak {resume}
# create library
if [file exists work] {
vdel -all
}
vlib work
# compile source files
# suppress spurious warnngs about
# "Extra checking for conflicts with always_comb done at vopt time"
# because vsim will run vopt
# start and run simulation
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
# $num = the added words after the call
vlog +incdir+../config/$1 +incdir+../config/shared ../testbench/testbench-fp.sv ../src/fpu/*.sv -suppress 2583,7063,8607,2697
vsim -voptargs=+acc work.testbenchfp -G TEST=$2
view wave
#-- display input and output signals as hexidecimal values
#do ./wave-dos/peripheral-waves.do
#add log -recursive /*
#do wave.do deal with when ready
do wave-fpu.do
#-- Run the Simulation
#run 3600
run -all
noview testbench-fp.sv
view wave

11
pipelined/regression/sim-fp Executable file
View File

@ -0,0 +1,11 @@
# cvtint - test integer conversion unit (fcvtint)
# cvtfp - test floating-point conversion unit (fcvtfp)
# cmp - test comparison unit's LT, LE, EQ opperations (fcmp)
# add - test addition
# sub - test subtraction
# div - test division
# sqrt - test square root
# all - test everything
vsim -do "do fp.do rv64fp mul"

View File

@ -0,0 +1,10 @@
# cvtint - test integer conversion unit (fcvtint)
# cvtfp - test floating-point conversion unit (fcvtfp)
# cmp - test comparison unit's LT, LE, EQ opperations (fcmp)
# add - test addition
# sub - test subtraction
# div - test division
# sqrt - test square root
# all - test everything
vsim -c -do "do fp.do rv64fp mul"

View File

@ -0,0 +1,102 @@
add wave -noupdate /testbenchfp/clk
add wave -noupdate -radix decimal /testbenchfp/VectorNum
add wave -group Other -noupdate /testbenchfp/FrmNum
add wave -group Other -noupdate /testbenchfp/X
add wave -group Other -noupdate /testbenchfp/Y
add wave -group Other -noupdate /testbenchfp/Z
add wave -group Other -noupdate /testbenchfp/Res
add wave -group Other -noupdate /testbenchfp/Ans
add wave -group Rne -noupdate /testbenchfp/FmaRneX
add wave -group Rne -noupdate /testbenchfp/FmaRneY
add wave -group Rne -noupdate /testbenchfp/FmaRneZ
add wave -group Rne -noupdate /testbenchfp/FmaRneRes
add wave -group Rne -noupdate /testbenchfp/FmaRneAns
add wave -group Rz -noupdate /testbenchfp/FmaRzX
add wave -group Rz -noupdate /testbenchfp/FmaRzY
add wave -group Rz -noupdate /testbenchfp/FmaRzZ
add wave -group Rz -noupdate /testbenchfp/FmaRzRes
add wave -group Rz -noupdate /testbenchfp/FmaRzAns
add wave -group Ru -noupdate /testbenchfp/FmaRuX
add wave -group Ru -noupdate /testbenchfp/FmaRuY
add wave -group Ru -noupdate /testbenchfp/FmaRuZ
add wave -group Ru -noupdate /testbenchfp/FmaRuRes
add wave -group Ru -noupdate /testbenchfp/FmaRuAns
add wave -group Rd -noupdate /testbenchfp/FmaRdX
add wave -group Rd -noupdate /testbenchfp/FmaRdY
add wave -group Rd -noupdate /testbenchfp/FmaRdZ
add wave -group Rd -noupdate /testbenchfp/FmaRdRes
add wave -group Rd -noupdate /testbenchfp/FmaRdAns
add wave -group Rnm -noupdate /testbenchfp/FmaRnmX
add wave -group Rnm -noupdate /testbenchfp/FmaRnmY
add wave -group Rnm -noupdate /testbenchfp/FmaRnmZ
add wave -group Rnm -noupdate /testbenchfp/FmaRnmRes
add wave -group Rnm -noupdate /testbenchfp/FmaRnmAns
add wave -group AllSignals -noupdate /*
add wave -group AllSignals -noupdate /testbenchfp/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/expadd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/mult/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/align/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/sign/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/add/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rne/loa/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/normalize/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/fmaround/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/resultsign/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/fmaflags/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rne/resultselect/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/expadd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/mult/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/align/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/sign/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/add/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rz/loa/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/normalize/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/fmaround/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/resultsign/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/fmaflags/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rz/resultselect/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/expadd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/mult/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/align/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/sign/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/add/*
add wave -group AllSignals -noupdate /testbenchfp/fma1ru/loa/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/normalize/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/fmaround/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/resultsign/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/fmaflags/*
add wave -group AllSignals -noupdate /testbenchfp/fma2ru/resultselect/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/expadd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/mult/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/align/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/sign/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/add/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rd/loa/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/normalize/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/fmaround/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/resultsign/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/fmaflags/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rd/resultselect/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/expadd/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/mult/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/align/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/sign/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/add/*
add wave -group AllSignals -noupdate /testbenchfp/fma1rnm/loa/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/normalize/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/fmaround/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/resultsign/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/fmaflags/*
add wave -group AllSignals -noupdate /testbenchfp/fma2rnm/resultselect/*

View File

@ -1,6 +1,6 @@
`include "wally-config.vh" `include "wally-config.vh"
module cvtfp ( module fcvtfp (
input logic [10:0] XExpE, // input's exponent input logic [10:0] XExpE, // input's exponent
input logic [52:0] XManE, // input's mantissa input logic [52:0] XManE, // input's mantissa
input logic XSgnE, // input's sign input logic XSgnE, // input's sign

View File

@ -2,7 +2,7 @@
`include "wally-config.vh" `include "wally-config.vh"
// `include "../../config/rv64icfd/wally-config.vh" // `include "../../config/rv64icfd/wally-config.vh"
// `define XLEN 64 // `define XLEN 64
module fcvt ( module fcvtint (
input logic XSgnE, // X's sign input logic XSgnE, // X's sign
input logic [10:0] XExpE, // X's exponent input logic [10:0] XExpE, // X's exponent
input logic [52:0] XManE, // X's fraction input logic [52:0] XManE, // X's fraction

View File

@ -43,6 +43,7 @@ module fma(
input logic XSgnM, YSgnM, // input signs - memory stage input logic XSgnM, YSgnM, // input signs - memory stage
input logic [`NE-1:0] ZExpM, // input exponents - memory stage input logic [`NE-1:0] ZExpM, // input exponents - memory stage
input logic [`NF:0] XManM, YManM, ZManM, // input mantissa - memory stage input logic [`NF:0] XManM, YManM, ZManM, // input mantissa - memory stage
input logic ZOrigDenormE, // is the original precision denormalized
input logic XDenormE, YDenormE, ZDenormE, // is denorm input logic XDenormE, YDenormE, ZDenormE, // is denorm
input logic XZeroE, YZeroE, ZZeroE, // is zero - execute stage input logic XZeroE, YZeroE, ZZeroE, // is zero - execute stage
input logic XNaNM, YNaNM, ZNaNM, // is NaN input logic XNaNM, YNaNM, ZNaNM, // is NaN
@ -72,6 +73,7 @@ module fma(
logic PSgnE, PSgnM; logic PSgnE, PSgnM;
logic [$clog2(3*`NF+7)-1:0] NormCntE, NormCntM; logic [$clog2(3*`NF+7)-1:0] NormCntE, NormCntM;
logic Mult; logic Mult;
logic ZOrigDenormM;
fma1 fma1 (.XSgnE, .YSgnE, .ZSgnE, .XExpE, .YExpE, .ZExpE, .XManE, .YManE, .ZManE, fma1 fma1 (.XSgnE, .YSgnE, .ZSgnE, .XExpE, .YExpE, .ZExpE, .XManE, .YManE, .ZManE,
.XDenormE, .YDenormE, .ZDenormE, .XZeroE, .YZeroE, .ZZeroE, .XDenormE, .YDenormE, .ZDenormE, .XZeroE, .YZeroE, .ZZeroE,
@ -81,11 +83,11 @@ module fma(
// E/M pipeline registers // E/M pipeline registers
flopenrc #(3*`NF+6) EMRegFma2(clk, reset, FlushM, ~StallM, SumE, SumM); flopenrc #(3*`NF+6) EMRegFma2(clk, reset, FlushM, ~StallM, SumE, SumM);
flopenrc #(13) EMRegFma3(clk, reset, FlushM, ~StallM, ProdExpE, ProdExpM); flopenrc #(13) EMRegFma3(clk, reset, FlushM, ~StallM, ProdExpE, ProdExpM);
flopenrc #($clog2(3*`NF+7)+7) EMRegFma4(clk, reset, FlushM, ~StallM, flopenrc #($clog2(3*`NF+7)+8) EMRegFma4(clk, reset, FlushM, ~StallM,
{AddendStickyE, KillProdE, InvZE, NormCntE, NegSumE, ZSgnEffE, PSgnE, FOpCtrlE[2]&~FOpCtrlE[1]&~FOpCtrlE[0]}, {AddendStickyE, KillProdE, InvZE, NormCntE, NegSumE, ZSgnEffE, PSgnE, FOpCtrlE[2]&~FOpCtrlE[1]&~FOpCtrlE[0], ZOrigDenormE},
{AddendStickyM, KillProdM, InvZM, NormCntM, NegSumM, ZSgnEffM, PSgnM, Mult}); {AddendStickyM, KillProdM, InvZM, NormCntM, NegSumM, ZSgnEffM, PSgnM, Mult, ZOrigDenormM});
fma2 fma2(.XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM, fma2 fma2(.XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM, .ZOrigDenormM,
.FrmM, .FmtM, .ProdExpM, .AddendStickyM, .KillProdM, .SumM, .NegSumM, .InvZM, .NormCntM, .ZSgnEffM, .PSgnM, .FrmM, .FmtM, .ProdExpM, .AddendStickyM, .KillProdM, .SumM, .NegSumM, .InvZM, .NormCntM, .ZSgnEffM, .PSgnM,
.XZeroM, .YZeroM, .ZZeroM, .XInfM, .YInfM, .ZInfM, .XNaNM, .YNaNM, .ZNaNM, .XSNaNM, .YSNaNM, .ZSNaNM, .Mult, .XZeroM, .YZeroM, .ZZeroM, .XInfM, .YInfM, .ZInfM, .XNaNM, .YNaNM, .ZNaNM, .XSNaNM, .YSNaNM, .ZSNaNM, .Mult,
.FMAResM, .FMAFlgM); .FMAResM, .FMAFlgM);
@ -448,6 +450,7 @@ module fma2(
input logic [3*`NF+5:0] SumM, // the positive sum input logic [3*`NF+5:0] SumM, // the positive sum
input logic NegSumM, // was the sum negitive input logic NegSumM, // was the sum negitive
input logic InvZM, // do you invert Z input logic InvZM, // do you invert Z
input logic ZOrigDenormM, // is the original precision denormalized
input logic ZSgnEffM, // the modified Z sign - depends on instruction input logic ZSgnEffM, // the modified Z sign - depends on instruction
input logic PSgnM, // the product's sign input logic PSgnM, // the product's sign
input logic Mult, // multiply opperation input logic Mult, // multiply opperation
@ -530,7 +533,7 @@ module fma2(
// Select the result // Select the result
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
resultselect resultselect(.XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM, resultselect resultselect(.XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM, .ZOrigDenormM,
.FrmM, .FmtM, .AddendStickyM, .KillProdM, .XInfM, .YInfM, .ZInfM, .XNaNM, .YNaNM, .ZNaNM, .RoundAdd, .FrmM, .FmtM, .AddendStickyM, .KillProdM, .XInfM, .YInfM, .ZInfM, .XNaNM, .YNaNM, .ZNaNM, .RoundAdd,
.ZSgnEffM, .PSgnM, .ResultSgn, .CalcPlus1, .Invalid, .Overflow, .Underflow, .ZSgnEffM, .PSgnM, .ResultSgn, .CalcPlus1, .Invalid, .Overflow, .Underflow,
.ResultDenorm, .ResultExp, .ResultFrac, .FMAResM); .ResultDenorm, .ResultExp, .ResultFrac, .FMAResM);
@ -1103,6 +1106,7 @@ module resultselect(
input logic KillProdM, // set the product to zero before addition if the product is too small to matter input logic KillProdM, // set the product to zero before addition if the product is too small to matter
input logic XInfM, YInfM, ZInfM, // inputs are infinity input logic XInfM, YInfM, ZInfM, // inputs are infinity
input logic XNaNM, YNaNM, ZNaNM, // inputs are NaN input logic XNaNM, YNaNM, ZNaNM, // inputs are NaN
input logic ZOrigDenormM, // is the original precision denormalized
input logic ZSgnEffM, // the modified Z sign - depends on instruction input logic ZSgnEffM, // the modified Z sign - depends on instruction
input logic PSgnM, // the product's sign input logic PSgnM, // the product's sign
input logic ResultSgn, // the result's sign input logic ResultSgn, // the result's sign
@ -1122,7 +1126,7 @@ module resultselect(
assign XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]}; assign XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]};
assign YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]}; assign YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]};
assign ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]}; assign ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]};
assign InvalidResult = {ResultSgn, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; assign InvalidResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end else begin end else begin
assign XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; assign XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end end
@ -1138,7 +1142,7 @@ module resultselect(
assign XNaNResult = FmtM ? {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, XSgnM, {`NE1{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF1]}; assign XNaNResult = FmtM ? {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, XSgnM, {`NE1{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF1]};
assign YNaNResult = FmtM ? {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, YSgnM, {`NE1{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF1]}; assign YNaNResult = FmtM ? {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, YSgnM, {`NE1{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF1]};
assign ZNaNResult = FmtM ? {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, ZSgnEffM, {`NE1{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF1]}; assign ZNaNResult = FmtM ? {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]} : {{`FLEN-`LEN1{1'b1}}, ZSgnEffM, {`NE1{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF1]};
assign InvalidResult = FmtM ? {ResultSgn, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}} : {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)}; assign InvalidResult = FmtM ? {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}} : {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)};
end else begin end else begin
assign XNaNResult = FmtM ? {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}} : {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)}; assign XNaNResult = FmtM ? {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}} : {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)};
end end
@ -1147,7 +1151,7 @@ module resultselect(
{ResultSgn, {`NE{1'b1}}, {`NF{1'b0}}} : {ResultSgn, {`NE{1'b1}}, {`NF{1'b0}}} :
((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1-1{1'b1}}, 1'b0, {`NF1{1'b1}}} : ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1-1{1'b1}}, 1'b0, {`NF1{1'b1}}} :
{{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, (`NF1)'(0)}; {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, (`NF1)'(0)};
assign KillProdResult = FmtM ? {ResultSgn, {ZExpM, ZManM[`NF-1:0]} + (RoundAdd[`FLEN-2:0]&{`FLEN-1{AddendStickyM}})} : {{`FLEN-`LEN1{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE1-2:0], ZManM[`NF-1:`NF-`NF1]} + (RoundAdd[`NF-`NF1+`LEN1-2:`NF-`NF1]&{`LEN1-1{AddendStickyM}})}; assign KillProdResult = FmtM ? {ResultSgn, {ZExpM, ZManM[`NF-1:0]} + (RoundAdd[`FLEN-2:0]&{`FLEN-1{AddendStickyM}})} : {{`FLEN-`LEN1{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE1-2:1], ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`NF1]} + (RoundAdd[`NF-`NF1+`LEN1-2:`NF-`NF1]&{`LEN1-1{AddendStickyM}})};
assign UnderflowResult = FmtM ? {ResultSgn, {`FLEN-1{1'b0}}} + {(`FLEN-1)'(0),(CalcPlus1&(AddendStickyM|FrmM[1]))} : {{`FLEN-`LEN1{1'b1}}, {ResultSgn, (`LEN1-1)'(0)} + {(`LEN1-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; assign UnderflowResult = FmtM ? {ResultSgn, {`FLEN-1{1'b0}}} + {(`FLEN-1)'(0),(CalcPlus1&(AddendStickyM|FrmM[1]))} : {{`FLEN-`LEN1{1'b1}}, {ResultSgn, (`LEN1-1)'(0)} + {(`LEN1-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
assign InfResult = FmtM ? {InfSgn, {`NE{1'b1}}, (`NF)'(0)} : {{`FLEN-`LEN1{1'b1}}, InfSgn, {`NE1{1'b1}}, (`NF1)'(0)}; assign InfResult = FmtM ? {InfSgn, {`NE{1'b1}}, (`NF)'(0)} : {{`FLEN-`LEN1{1'b1}}, InfSgn, {`NE1{1'b1}}, (`NF1)'(0)};
assign NormResult = FmtM ? {ResultSgn, ResultExp, ResultFrac} : {{`FLEN-`LEN1{1'b1}}, ResultSgn, ResultExp[`NE1-1:0], ResultFrac[`NF-1:`NF-`NF1]}; assign NormResult = FmtM ? {ResultSgn, ResultExp, ResultFrac} : {{`FLEN-`LEN1{1'b1}}, ResultSgn, ResultExp[`NE1-1:0], ResultFrac[`NF-1:`NF-`NF1]};
@ -1160,7 +1164,7 @@ module resultselect(
XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]}; XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]};
YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]}; YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]};
ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]}; ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]};
InvalidResult = {ResultSgn, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; InvalidResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end else begin end else begin
XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end end
@ -1177,13 +1181,13 @@ module resultselect(
XNaNResult = {{`FLEN-`LEN1{1'b1}}, XSgnM, {`NE1{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF1]}; XNaNResult = {{`FLEN-`LEN1{1'b1}}, XSgnM, {`NE1{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF1]};
YNaNResult = {{`FLEN-`LEN1{1'b1}}, YSgnM, {`NE1{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF1]}; YNaNResult = {{`FLEN-`LEN1{1'b1}}, YSgnM, {`NE1{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF1]};
ZNaNResult = {{`FLEN-`LEN1{1'b1}}, ZSgnEffM, {`NE1{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF1]}; ZNaNResult = {{`FLEN-`LEN1{1'b1}}, ZSgnEffM, {`NE1{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF1]};
InvalidResult = {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)}; InvalidResult = {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)};
end else begin end else begin
XNaNResult = {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)}; XNaNResult = {{`FLEN-`LEN1{1'b1}}, 1'b0, {`NE1{1'b1}}, 1'b1, (`NF1-1)'(0)};
end end
OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1-1{1'b1}}, 1'b0, {`NF1{1'b1}}} : OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1-1{1'b1}}, 1'b0, {`NF1{1'b1}}} :
{{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, (`NF1)'(0)}; {{`FLEN-`LEN1{1'b1}}, ResultSgn, {`NE1{1'b1}}, (`NF1)'(0)};
KillProdResult = {{`FLEN-`LEN1{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE1-2:0], ZManM[`NF-1:`NF-`NF1]} + (RoundAdd[`NF-`NF1+`LEN1-2:`NF-`NF1]&{`LEN1-1{AddendStickyM}})}; KillProdResult = {{`FLEN-`LEN1{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE1-2:1], ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`NF1]} + (RoundAdd[`NF-`NF1+`LEN1-2:`NF-`NF1]&{`LEN1-1{AddendStickyM}})};
UnderflowResult = {{`FLEN-`LEN1{1'b1}}, {ResultSgn, (`LEN1-1)'(0)} + {(`LEN1-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; UnderflowResult = {{`FLEN-`LEN1{1'b1}}, {ResultSgn, (`LEN1-1)'(0)} + {(`LEN1-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
InfResult = {{`FLEN-`LEN1{1'b1}}, InfSgn, {`NE1{1'b1}}, (`NF1)'(0)}; InfResult = {{`FLEN-`LEN1{1'b1}}, InfSgn, {`NE1{1'b1}}, (`NF1)'(0)};
NormResult = {{`FLEN-`LEN1{1'b1}}, ResultSgn, ResultExp[`NE1-1:0], ResultFrac[`NF-1:`NF-`NF1]}; NormResult = {{`FLEN-`LEN1{1'b1}}, ResultSgn, ResultExp[`NE1-1:0], ResultFrac[`NF-1:`NF-`NF1]};
@ -1193,14 +1197,14 @@ module resultselect(
XNaNResult = {{`FLEN-`LEN2{1'b1}}, XSgnM, {`NE2{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF2]}; XNaNResult = {{`FLEN-`LEN2{1'b1}}, XSgnM, {`NE2{1'b1}}, 1'b1, XManM[`NF-2:`NF-`NF2]};
YNaNResult = {{`FLEN-`LEN2{1'b1}}, YSgnM, {`NE2{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF2]}; YNaNResult = {{`FLEN-`LEN2{1'b1}}, YSgnM, {`NE2{1'b1}}, 1'b1, YManM[`NF-2:`NF-`NF2]};
ZNaNResult = {{`FLEN-`LEN2{1'b1}}, ZSgnEffM, {`NE2{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF2]}; ZNaNResult = {{`FLEN-`LEN2{1'b1}}, ZSgnEffM, {`NE2{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`NF2]};
InvalidResult = {{`FLEN-`LEN2{1'b1}}, ResultSgn, {`NE2{1'b1}}, 1'b1, (`NF2-1)'(0)}; InvalidResult = {{`FLEN-`LEN2{1'b1}}, 1'b0, {`NE2{1'b1}}, 1'b1, (`NF2-1)'(0)};
end else begin end else begin
XNaNResult = {{`FLEN-`LEN2{1'b1}}, 1'b0, {`NE2{1'b1}}, 1'b1, (`NF2-1)'(0)}; XNaNResult = {{`FLEN-`LEN2{1'b1}}, 1'b0, {`NE2{1'b1}}, 1'b1, (`NF2-1)'(0)};
end end
OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN2{1'b1}}, ResultSgn, {`NE2-1{1'b1}}, 1'b0, {`NF2{1'b1}}} : OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`LEN2{1'b1}}, ResultSgn, {`NE2-1{1'b1}}, 1'b0, {`NF2{1'b1}}} :
{{`FLEN-`LEN2{1'b1}}, ResultSgn, {`NE2{1'b1}}, (`NF2)'(0)}; {{`FLEN-`LEN2{1'b1}}, ResultSgn, {`NE2{1'b1}}, (`NF2)'(0)};
KillProdResult = {{`FLEN-`LEN2{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE2-2:0], ZManM[`NF-1:`NF-`NF2]} + (RoundAdd[`NF-`NF2+`LEN2-2:`NF-`NF2]&{`LEN2-1{AddendStickyM}})}; KillProdResult = {{`FLEN-`LEN2{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE2-2:1], ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`NF2]} + (RoundAdd[`NF-`NF2+`LEN2-2:`NF-`NF2]&{`LEN2-1{AddendStickyM}})};
UnderflowResult = {{`FLEN-`LEN2{1'b1}}, {ResultSgn, (`LEN2-1)'(0)} + {(`LEN2-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; UnderflowResult = {{`FLEN-`LEN2{1'b1}}, {ResultSgn, (`LEN2-1)'(0)} + {(`LEN2-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
InfResult = {{`FLEN-`LEN2{1'b1}}, InfSgn, {`NE2{1'b1}}, (`NF2)'(0)}; InfResult = {{`FLEN-`LEN2{1'b1}}, InfSgn, {`NE2{1'b1}}, (`NF2)'(0)};
NormResult = {{`FLEN-`LEN2{1'b1}}, ResultSgn, ResultExp[`NE2-1:0], ResultFrac[`NF-1:`NF-`NF2]}; NormResult = {{`FLEN-`LEN2{1'b1}}, ResultSgn, ResultExp[`NE2-1:0], ResultFrac[`NF-1:`NF-`NF2]};
@ -1231,7 +1235,7 @@ module resultselect(
XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]}; XNaNResult = {XSgnM, {`NE{1'b1}}, 1'b1, XManM[`NF-2:0]};
YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]}; YNaNResult = {YSgnM, {`NE{1'b1}}, 1'b1, YManM[`NF-2:0]};
ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]}; ZNaNResult = {ZSgnEffM, {`NE{1'b1}}, 1'b1, ZManM[`NF-2:0]};
InvalidResult = {ResultSgn, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; InvalidResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end else begin end else begin
XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}}; XNaNResult = {1'b0, {`NE{1'b1}}, 1'b1, {`NF-1{1'b0}}};
end end
@ -1248,13 +1252,13 @@ module resultselect(
XNaNResult = {{`FLEN-`D_LEN{1'b1}}, XSgnM, {`D_NE{1'b1}}, 1'b1, XManM[`NF-2:`NF-`D_NF]}; XNaNResult = {{`FLEN-`D_LEN{1'b1}}, XSgnM, {`D_NE{1'b1}}, 1'b1, XManM[`NF-2:`NF-`D_NF]};
YNaNResult = {{`FLEN-`D_LEN{1'b1}}, YSgnM, {`D_NE{1'b1}}, 1'b1, YManM[`NF-2:`NF-`D_NF]}; YNaNResult = {{`FLEN-`D_LEN{1'b1}}, YSgnM, {`D_NE{1'b1}}, 1'b1, YManM[`NF-2:`NF-`D_NF]};
ZNaNResult = {{`FLEN-`D_LEN{1'b1}}, ZSgnEffM, {`D_NE{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`D_NF]}; ZNaNResult = {{`FLEN-`D_LEN{1'b1}}, ZSgnEffM, {`D_NE{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`D_NF]};
InvalidResult = {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {`D_NE{1'b1}}, 1'b1, (`D_NF-1)'(0)}; InvalidResult = {{`FLEN-`D_LEN{1'b1}}, 1'b0, {`D_NE{1'b1}}, 1'b1, (`D_NF-1)'(0)};
end else begin end else begin
XNaNResult = {{`FLEN-`D_LEN{1'b1}}, 1'b0, {`D_NE{1'b1}}, 1'b1, (`D_NF-1)'(0)}; XNaNResult = {{`FLEN-`D_LEN{1'b1}}, 1'b0, {`D_NE{1'b1}}, 1'b1, (`D_NF-1)'(0)};
end end
OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {`D_NE-1{1'b1}}, 1'b0, {`D_NF{1'b1}}} : OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {`D_NE-1{1'b1}}, 1'b0, {`D_NF{1'b1}}} :
{{`FLEN-`D_LEN{1'b1}}, ResultSgn, {`D_NE{1'b1}}, (`D_NF)'(0)}; {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {`D_NE{1'b1}}, (`D_NF)'(0)};
KillProdResult = {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`D_NE-2:0], ZManM[`NF-1:`NF-`D_NF]} + (RoundAdd[`NF-`D_NF+`D_LEN-2:`NF-`D_NF]&{`D_LEN-1{AddendStickyM}})}; KillProdResult = {{`FLEN-`D_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`D_NE-2:1], ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`D_NF]} + (RoundAdd[`NF-`D_NF+`D_LEN-2:`NF-`D_NF]&{`D_LEN-1{AddendStickyM}})};
UnderflowResult = {{`FLEN-`D_LEN{1'b1}}, {ResultSgn, (`D_LEN-1)'(0)} + {(`D_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; UnderflowResult = {{`FLEN-`D_LEN{1'b1}}, {ResultSgn, (`D_LEN-1)'(0)} + {(`D_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
InfResult = {{`FLEN-`D_LEN{1'b1}}, InfSgn, {`D_NE{1'b1}}, (`D_NF)'(0)}; InfResult = {{`FLEN-`D_LEN{1'b1}}, InfSgn, {`D_NE{1'b1}}, (`D_NF)'(0)};
NormResult = {{`FLEN-`D_LEN{1'b1}}, ResultSgn, ResultExp[`D_NE-1:0], ResultFrac[`NF-1:`NF-`D_NF]}; NormResult = {{`FLEN-`D_LEN{1'b1}}, ResultSgn, ResultExp[`D_NE-1:0], ResultFrac[`NF-1:`NF-`D_NF]};
@ -1264,14 +1268,14 @@ module resultselect(
XNaNResult = {{`FLEN-`S_LEN{1'b1}}, XSgnM, {`S_NE{1'b1}}, 1'b1, XManM[`NF-2:`NF-`S_NF]}; XNaNResult = {{`FLEN-`S_LEN{1'b1}}, XSgnM, {`S_NE{1'b1}}, 1'b1, XManM[`NF-2:`NF-`S_NF]};
YNaNResult = {{`FLEN-`S_LEN{1'b1}}, YSgnM, {`S_NE{1'b1}}, 1'b1, YManM[`NF-2:`NF-`S_NF]}; YNaNResult = {{`FLEN-`S_LEN{1'b1}}, YSgnM, {`S_NE{1'b1}}, 1'b1, YManM[`NF-2:`NF-`S_NF]};
ZNaNResult = {{`FLEN-`S_LEN{1'b1}}, ZSgnEffM, {`S_NE{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`S_NF]}; ZNaNResult = {{`FLEN-`S_LEN{1'b1}}, ZSgnEffM, {`S_NE{1'b1}}, 1'b1, ZManM[`NF-2:`NF-`S_NF]};
InvalidResult = {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {`S_NE{1'b1}}, 1'b1, (`S_NF-1)'(0)}; InvalidResult = {{`FLEN-`S_LEN{1'b1}}, 1'b0, {`S_NE{1'b1}}, 1'b1, (`S_NF-1)'(0)};
end else begin end else begin
XNaNResult = {{`FLEN-`S_LEN{1'b1}}, 1'b0, {`S_NE{1'b1}}, 1'b1, (`S_NF-1)'(0)}; XNaNResult = {{`FLEN-`S_LEN{1'b1}}, 1'b0, {`S_NE{1'b1}}, 1'b1, (`S_NF-1)'(0)};
end end
OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {`S_NE-1{1'b1}}, 1'b0, {`S_NF{1'b1}}} : OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {`S_NE-1{1'b1}}, 1'b0, {`S_NF{1'b1}}} :
{{`FLEN-`S_LEN{1'b1}}, ResultSgn, {`S_NE{1'b1}}, (`S_NF)'(0)}; {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {`S_NE{1'b1}}, (`S_NF)'(0)};
KillProdResult = {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`NE2-2:0], ZManM[`NF-1:`NF-`S_NF]} + (RoundAdd[`NF-`S_NF+`S_LEN-2:`NF-`S_NF]&{`S_LEN-1{AddendStickyM}})}; KillProdResult = {{`FLEN-`S_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`S_NE-2:1], ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`S_NF]} + (RoundAdd[`NF-`S_NF+`S_LEN-2:`NF-`S_NF]&{`S_LEN-1{AddendStickyM}})};
UnderflowResult = {{`FLEN-`S_LEN{1'b1}}, {ResultSgn, (`S_LEN-1)'(0)} + {(`S_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; UnderflowResult = {{`FLEN-`S_LEN{1'b1}}, {ResultSgn, (`S_LEN-1)'(0)} + {(`S_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
InfResult = {{`FLEN-`S_LEN{1'b1}}, InfSgn, {`S_NE{1'b1}}, (`S_NF)'(0)}; InfResult = {{`FLEN-`S_LEN{1'b1}}, InfSgn, {`S_NE{1'b1}}, (`S_NF)'(0)};
NormResult = {{`FLEN-`S_LEN{1'b1}}, ResultSgn, ResultExp[`S_NE-1:0], ResultFrac[`NF-1:`NF-`S_NF]}; NormResult = {{`FLEN-`S_LEN{1'b1}}, ResultSgn, ResultExp[`S_NE-1:0], ResultFrac[`NF-1:`NF-`S_NF]};
@ -1289,7 +1293,7 @@ module resultselect(
OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`H_LEN{1'b1}}, ResultSgn, {`H_NE-1{1'b1}}, 1'b0, {`H_NF{1'b1}}} : OverflowResult = ((FrmM[1:0]==2'b01) | (FrmM[1:0]==2'b10&~ResultSgn) | (FrmM[1:0]==2'b11&ResultSgn)) ? {{`FLEN-`H_LEN{1'b1}}, ResultSgn, {`H_NE-1{1'b1}}, 1'b0, {`H_NF{1'b1}}} :
{{`FLEN-`H_LEN{1'b1}}, ResultSgn, {`H_NE{1'b1}}, (`H_NF)'(0)}; {{`FLEN-`H_LEN{1'b1}}, ResultSgn, {`H_NE{1'b1}}, (`H_NF)'(0)};
KillProdResult = {{`FLEN-`H_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`H_NE-2:0], ZManM[`NF-1:`NF-`H_NF]} + (RoundAdd[`NF-`H_NF+`H_LEN-2:`NF-`H_NF]&{`H_LEN-1{AddendStickyM}})}; KillProdResult = {{`FLEN-`H_LEN{1'b1}}, ResultSgn, {ZExpM[`NE-1], ZExpM[`H_NE-2:1],ZExpM[0]&~ZOrigDenormM, ZManM[`NF-1:`NF-`H_NF]} + (RoundAdd[`NF-`H_NF+`H_LEN-2:`NF-`H_NF]&{`H_LEN-1{AddendStickyM}})};
UnderflowResult = {{`FLEN-`H_LEN{1'b1}}, {ResultSgn, (`H_LEN-1)'(0)} + {(`H_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}}; UnderflowResult = {{`FLEN-`H_LEN{1'b1}}, {ResultSgn, (`H_LEN-1)'(0)} + {(`H_LEN-1)'(0), (CalcPlus1&(AddendStickyM|FrmM[1]))}};
InfResult = {{`FLEN-`H_LEN{1'b1}}, InfSgn, {`H_NE{1'b1}}, (`H_NF)'(0)}; InfResult = {{`FLEN-`H_LEN{1'b1}}, InfSgn, {`H_NE{1'b1}}, (`H_NF)'(0)};
NormResult = {{`FLEN-`H_LEN{1'b1}}, ResultSgn, ResultExp[`H_NE-1:0], ResultFrac[`NF-1:`NF-`H_NF]}; NormResult = {{`FLEN-`H_LEN{1'b1}}, ResultSgn, ResultExp[`H_NE-1:0], ResultFrac[`NF-1:`NF-`H_NF]};

View File

@ -104,6 +104,7 @@ module fpu (
logic XInfQ, YInfQ; // is the input infinity - divide logic XInfQ, YInfQ; // is the input infinity - divide
logic XExpMaxE; // is the exponent all ones (max value) logic XExpMaxE; // is the exponent all ones (max value)
logic XNormE; // is normal logic XNormE; // is normal
logic ZOrigDenormE;
logic FmtQ; logic FmtQ;
logic FOpCtrlQ; logic FOpCtrlQ;
@ -176,7 +177,7 @@ module fpu (
// unpack unit // unpack unit
// - splits FP inputs into their various parts // - splits FP inputs into their various parts
// - does some classifications (SNaN, NaN, Denorm, Norm, Zero, Infifnity) // - does some classifications (SNaN, NaN, Denorm, Norm, Zero, Infifnity)
unpack unpack (.X(FSrcXE), .Y(FSrcYE), .Z(FSrcZE), .FmtE, unpack unpack (.X(FSrcXE), .Y(FSrcYE), .Z(FSrcZE), .FmtE, .ZOrigDenormE,
.XSgnE, .YSgnE, .ZSgnE, .XExpE, .YExpE, .ZExpE, .XManE, .YManE, .ZManE, .XSgnE, .YSgnE, .ZSgnE, .XExpE, .YExpE, .ZExpE, .XManE, .YManE, .ZManE,
.XNaNE, .YNaNE, .ZNaNE, .XSNaNE, .YSNaNE, .ZSNaNE, .XDenormE, .YDenormE, .ZDenormE, .XNaNE, .YNaNE, .ZNaNE, .XSNaNE, .YSNaNE, .ZSNaNE, .XDenormE, .YDenormE, .ZDenormE,
.XZeroE, .YZeroE, .ZZeroE, .XInfE, .YInfE, .ZInfE, .XExpMaxE, .XNormE); .XZeroE, .YZeroE, .ZZeroE, .XInfE, .YInfE, .ZInfE, .XExpMaxE, .XNormE);
@ -192,7 +193,7 @@ module fpu (
.XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM, .XSgnM, .YSgnM, .ZExpM, .XManM, .YManM, .ZManM,
.XNaNM, .YNaNM, .ZNaNM, .XZeroM, .YZeroM, .ZZeroM, .XNaNM, .YNaNM, .ZNaNM, .XZeroM, .YZeroM, .ZZeroM,
.XInfM, .YInfM, .ZInfM, .XSNaNM, .YSNaNM, .ZSNaNM, .XInfM, .YInfM, .ZInfM, .XSNaNM, .YSNaNM, .ZSNaNM,
.FOpCtrlE, .FOpCtrlE, .ZOrigDenormE,
.FmtE, .FmtM, .FrmM, .FmtE, .FmtM, .FrmM,
.FMAFlgM, .FMAResM); .FMAFlgM, .FMAResM);
@ -213,12 +214,12 @@ module fpu (
.FDivBusyE, .done(FDivSqrtDoneE), .AS_Result(FDivResM), .Flags(FDivFlgM)); .FDivBusyE, .done(FDivSqrtDoneE), .AS_Result(FDivResM), .Flags(FDivFlgM));
// other FP execution units // other FP execution units
cvtfp cvtfp (.XExpE, .XManE, .XSgnE, .XZeroE, .XDenormE, .XInfE, .XNaNE, .XSNaNE, .FrmE, .FmtE, .CvtFpResE, .CvtFpFlgE); fcvtfp fcvtfp (.XExpE, .XManE, .XSgnE, .XZeroE, .XDenormE, .XInfE, .XNaNE, .XSNaNE, .FrmE, .FmtE, .CvtFpResE, .CvtFpFlgE);
fcmp fcmp (.FmtE, .FOpCtrlE, .XSgnE, .YSgnE, .XExpE, .YExpE, .XManE, .YManE, fcmp fcmp (.FmtE, .FOpCtrlE, .XSgnE, .YSgnE, .XExpE, .YExpE, .XManE, .YManE,
.XZeroE, .YZeroE, .XNaNE, .YNaNE, .XSNaNE, .YSNaNE, .FSrcXE, .FSrcYE, .CmpNVE, .CmpResE); .XZeroE, .YZeroE, .XNaNE, .YNaNE, .XSNaNE, .YSNaNE, .FSrcXE, .FSrcYE, .CmpNVE, .CmpResE);
fsgn fsgn (.SgnOpCodeE(FOpCtrlE[1:0]), .XSgnE, .YSgnE, .FSrcXE, .FmtE, .SgnResE); fsgn fsgn (.SgnOpCodeE(FOpCtrlE[1:0]), .XSgnE, .YSgnE, .FSrcXE, .FmtE, .SgnResE);
fclassify fclassify (.XSgnE, .XDenormE, .XZeroE, .XNaNE, .XInfE, .XNormE, .XSNaNE, .ClassResE); fclassify fclassify (.XSgnE, .XDenormE, .XZeroE, .XNaNE, .XInfE, .XNormE, .XSNaNE, .ClassResE);
fcvt fcvt (.XSgnE, .XExpE, .XManE, .XZeroE, .XNaNE, .XInfE, .XDenormE, .ForwardedSrcAE, .FOpCtrlE, .FmtE, .FrmE, fcvtint fcvtint (.XSgnE, .XExpE, .XManE, .XZeroE, .XNaNE, .XInfE, .XDenormE, .ForwardedSrcAE, .FOpCtrlE, .FmtE, .FrmE,
.CvtResE, .CvtFlgE); .CvtResE, .CvtFlgE);
// data to be stored in memory - to IEU // data to be stored in memory - to IEU

View File

@ -2,7 +2,7 @@
module unpack ( module unpack (
input logic [`FLEN-1:0] X, Y, Z, // inputs from register file input logic [`FLEN-1:0] X, Y, Z, // inputs from register file
input logic [`FPSIZES/3:0] FmtE, // format signal 00 - single 10 - double 11 - quad 10 - half input logic [`FPSIZES/3:0] FmtE, // format signal 00 - single 01 - double 11 - quad 10 - half
output logic XSgnE, YSgnE, ZSgnE, // sign bits of XYZ output logic XSgnE, YSgnE, ZSgnE, // sign bits of XYZ
output logic [`NE-1:0] XExpE, YExpE, ZExpE, // exponents of XYZ (converted to largest supported precision) output logic [`NE-1:0] XExpE, YExpE, ZExpE, // exponents of XYZ (converted to largest supported precision)
output logic [`NF:0] XManE, YManE, ZManE, // mantissas of XYZ (converted to largest supported precision) output logic [`NF:0] XManE, YManE, ZManE, // mantissas of XYZ (converted to largest supported precision)
@ -12,6 +12,7 @@ module unpack (
output logic XDenormE, YDenormE, ZDenormE, // is XYZ denormalized output logic XDenormE, YDenormE, ZDenormE, // is XYZ denormalized
output logic XZeroE, YZeroE, ZZeroE, // is XYZ zero output logic XZeroE, YZeroE, ZZeroE, // is XYZ zero
output logic XInfE, YInfE, ZInfE, // is XYZ infinity output logic XInfE, YInfE, ZInfE, // is XYZ infinity
output logic ZOrigDenormE, // is the original precision denormalized
output logic XExpMaxE // does X have the maximum exponent (NaN or Inf) output logic XExpMaxE // does X have the maximum exponent (NaN or Inf)
); );
@ -47,10 +48,11 @@ module unpack (
assign XExpMaxE = &XExpE; assign XExpMaxE = &XExpE;
assign YExpMaxE = &YExpE; assign YExpMaxE = &YExpE;
assign ZExpMaxE = &ZExpE; assign ZExpMaxE = &ZExpE;
assign ZOrigDenormE = 1'b0;
end else if (`FPSIZES == 2) begin // if there are 2 floating point formats supported end else if (`FPSIZES == 2) begin // if there are 2 floating point formats supported
//***need better names for these constants //***need better names for these constants
// largest format | smaller format // largest format | smaller format
//---------------------------------- //----------------------------------
@ -70,7 +72,8 @@ module unpack (
// quad and half // quad and half
// double and half // double and half
logic [`LEN1-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed logic [`LEN1-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed
logic XOrigDenormE, YOrigDenormE; // the original value of XYZ is denormalized
// Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN // Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN
assign XLen1 = &X[`FLEN-1:`LEN1] ? X[`LEN1-1:0] : {1'b0, {`NE1+1{1'b1}}, (`NF1-1)'(0)}; assign XLen1 = &X[`FLEN-1:`LEN1] ? X[`LEN1-1:0] : {1'b0, {`NE1+1{1'b1}}, (`NF1-1)'(0)};
@ -91,9 +94,15 @@ module unpack (
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// extract the exponent, converting the smaller exponent into the larger precision if nessisary // extract the exponent, converting the smaller exponent into the larger precision if nessisary
assign XExpE = FmtE ? X[`FLEN-2:`NF] : {XLen1[`LEN1-2], {`NE-`NE1{~XLen1[`LEN1-2]&~XExpZero|XExpMaxE}}, XLen1[`LEN1-3:`NF1]}; // - if the original precision had a denormal number convert the exponent value 1
assign YExpE = FmtE ? Y[`FLEN-2:`NF] : {YLen1[`LEN1-2], {`NE-`NE1{~YLen1[`LEN1-2]&~YExpZero|YExpMaxE}}, YLen1[`LEN1-3:`NF1]}; assign XExpE = FmtE ? X[`FLEN-2:`NF] : XOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {XLen1[`LEN1-2], {`NE-`NE1{~XLen1[`LEN1-2]&~XExpZero|XExpMaxE}}, XLen1[`LEN1-3:`NF1]};
assign ZExpE = FmtE ? Z[`FLEN-2:`NF] : {ZLen1[`LEN1-2], {`NE-`NE1{~ZLen1[`LEN1-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`LEN1-3:`NF1]}; assign YExpE = FmtE ? Y[`FLEN-2:`NF] : YOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {YLen1[`LEN1-2], {`NE-`NE1{~YLen1[`LEN1-2]&~YExpZero|YExpMaxE}}, YLen1[`LEN1-3:`NF1]};
assign ZExpE = FmtE ? Z[`FLEN-2:`NF] : ZOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {ZLen1[`LEN1-2], {`NE-`NE1{~ZLen1[`LEN1-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`LEN1-3:`NF1]};
// is the input (in it's original format) denormalized
assign XOrigDenormE = (FmtE ? 0 : |XLen1[`LEN1-2:`NF1]) & ~XFracZero;
assign YOrigDenormE = (FmtE ? 0 : |YLen1[`LEN1-2:`NF1]) & ~YFracZero;
assign ZOrigDenormE = (FmtE ? 0 : |ZLen1[`LEN1-2:`NF1]) & ~ZFracZero;
// extract the fraction, add trailing zeroes to the mantissa if nessisary // extract the fraction, add trailing zeroes to the mantissa if nessisary
assign XFracE = FmtE ? X[`NF-1:0] : {XLen1[`NF1-1:0], (`NF-`NF1)'(0)}; assign XFracE = FmtE ? X[`NF-1:0] : {XLen1[`NF1-1:0], (`NF-`NF1)'(0)};
@ -130,8 +139,9 @@ module unpack (
// quad and double and half // quad and double and half
// quad and single and half // quad and single and half
logic [`LEN1-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed for larger percision logic [`LEN1-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed for larger percision
logic [`LEN2-1:0] XLen2, YLen2, ZLen2; // Remove NaN boxing or NaN, if not properly NaN boxed for smallest precision logic [`LEN2-1:0] XLen2, YLen2, ZLen2; // Remove NaN boxing or NaN, if not properly NaN boxed for smallest precision
logic XOrigDenormE, YOrigDenormE; // the original value of XYZ is denormalized
// Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN - for larger precision // Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN - for larger precision
assign XLen1 = &X[`FLEN-1:`LEN1] ? X[`LEN1-1:0] : {1'b0, {`NE1+1{1'b1}}, (`NF1-1)'(0)}; assign XLen1 = &X[`FLEN-1:`LEN1] ? X[`LEN1-1:0] : {1'b0, {`NE1+1{1'b1}}, (`NF1-1)'(0)};
@ -143,6 +153,75 @@ module unpack (
assign YLen2 = &Y[`FLEN-1:`LEN2] ? Y[`LEN2-1:0] : {1'b0, {`NE2+1{1'b1}}, (`NF2-1)'(0)}; assign YLen2 = &Y[`FLEN-1:`LEN2] ? Y[`LEN2-1:0] : {1'b0, {`NE2+1{1'b1}}, (`NF2-1)'(0)};
assign ZLen2 = &Z[`FLEN-1:`LEN2] ? Z[`LEN2-1:0] : {1'b0, {`NE2+1{1'b1}}, (`NF2-1)'(0)}; assign ZLen2 = &Z[`FLEN-1:`LEN2] ? Z[`LEN2-1:0] : {1'b0, {`NE2+1{1'b1}}, (`NF2-1)'(0)};
// There are 2 case statements
// - one for other singals and one for sgn/exp/frac
// - need two for the dependencies in the expoenent calculation
always_comb begin
case (FmtE)
`FMT: begin // if input is largest precision (`FLEN - ie quad or double)
// This is the original format so set OrigDenorm to 0
XOrigDenormE = 1'b0;
YOrigDenormE = 1'b0;
ZOrigDenormE = 1'b0;
// is the exponent non-zero
XExpNonzero = |X[`FLEN-2:`NF];
YExpNonzero = |Y[`FLEN-2:`NF];
ZExpNonzero = |Z[`FLEN-2:`NF];
// is the exponent all 1's
XExpMaxE = &X[`FLEN-2:`NF];
YExpMaxE = &Y[`FLEN-2:`NF];
ZExpMaxE = &Z[`FLEN-2:`NF];
end
`FMT1: begin // if input is larger precsion (`LEN1 - double or single)
// is the input (in it's original format) denormalized
XOrigDenormE = ~|XLen1[`LEN1-2:`NF1] & ~XFracZero;
YOrigDenormE = ~|YLen1[`LEN1-2:`NF1] & ~YFracZero;
ZOrigDenormE = ~|ZLen1[`LEN1-2:`NF1] & ~ZFracZero;
// is the exponent non-zero
XExpNonzero = |XLen1[`LEN1-2:`NF1];
YExpNonzero = |YLen1[`LEN1-2:`NF1];
ZExpNonzero = |ZLen1[`LEN1-2:`NF1];
// is the exponent all 1's
XExpMaxE = &XLen1[`LEN1-2:`NF1];
YExpMaxE = &YLen1[`LEN1-2:`NF1];
ZExpMaxE = &ZLen1[`LEN1-2:`NF1];
end
`FMT2: begin // if input is smallest precsion (`LEN2 - single or half)
// is the input (in it's original format) denormalized
XOrigDenormE = ~|XLen2[`LEN2-2:`NF2] & ~XFracZero;
YOrigDenormE = ~|YLen2[`LEN2-2:`NF2] & ~YFracZero;
ZOrigDenormE = ~|ZLen2[`LEN2-2:`NF2] & ~ZFracZero;
// is the exponent non-zero
XExpNonzero = |XLen2[`LEN2-2:`NF2];
YExpNonzero = |YLen2[`LEN2-2:`NF2];
ZExpNonzero = |ZLen2[`LEN2-2:`NF2];
// is the exponent all 1's
XExpMaxE = &XLen2[`LEN2-2:`NF2];
YExpMaxE = &YLen2[`LEN2-2:`NF2];
ZExpMaxE = &ZLen2[`LEN2-2:`NF2];
end
default: begin
XOrigDenormE = 0;
YOrigDenormE = 0;
ZOrigDenormE = 0;
XExpNonzero = 0;
YExpNonzero = 0;
ZExpNonzero = 0;
XExpMaxE = 0;
YExpMaxE = 0;
ZExpMaxE = 0;
end
endcase
end
always_comb begin always_comb begin
case (FmtE) case (FmtE)
`FMT: begin // if input is largest precision (`FLEN - ie quad or double) `FMT: begin // if input is largest precision (`FLEN - ie quad or double)
@ -160,16 +239,6 @@ module unpack (
XFracE = X[`NF-1:0]; XFracE = X[`NF-1:0];
YFracE = Y[`NF-1:0]; YFracE = Y[`NF-1:0];
ZFracE = Z[`NF-1:0]; ZFracE = Z[`NF-1:0];
// is the exponent non-zero
XExpNonzero = |X[`FLEN-2:`NF];
YExpNonzero = |Y[`FLEN-2:`NF];
ZExpNonzero = |Z[`FLEN-2:`NF];
// is the exponent all 1's
XExpMaxE = &X[`FLEN-2:`NF];
YExpMaxE = &Y[`FLEN-2:`NF];
ZExpMaxE = &Z[`FLEN-2:`NF];
end end
`FMT1: begin // if input is larger precsion (`LEN1 - double or single) `FMT1: begin // if input is larger precsion (`LEN1 - double or single)
@ -187,24 +256,14 @@ module unpack (
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// convert the larger precision's exponent to use the largest precision's bias // convert the larger precision's exponent to use the largest precision's bias
XExpE = {XLen1[`LEN1-2], {`NE-`NE1{~XLen1[`LEN1-2]&~XExpZero|XExpMaxE}}, XLen1[`LEN1-3:`NF1]}; XExpE = XOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {XLen1[`LEN1-2], {`NE-`NE1{~XLen1[`LEN1-2]&~XExpZero|XExpMaxE}}, XLen1[`LEN1-3:`NF1]};
YExpE = {YLen1[`LEN1-2], {`NE-`NE1{~YLen1[`LEN1-2]&~YExpZero|YExpMaxE}}, YLen1[`LEN1-3:`NF1]}; YExpE = YOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {YLen1[`LEN1-2], {`NE-`NE1{~YLen1[`LEN1-2]&~YExpZero|YExpMaxE}}, YLen1[`LEN1-3:`NF1]};
ZExpE = {ZLen1[`LEN1-2], {`NE-`NE1{~ZLen1[`LEN1-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`LEN1-3:`NF1]}; ZExpE = ZOrigDenormE ? {1'b0, {`NE-`NE1{1'b1}}, (`NE1-1)'(1)} : {ZLen1[`LEN1-2], {`NE-`NE1{~ZLen1[`LEN1-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`LEN1-3:`NF1]};
// extract the fraction and add the nessesary trailing zeros // extract the fraction and add the nessesary trailing zeros
XFracE = {XLen1[`NF1-1:0], (`NF-`NF1)'(0)}; XFracE = {XLen1[`NF1-1:0], (`NF-`NF1)'(0)};
YFracE = {YLen1[`NF1-1:0], (`NF-`NF1)'(0)}; YFracE = {YLen1[`NF1-1:0], (`NF-`NF1)'(0)};
ZFracE = {ZLen1[`NF1-1:0], (`NF-`NF1)'(0)}; ZFracE = {ZLen1[`NF1-1:0], (`NF-`NF1)'(0)};
// is the exponent non-zero
XExpNonzero = |XLen1[`LEN1-2:`NF1];
YExpNonzero = |YLen1[`LEN1-2:`NF1];
ZExpNonzero = |ZLen1[`LEN1-2:`NF1];
// is the exponent all 1's
XExpMaxE = &XLen1[`LEN1-2:`NF1];
YExpMaxE = &YLen1[`LEN1-2:`NF1];
ZExpMaxE = &ZLen1[`LEN1-2:`NF1];
end end
`FMT2: begin // if input is smallest precsion (`LEN2 - single or half) `FMT2: begin // if input is smallest precsion (`LEN2 - single or half)
@ -222,24 +281,14 @@ module unpack (
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// convert the smallest precision's exponent to use the largest precision's bias // convert the smallest precision's exponent to use the largest precision's bias
XExpE = {XLen2[`LEN2-2], {`NE-`NE2{~XLen2[`LEN2-2]&~XExpZero|XExpMaxE}}, XLen2[`LEN2-3:`NF2]}; XExpE = XOrigDenormE ? {1'b0, {`NE-`NE2{1'b1}}, (`NE2-1)'(1)} : {XLen2[`LEN2-2], {`NE-`NE2{~XLen2[`LEN2-2]&~XExpZero|XExpMaxE}}, XLen2[`LEN2-3:`NF2]};
YExpE = {YLen2[`LEN2-2], {`NE-`NE2{~YLen2[`LEN2-2]&~YExpZero|YExpMaxE}}, YLen2[`LEN2-3:`NF2]}; YExpE = YOrigDenormE ? {1'b0, {`NE-`NE2{1'b1}}, (`NE2-1)'(1)} : {YLen2[`LEN2-2], {`NE-`NE2{~YLen2[`LEN2-2]&~YExpZero|YExpMaxE}}, YLen2[`LEN2-3:`NF2]};
ZExpE = {ZLen2[`LEN2-2], {`NE-`NE2{~ZLen2[`LEN2-2]&~ZExpZero|ZExpMaxE}}, ZLen2[`LEN2-3:`NF2]}; ZExpE = ZOrigDenormE ? {1'b0, {`NE-`NE2{1'b1}}, (`NE2-1)'(1)} : {ZLen2[`LEN2-2], {`NE-`NE2{~ZLen2[`LEN2-2]&~ZExpZero|ZExpMaxE}}, ZLen2[`LEN2-3:`NF2]};
// extract the fraction and add the nessesary trailing zeros // extract the fraction and add the nessesary trailing zeros
XFracE = {XLen2[`NF2-1:0], (`NF-`NF2)'(0)}; XFracE = {XLen2[`NF2-1:0], (`NF-`NF2)'(0)};
YFracE = {YLen2[`NF2-1:0], (`NF-`NF2)'(0)}; YFracE = {YLen2[`NF2-1:0], (`NF-`NF2)'(0)};
ZFracE = {ZLen2[`NF2-1:0], (`NF-`NF2)'(0)}; ZFracE = {ZLen2[`NF2-1:0], (`NF-`NF2)'(0)};
// is the exponent non-zero
XExpNonzero = |XLen2[`LEN2-2:`NF2];
YExpNonzero = |YLen2[`LEN2-2:`NF2];
ZExpNonzero = |ZLen2[`LEN2-2:`NF2];
// is the exponent all 1's
XExpMaxE = &XLen2[`LEN2-2:`NF2];
YExpMaxE = &YLen2[`LEN2-2:`NF2];
ZExpMaxE = &ZLen2[`LEN2-2:`NF2];
end end
default: begin default: begin
XSgnE = 0; XSgnE = 0;
@ -251,12 +300,6 @@ module unpack (
XFracE = 0; XFracE = 0;
YFracE = 0; YFracE = 0;
ZFracE = 0; ZFracE = 0;
XExpNonzero = 0;
YExpNonzero = 0;
ZExpNonzero = 0;
XExpMaxE = 0;
YExpMaxE = 0;
ZExpMaxE = 0;
end end
endcase endcase
end end
@ -272,9 +315,10 @@ module unpack (
// `Q_FMT | `D_FMT | `S_FMT | `H_FMT precision's format value - Q=11 D=01 S=00 H=10 // `Q_FMT | `D_FMT | `S_FMT | `H_FMT precision's format value - Q=11 D=01 S=00 H=10
logic [`LEN1-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed for double percision logic [`D_LEN-1:0] XLen1, YLen1, ZLen1; // Remove NaN boxing or NaN, if not properly NaN boxed for double percision
logic [`LEN2-1:0] XLen2, YLen2, ZLen2; // Remove NaN boxing or NaN, if not properly NaN boxed for single percision logic [`S_LEN-1:0] XLen2, YLen2, ZLen2; // Remove NaN boxing or NaN, if not properly NaN boxed for single percision
logic [`LEN2-1:0] XLen3, YLen3, ZLen3; // Remove NaN boxing or NaN, if not properly NaN boxed for half percision logic [`H_LEN-1:0] XLen3, YLen3, ZLen3; // Remove NaN boxing or NaN, if not properly NaN boxed for half percision
logic XOrigDenormE, YOrigDenormE; // the original value of XYZ is denormalized
// Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN - for double precision // Check NaN boxing, If the value is not properly NaN boxed, set the value to a quiet NaN - for double precision
assign XLen1 = &X[`Q_LEN-1:`D_LEN] ? X[`D_LEN-1:0] : {1'b0, {`D_NE+1{1'b1}}, (`D_NF-1)'(0)}; assign XLen1 = &X[`Q_LEN-1:`D_LEN] ? X[`D_LEN-1:0] : {1'b0, {`D_NE+1{1'b1}}, (`D_NF-1)'(0)};
@ -291,6 +335,83 @@ module unpack (
assign YLen3 = &Y[`Q_LEN-1:`H_LEN] ? Y[`H_LEN-1:0] : {1'b0, {`H_NE+1{1'b1}}, (`H_NF-1)'(0)}; assign YLen3 = &Y[`Q_LEN-1:`H_LEN] ? Y[`H_LEN-1:0] : {1'b0, {`H_NE+1{1'b1}}, (`H_NF-1)'(0)};
assign ZLen3 = &Z[`Q_LEN-1:`H_LEN] ? Z[`H_LEN-1:0] : {1'b0, {`H_NE+1{1'b1}}, (`H_NF-1)'(0)}; assign ZLen3 = &Z[`Q_LEN-1:`H_LEN] ? Z[`H_LEN-1:0] : {1'b0, {`H_NE+1{1'b1}}, (`H_NF-1)'(0)};
// There are 2 case statements
// - one for other singals and one for sgn/exp/frac
// - need two for the dependencies in the expoenent calculation
always_comb begin
case (FmtE)
2'b11: begin // if input is quad percision
// This is the original format so set OrigDenorm to 0
XOrigDenormE = 1'b0;
YOrigDenormE = 1'b0;
ZOrigDenormE = 1'b0;
// is the exponent non-zero
XExpNonzero = |X[`Q_LEN-2:`Q_NF];
YExpNonzero = |Y[`Q_LEN-2:`Q_NF];
ZExpNonzero = |Z[`Q_LEN-2:`Q_NF];
// is the exponent all 1's
XExpMaxE = &X[`Q_LEN-2:`Q_NF];
YExpMaxE = &Y[`Q_LEN-2:`Q_NF];
ZExpMaxE = &Z[`Q_LEN-2:`Q_NF];
end
2'b01: begin // if input is double percision
// is the exponent all 1's
XExpMaxE = &XLen1[`D_LEN-2:`D_NF];
YExpMaxE = &YLen1[`D_LEN-2:`D_NF];
ZExpMaxE = &ZLen1[`D_LEN-2:`D_NF];
// is the input (in it's original format) denormalized
XOrigDenormE = ~|XLen1[`D_LEN-2:`D_NF] & ~XFracZero;
YOrigDenormE = ~|YLen1[`D_LEN-2:`D_NF] & ~YFracZero;
ZOrigDenormE = ~|ZLen1[`D_LEN-2:`D_NF] & ~ZFracZero;
// is the exponent non-zero
XExpNonzero = |XLen1[`D_LEN-2:`D_NF];
YExpNonzero = |YLen1[`D_LEN-2:`D_NF];
ZExpNonzero = |ZLen1[`D_LEN-2:`D_NF];
end
2'b00: begin // if input is single percision
// is the exponent all 1's
XExpMaxE = &XLen2[`S_LEN-2:`S_NF];
YExpMaxE = &YLen2[`S_LEN-2:`S_NF];
ZExpMaxE = &ZLen2[`S_LEN-2:`S_NF];
// is the input (in it's original format) denormalized
XOrigDenormE = ~|XLen2[`S_LEN-2:`S_NF] & ~XFracZero;
YOrigDenormE = ~|YLen2[`S_LEN-2:`S_NF] & ~YFracZero;
ZOrigDenormE = ~|ZLen2[`S_LEN-2:`S_NF] & ~ZFracZero;
// is the exponent non-zero
XExpNonzero = |XLen2[`S_LEN-2:`S_NF];
YExpNonzero = |YLen2[`S_LEN-2:`S_NF];
ZExpNonzero = |ZLen2[`S_LEN-2:`S_NF];
end
2'b10: begin // if input is half percision
// is the exponent all 1's
XExpMaxE = &XLen3[`H_LEN-2:`H_NF];
YExpMaxE = &YLen3[`H_LEN-2:`H_NF];
ZExpMaxE = &ZLen3[`H_LEN-2:`H_NF];
// is the input (in it's original format) denormalized
XOrigDenormE = ~|XLen3[`H_LEN-2:`H_NF] & ~XFracZero;
YOrigDenormE = ~|YLen3[`H_LEN-2:`H_NF] & ~YFracZero;
ZOrigDenormE = ~|ZLen3[`H_LEN-2:`H_NF] & ~ZFracZero;
// is the exponent non-zero
XExpNonzero = |XLen3[`H_LEN-2:`H_NF];
YExpNonzero = |YLen3[`H_LEN-2:`H_NF];
ZExpNonzero = |ZLen3[`H_LEN-2:`H_NF];
end
endcase
end
always_comb begin always_comb begin
case (FmtE) case (FmtE)
2'b11: begin // if input is quad percision 2'b11: begin // if input is quad percision
@ -308,16 +429,6 @@ module unpack (
XFracE = X[`Q_NF-1:0]; XFracE = X[`Q_NF-1:0];
YFracE = Y[`Q_NF-1:0]; YFracE = Y[`Q_NF-1:0];
ZFracE = Z[`Q_NF-1:0]; ZFracE = Z[`Q_NF-1:0];
// is the exponent non-zero
XExpNonzero = |X[`Q_LEN-2:`Q_NF];
YExpNonzero = |Y[`Q_LEN-2:`Q_NF];
ZExpNonzero = |Z[`Q_LEN-2:`Q_NF];
// is the exponent all 1's
XExpMaxE = &X[`Q_LEN-2:`Q_NF];
YExpMaxE = &Y[`Q_LEN-2:`Q_NF];
ZExpMaxE = &Z[`Q_LEN-2:`Q_NF];
end end
2'b01: begin // if input is double percision 2'b01: begin // if input is double percision
// extract sign bit // extract sign bit
@ -334,24 +445,15 @@ module unpack (
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// convert the double precsion exponent into quad precsion // convert the double precsion exponent into quad precsion
XExpE = {XLen1[`D_LEN-2], {`Q_NE-`D_NE{~XLen1[`D_LEN-2]&~XExpZero|XExpMaxE}}, XLen1[`D_LEN-3:`D_NF]};
YExpE = {YLen1[`D_LEN-2], {`Q_NE-`D_NE{~YLen1[`D_LEN-2]&~YExpZero|YExpMaxE}}, YLen1[`D_LEN-3:`D_NF]}; XExpE = XOrigDenormE ? {1'b0, {`Q_NE-`D_NE{1'b1}}, (`D_NE-1)'(1)} : {XLen1[`D_LEN-2], {`Q_NE-`D_NE{~XLen1[`D_LEN-2]&~XExpZero|XExpMaxE}}, XLen1[`D_LEN-3:`D_NF]};
ZExpE = {ZLen1[`D_LEN-2], {`Q_NE-`D_NE{~ZLen1[`D_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`D_LEN-3:`D_NF]}; YExpE = YOrigDenormE ? {1'b0, {`Q_NE-`D_NE{1'b1}}, (`D_NE-1)'(1)} : {YLen1[`D_LEN-2], {`Q_NE-`D_NE{~YLen1[`D_LEN-2]&~YExpZero|YExpMaxE}}, YLen1[`D_LEN-3:`D_NF]};
ZExpE = ZOrigDenormE ? {1'b0, {`Q_NE-`D_NE{1'b1}}, (`D_NE-1)'(1)} : {ZLen1[`D_LEN-2], {`Q_NE-`D_NE{~ZLen1[`D_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen1[`D_LEN-3:`D_NF]};
// extract the fraction and add the nessesary trailing zeros // extract the fraction and add the nessesary trailing zeros
XFracE = {XLen1[`D_NE-1:0], (`Q_NF-`D_NE)'(0)}; XFracE = {XLen1[`D_NF-1:0], (`Q_NF-`D_NF)'(0)};
YFracE = {YLen1[`D_NE-1:0], (`Q_NF-`D_NE)'(0)}; YFracE = {YLen1[`D_NF-1:0], (`Q_NF-`D_NF)'(0)};
ZFracE = {ZLen1[`D_NE-1:0], (`Q_NF-`D_NE)'(0)}; ZFracE = {ZLen1[`D_NF-1:0], (`Q_NF-`D_NF)'(0)};
// is the exponent non-zero
XExpNonzero = |XLen1[`D_LEN-2:`D_NE];
YExpNonzero = |YLen1[`D_LEN-2:`D_NE];
ZExpNonzero = |ZLen1[`D_LEN-2:`D_NE];
// is the exponent all 1's
XExpMaxE = &XLen1[`D_LEN-2:`D_NE];
YExpMaxE = &YLen1[`D_LEN-2:`D_NE];
ZExpMaxE = &ZLen1[`D_LEN-2:`D_NE];
end end
2'b00: begin // if input is single percision 2'b00: begin // if input is single percision
// extract sign bit // extract sign bit
@ -368,24 +470,14 @@ module unpack (
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// convert the single precsion exponent into quad precsion // convert the single precsion exponent into quad precsion
XExpE = {XLen2[`S_LEN-2], {`Q_NE-`S_NE{~XLen2[`S_LEN-2]&~XExpZero|XExpMaxE}}, XLen2[`S_LEN-3:`S_NF]}; XExpE = XOrigDenormE ? {1'b0, {`Q_NE-`S_NE{1'b1}}, (`S_NE-1)'(1)} : {XLen2[`S_LEN-2], {`Q_NE-`S_NE{~XLen2[`S_LEN-2]&~XExpZero|XExpMaxE}}, XLen2[`S_LEN-3:`S_NF]};
YExpE = {YLen2[`S_LEN-2], {`Q_NE-`S_NE{~YLen2[`S_LEN-2]&~YExpZero|YExpMaxE}}, YLen2[`S_LEN-3:`S_NF]}; YExpE = YOrigDenormE ? {1'b0, {`Q_NE-`S_NE{1'b1}}, (`S_NE-1)'(1)} : {YLen2[`S_LEN-2], {`Q_NE-`S_NE{~YLen2[`S_LEN-2]&~YExpZero|YExpMaxE}}, YLen2[`S_LEN-3:`S_NF]};
ZExpE = {ZLen2[`S_LEN-2], {`Q_NE-`S_NE{~ZLen2[`S_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen2[`S_LEN-3:`S_NF]}; ZExpE = ZOrigDenormE ? {1'b0, {`Q_NE-`S_NE{1'b1}}, (`S_NE-1)'(1)} : {ZLen2[`S_LEN-2], {`Q_NE-`S_NE{~ZLen2[`S_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen2[`S_LEN-3:`S_NF]};
// extract the fraction and add the nessesary trailing zeros // extract the fraction and add the nessesary trailing zeros
XFracE = {XLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)}; XFracE = {XLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)};
YFracE = {YLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)}; YFracE = {YLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)};
ZFracE = {ZLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)}; ZFracE = {ZLen2[`S_NF-1:0], (`Q_NF-`S_NF)'(0)};
// is the exponent non-zero
XExpNonzero = |XLen2[`S_LEN-2:`S_NF];
YExpNonzero = |YLen2[`S_LEN-2:`S_NF];
ZExpNonzero = |ZLen2[`S_LEN-2:`S_NF];
// is the exponent all 1's
XExpMaxE = &XLen2[`S_LEN-2:`S_NF];
YExpMaxE = &YLen2[`S_LEN-2:`S_NF];
ZExpMaxE = &ZLen2[`S_LEN-2:`S_NF];
end end
2'b10: begin // if input is half percision 2'b10: begin // if input is half percision
// extract sign bit // extract sign bit
@ -400,26 +492,16 @@ module unpack (
// sexp = 0000 bbbb bbbb (add this) b = bit d = ~b // sexp = 0000 bbbb bbbb (add this) b = bit d = ~b
// dexp = 0bdd dbbb bbbb // dexp = 0bdd dbbb bbbb
// also need to take into account possible zero/denorm/inf/NaN values // also need to take into account possible zero/denorm/inf/NaN values
// convert the half precsion exponent into quad precsion // convert the half precsion exponent into quad precsion
XExpE = {XLen3[`H_LEN-2], {`Q_NE-`H_NE{~XLen3[`H_LEN-2]&~XExpZero|XExpMaxE}}, XLen3[`H_LEN-3:`H_NF]}; XExpE = XOrigDenormE ? {1'b0, {`Q_NE-`H_NE{1'b1}}, (`H_NE-1)'(1)} : {XLen3[`H_LEN-2], {`Q_NE-`H_NE{~XLen3[`H_LEN-2]&~XExpZero|XExpMaxE}}, XLen3[`H_LEN-3:`H_NF]};
YExpE = {YLen3[`H_LEN-2], {`Q_NE-`H_NE{~YLen3[`H_LEN-2]&~YExpZero|YExpMaxE}}, YLen3[`H_LEN-3:`H_NF]}; YExpE = YOrigDenormE ? {1'b0, {`Q_NE-`H_NE{1'b1}}, (`H_NE-1)'(1)} : {YLen3[`H_LEN-2], {`Q_NE-`H_NE{~YLen3[`H_LEN-2]&~YExpZero|YExpMaxE}}, YLen3[`H_LEN-3:`H_NF]};
ZExpE = {ZLen3[`H_LEN-2], {`Q_NE-`H_NE{~ZLen3[`H_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen3[`H_LEN-3:`H_NF]}; ZExpE = ZOrigDenormE ? {1'b0, {`Q_NE-`H_NE{1'b1}}, (`H_NE-1)'(1)} : {ZLen3[`H_LEN-2], {`Q_NE-`H_NE{~ZLen3[`H_LEN-2]&~ZExpZero|ZExpMaxE}}, ZLen3[`H_LEN-3:`H_NF]};
// extract the fraction and add the nessesary trailing zeros // extract the fraction and add the nessesary trailing zeros
XFracE = {XLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)}; XFracE = {XLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)};
YFracE = {YLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)}; YFracE = {YLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)};
ZFracE = {ZLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)}; ZFracE = {ZLen3[`H_NF-1:0], (`Q_NF-`H_NF)'(0)};
// is the exponent non-zero
XExpNonzero = |XLen3[`H_LEN-2:`H_NF];
YExpNonzero = |YLen3[`H_LEN-2:`H_NF];
ZExpNonzero = |ZLen3[`H_LEN-2:`H_NF];
// is the exponent all 1's
XExpMaxE = &XLen3[`H_LEN-2:`H_NF];
YExpMaxE = &YLen3[`H_LEN-2:`H_NF];
ZExpMaxE = &ZLen3[`H_LEN-2:`H_NF];
end end
endcase endcase
end end

View File

@ -313,6 +313,7 @@ module ppa_shifter #(parameter WIDTH=32) (
assign Y = zshift[WIDTH-1:0]; assign Y = zshift[WIDTH-1:0];
endmodule endmodule
// just report one hot
module ppa_prioritythermometer #(parameter N = 8) ( module ppa_prioritythermometer #(parameter N = 8) (
input logic [N-1:0] a, input logic [N-1:0] a,
output logic [N-1:0] y); output logic [N-1:0] y);
@ -338,7 +339,7 @@ module ppa_priorityonehot #(parameter N = 8) (
assign y = a & nolower; assign y = a & nolower;
endmodule endmodule
module ppa_prioriyencoder #(parameter N = 8) ( module ppa_priorityencoder #(parameter N = 8) (
input logic [N-1:0] a, input logic [N-1:0] a,
output logic [$clog2(N)-1:0] y); output logic [$clog2(N)-1:0] y);
// Carefully crafted so design compiler will synthesize into a fast tree structure // Carefully crafted so design compiler will synthesize into a fast tree structure

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,587 @@
///////////////////////////////////////////
// tests.vh
//
// Written: David_Harris@hmc.edu 7 October 2021
// Modified:
//
// Purpose: List of tests to apply
//
// A component of the Wally configurable RISC-V project.
//
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////
`define PATH "../../tests/fp/vectors/"
`define ADD_OPCTRL 3'b110
`define MUL_OPCTRL 3'b100
`define SUB_OPCTRL 3'b111
`define FADD_OPCTRL 3'b000
`define DIV_OPCTRL 3'b000
`define SQRT_OPCTRL 3'b001
`define LE_OPCTRL 3'b011
`define LT_OPCTRL 3'b001
`define EQ_OPCTRL 3'b010
`define TO_UI_OPCTRL 3'b011
`define TO_I_OPCTRL 3'b001
`define TO_UL_OPCTRL 3'b111
`define TO_L_OPCTRL 3'b101
`define FROM_UI_OPCTRL 3'b010
`define FROM_I_OPCTRL 3'b000
`define FROM_UL_OPCTRL 3'b110
`define FROM_L_OPCTRL 3'b100
`define RNE 3'b000
`define RZ 3'b001
`define RU 3'b011
`define RD 3'b010
`define RNM 3'b100
`define FMAUNIT 0
`define DIVUNIT 1
`define CVTINTUNIT 2
`define CVTFPUNIT 3
`define CMPUNIT 4
string f16rv32cvtint[] = '{
"f16_to_i32_rne.tv",
"f16_to_i32_rz.tv",
"f16_to_i32_ru.tv",
"f16_to_i32_rd.tv",
"f16_to_i32_rnm.tv",
"f16_to_ui32_rne.tv",
"f16_to_ui32_rz.tv",
"f16_to_ui32_ru.tv",
"f16_to_ui32_rd.tv",
"f16_to_ui32_rnm.tv",
"ui32_to_f16_rne.tv",
"ui32_to_f16_rz.tv",
"ui32_to_f16_ru.tv",
"ui32_to_f16_rd.tv",
"ui32_to_f16_rnm.tv",
"i32_to_f16_rne.tv",
"i32_to_f16_rz.tv",
"i32_to_f16_ru.tv",
"i32_to_f16_rd.tv",
"i32_to_f16_rnm.tv"
};
string f16rv64cvtint[] = '{
"f16_to_ui64_rne.tv",
"f16_to_ui64_rz.tv",
"f16_to_ui64_ru.tv",
"f16_to_ui64_rd.tv",
"f16_to_ui64_rnm.tv",
"f16_to_i64_rne.tv",
"f16_to_i64_rz.tv",
"f16_to_i64_ru.tv",
"f16_to_i64_rd.tv",
"f16_to_i64_rnm.tv",
"ui64_to_f16_rne.tv",
"ui64_to_f16_rz.tv",
"ui64_to_f16_ru.tv",
"ui64_to_f16_rd.tv",
"ui64_to_f16_rnm.tv",
"i64_to_f16_rne.tv",
"i64_to_f16_rz.tv",
"i64_to_f16_ru.tv",
"i64_to_f16_rd.tv",
"i64_to_f16_rnm.tv"
};
string f32rv32cvtint[] = '{
"ui32_to_f32_rne.tv",
"ui32_to_f32_rz.tv",
"ui32_to_f32_ru.tv",
"ui32_to_f32_rd.tv",
"ui32_to_f32_rnm.tv",
"i32_to_f32_rne.tv",
"i32_to_f32_rz.tv",
"i32_to_f32_ru.tv",
"i32_to_f32_rd.tv",
"i32_to_f32_rnm.tv",
"f32_to_ui32_rne.tv",
"f32_to_ui32_rz.tv",
"f32_to_ui32_ru.tv",
"f32_to_ui32_rd.tv",
"f32_to_ui32_rnm.tv",
"f32_to_i32_rne.tv",
"f32_to_i32_rz.tv",
"f32_to_i32_ru.tv",
"f32_to_i32_rd.tv",
"f32_to_i32_rnm.tv"
};
string f32rv64cvtint[] = '{
"ui64_to_f32_rne.tv",
"ui64_to_f32_rz.tv",
"ui64_to_f32_ru.tv",
"ui64_to_f32_rd.tv",
"ui64_to_f32_rnm.tv",
"i64_to_f32_rne.tv",
"i64_to_f32_rz.tv",
"i64_to_f32_ru.tv",
"i64_to_f32_rd.tv",
"i64_to_f32_rnm.tv",
"f32_to_ui64_rne.tv",
"f32_to_ui64_rz.tv",
"f32_to_ui64_ru.tv",
"f32_to_ui64_rd.tv",
"f32_to_ui64_rnm.tv",
"f32_to_i64_rne.tv",
"f32_to_i64_rz.tv",
"f32_to_i64_ru.tv",
"f32_to_i64_rd.tv",
"f32_to_i64_rnm.tv"
};
string f64rv32cvtint[] = '{
"ui32_to_f64_rne.tv",
"ui32_to_f64_rz.tv",
"ui32_to_f64_ru.tv",
"ui32_to_f64_rd.tv",
"ui32_to_f64_rnm.tv",
"i32_to_f64_rne.tv",
"i32_to_f64_rz.tv",
"i32_to_f64_ru.tv",
"i32_to_f64_rd.tv",
"i32_to_f64_rnm.tv",
"f64_to_ui32_rne.tv",
"f64_to_ui32_rz.tv",
"f64_to_ui32_ru.tv",
"f64_to_ui32_rd.tv",
"f64_to_ui32_rnm.tv",
"f64_to_i32_rne.tv",
"f64_to_i32_rz.tv",
"f64_to_i32_ru.tv",
"f64_to_i32_rd.tv",
"f64_to_i32_rnm.tv"
};
string f64rv64cvtint[] = '{
"ui64_to_f64_rne.tv",
"ui64_to_f64_rz.tv",
"ui64_to_f64_ru.tv",
"ui64_to_f64_rd.tv",
"ui64_to_f64_rnm.tv",
"i64_to_f64_rne.tv",
"i64_to_f64_rz.tv",
"i64_to_f64_ru.tv",
"i64_to_f64_rd.tv",
"i64_to_f64_rnm.tv",
"f64_to_ui64_rne.tv",
"f64_to_ui64_rz.tv",
"f64_to_ui64_ru.tv",
"f64_to_ui64_rd.tv",
"f64_to_ui64_rnm.tv",
"f64_to_i64_rne.tv",
"f64_to_i64_rz.tv",
"f64_to_i64_ru.tv",
"f64_to_i64_rd.tv",
"f64_to_i64_rnm.tv"
};
string f128rv64cvtint[] = '{
"ui64_to_f128_rne.tv",
"ui64_to_f128_rz.tv",
"ui64_to_f128_ru.tv",
"ui64_to_f128_rd.tv",
"ui64_to_f128_rnm.tv",
"i64_to_f128_rne.tv",
"i64_to_f128_rz.tv",
"i64_to_f128_ru.tv",
"i64_to_f128_rd.tv",
"i64_to_f128_rnm.tv",
"f128_to_ui64_rne.tv",
"f128_to_ui64_rz.tv",
"f128_to_ui64_ru.tv",
"f128_to_ui64_rd.tv",
"f128_to_ui64_rnm.tv",
"f128_to_i64_rne.tv",
"f128_to_i64_rz.tv",
"f128_to_i64_ru.tv",
"f128_to_i64_rd.tv",
"f128_to_i64_rnm.tv"
};
string f128rv32cvtint[] = '{
"ui32_to_f128_rne.tv",
"ui32_to_f128_rz.tv",
"ui32_to_f128_ru.tv",
"ui32_to_f128_rd.tv",
"ui32_to_f128_rnm.tv",
"i32_to_f128_rne.tv",
"i32_to_f128_rz.tv",
"i32_to_f128_ru.tv",
"i32_to_f128_rd.tv",
"i32_to_f128_rnm.tv",
"f128_to_ui32_rne.tv",
"f128_to_ui32_rz.tv",
"f128_to_ui32_ru.tv",
"f128_to_ui32_rd.tv",
"f128_to_ui32_rnm.tv",
"f128_to_i32_rne.tv",
"f128_to_i32_rz.tv",
"f128_to_i32_ru.tv",
"f128_to_i32_rd.tv",
"f128_to_i32_rnm.tv"
};
string f32f16cvt[] = '{
"f32_to_f16_rne.tv",
"f32_to_f16_rz.tv",
"f32_to_f16_ru.tv",
"f32_to_f16_rd.tv",
"f32_to_f16_rnm.tv",
"f16_to_f32_rne.tv",
"f16_to_f32_rz.tv",
"f16_to_f32_ru.tv",
"f16_to_f32_rd.tv",
"f16_to_f32_rnm.tv"
};
string f64f16cvt[] = '{
"f64_to_f16_rne.tv",
"f64_to_f16_rz.tv",
"f64_to_f16_ru.tv",
"f64_to_f16_rd.tv",
"f64_to_f16_rnm.tv",
"f16_to_f64_rne.tv",
"f16_to_f64_rz.tv",
"f16_to_f64_ru.tv",
"f16_to_f64_rd.tv",
"f16_to_f64_rnm.tv"
};
string f128f16cvt[] = '{
"f128_to_f16_rne.tv",
"f128_to_f16_rz.tv",
"f128_to_f16_ru.tv",
"f128_to_f16_rd.tv",
"f128_to_f16_rnm.tv",
"f16_to_f128_rne.tv",
"f16_to_f128_rz.tv",
"f16_to_f128_ru.tv",
"f16_to_f128_rd.tv",
"f16_to_f128_rnm.tv"
};
string f64f32cvt[] = '{
"f64_to_f32_rne.tv",
"f64_to_f32_rz.tv",
"f64_to_f32_ru.tv",
"f64_to_f32_rd.tv",
"f64_to_f32_rnm.tv",
"f32_to_f64_rne.tv",
"f32_to_f64_rz.tv",
"f32_to_f64_ru.tv",
"f32_to_f64_rd.tv",
"f32_to_f64_rnm.tv"
};
string f128f32cvt[] = '{
"f128_to_f32_rne.tv",
"f128_to_f32_rz.tv",
"f128_to_f32_ru.tv",
"f128_to_f32_rd.tv",
"f128_to_f32_rnm.tv",
"f32_to_f128_rne.tv",
"f32_to_f128_rz.tv",
"f32_to_f128_ru.tv",
"f32_to_f128_rd.tv",
"f32_to_f128_rnm.tv"
};
string f128f64cvt[] = '{
"f64_to_f128_rne.tv",
"f64_to_f128_rz.tv",
"f64_to_f128_ru.tv",
"f64_to_f128_rd.tv",
"f64_to_f128_rnm.tv",
"f128_to_f64_rne.tv",
"f128_to_f64_rz.tv",
"f128_to_f64_ru.tv",
"f128_to_f64_rd.tv",
"f128_to_f64_rnm.tv"
};
string f16add[] = '{
"f16_add_rne.tv",
"f16_add_rz.tv",
"f16_add_ru.tv",
"f16_add_rd.tv",
"f16_add_rnm.tv"
};
string f32add[] = '{
"f32_add_rne.tv",
"f32_add_rz.tv",
"f32_add_ru.tv",
"f32_add_rd.tv",
"f32_add_rnm.tv"
};
string f64add[] = '{
"f64_add_rne.tv",
"f64_add_rz.tv",
"f64_add_ru.tv",
"f64_add_rd.tv",
"f64_add_rnm.tv"
};
string f128add[] = '{
"f128_add_rne.tv",
"f128_add_rz.tv",
"f128_add_ru.tv",
"f128_add_rd.tv",
"f128_add_rnm.tv"
};
string f16sub[] = '{
"f16_sub_rne.tv",
"f16_sub_rz.tv",
"f16_sub_ru.tv",
"f16_sub_rd.tv",
"f16_sub_rnm.tv"
};
string f32sub[] = '{
"f32_sub_rne.tv",
"f32_sub_rz.tv",
"f32_sub_ru.tv",
"f32_sub_rd.tv",
"f32_sub_rnm.tv"
};
string f64sub[] = '{
"f64_sub_rne.tv",
"f64_sub_rz.tv",
"f64_sub_ru.tv",
"f64_sub_rd.tv",
"f64_sub_rnm.tv"
};
string f128sub[] = '{
"f128_sub_rne.tv",
"f128_sub_rz.tv",
"f128_sub_ru.tv",
"f128_sub_rd.tv",
"f128_sub_rnm.tv"
};
string f16mul[] = '{
"f16_mul_rne.tv",
"f16_mul_rz.tv",
"f16_mul_ru.tv",
"f16_mul_rd.tv",
"f16_mul_rnm.tv"
};
string f32mul[] = '{
"f32_mul_rne.tv",
"f32_mul_rz.tv",
"f32_mul_ru.tv",
"f32_mul_rd.tv",
"f32_mul_rnm.tv"
};
string f64mul[] = '{
"f64_mul_rne.tv",
"f64_mul_rz.tv",
"f64_mul_ru.tv",
"f64_mul_rd.tv",
"f64_mul_rnm.tv"
};
string f128mul[] = '{
"f128_mul_rne.tv",
"f128_mul_rz.tv",
"f128_mul_ru.tv",
"f128_mul_rd.tv",
"f128_mul_rnm.tv"
};
string f16div[] = '{
"f16_div_rne.tv",
"f16_div_rz.tv",
"f16_div_ru.tv",
"f16_div_rd.tv",
"f16_div_rnm.tv"
};
string f32div[] = '{
"f32_div_rne.tv",
"f32_div_rz.tv",
"f32_div_ru.tv",
"f32_div_rd.tv",
"f32_div_rnm.tv"
};
string f64div[] = '{
"f64_div_rne.tv",
"f64_div_rz.tv",
"f64_div_ru.tv",
"f64_div_rd.tv",
"f64_div_rnm.tv"
};
string f128div[] = '{
"f128_div_rne.tv",
"f128_div_rz.tv",
"f128_div_ru.tv",
"f128_div_rd.tv",
"f128_div_rnm.tv"
};
string f16sqrt[] = '{
"f16_sqrt_rne.tv",
"f16_sqrt_rz.tv",
"f16_sqrt_ru.tv",
"f16_sqrt_rd.tv",
"f16_sqrt_rnm.tv"
};
string f32sqrt[] = '{
"f32_sqrt_rne.tv",
"f32_sqrt_rz.tv",
"f32_sqrt_ru.tv",
"f32_sqrt_rd.tv",
"f32_sqrt_rnm.tv"
};
string f64sqrt[] = '{
"f64_sqrt_rne.tv",
"f64_sqrt_rz.tv",
"f64_sqrt_ru.tv",
"f64_sqrt_rd.tv",
"f64_sqrt_rnm.tv"
};
string f128sqrt[] = '{
"f128_sqrt_rne.tv",
"f128_sqrt_rz.tv",
"f128_sqrt_ru.tv",
"f128_sqrt_rd.tv",
"f128_sqrt_rnm.tv"
};
string f16cmp[] = '{
"f16_eq_rne.tv",
"f16_eq_rz.tv",
"f16_eq_ru.tv",
"f16_eq_rd.tv",
"f16_eq_rnm.tv",
"f16_le_rne.tv",
"f16_le_rz.tv",
"f16_le_ru.tv",
"f16_le_rd.tv",
"f16_le_rnm.tv",
"f16_lt_rne.tv",
"f16_lt_rz.tv",
"f16_lt_ru.tv",
"f16_lt_rd.tv",
"f16_lt_rnm.tv"
};
string f32cmp[] = '{
"f32_eq_rne.tv",
"f32_eq_rz.tv",
"f32_eq_ru.tv",
"f32_eq_rd.tv",
"f32_eq_rnm.tv",
"f32_le_rne.tv",
"f32_le_rz.tv",
"f32_le_ru.tv",
"f32_le_rd.tv",
"f32_le_rnm.tv",
"f32_lt_rne.tv",
"f32_lt_rz.tv",
"f32_lt_ru.tv",
"f32_lt_rd.tv",
"f32_lt_rnm.tv"
};
string f64cmp[] = '{
"f64_eq_rne.tv",
"f64_eq_rz.tv",
"f64_eq_ru.tv",
"f64_eq_rd.tv",
"f64_eq_rnm.tv",
"f64_le_rne.tv",
"f64_le_rz.tv",
"f64_le_ru.tv",
"f64_le_rd.tv",
"f64_le_rnm.tv",
"f64_lt_rne.tv",
"f64_lt_rz.tv",
"f64_lt_ru.tv",
"f64_lt_rd.tv",
"f64_lt_rnm.tv"
};
string f128cmp[] = '{
"f128_eq_rne.tv",
"f128_eq_rz.tv",
"f128_eq_ru.tv",
"f128_eq_rd.tv",
"f128_eq_rnm.tv",
"f128_le_rne.tv",
"f128_le_rz.tv",
"f128_le_ru.tv",
"f128_le_rd.tv",
"f128_le_rnm.tv",
"f128_lt_rne.tv",
"f128_lt_rz.tv",
"f128_lt_ru.tv",
"f128_lt_rd.tv",
"f128_lt_rnm.tv"
};
string f16fma[] = '{
"f16_mulAdd_rne.tv",
"f16_mulAdd_rz.tv",
"f16_mulAdd_ru.tv",
"f16_mulAdd_rd.tv",
"f16_mulAdd_rnm.tv"
};
string f32fma[] = '{
"f32_mulAdd_rne.tv",
"f32_mulAdd_rz.tv",
"f32_mulAdd_ru.tv",
"f32_mulAdd_rd.tv",
"f32_mulAdd_rnm.tv"
};
string f64fma[] = '{
"f64_mulAdd_rne.tv",
"f64_mulAdd_rz.tv",
"f64_mulAdd_ru.tv",
"f64_mulAdd_rd.tv",
"f64_mulAdd_rnm.tv"
};
string f128fma[] = '{
"f128_mulAdd_rne.tv",
"f128_mulAdd_rz.tv",
"f128_mulAdd_ru.tv",
"f128_mulAdd_rd.tv",
"f128_mulAdd_rnm.tv"
};

View File

@ -1,6 +1,8 @@
#!/usr/bin/python3 #!/usr/bin/python3
from distutils.log import error from distutils.log import error
from statistics import median
import subprocess import subprocess
import statistics
import csv import csv
import re import re
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
@ -32,13 +34,17 @@ def getData():
for i in range(len(linesCPL)): for i in range(len(linesCPL)):
line = linesCPL[i] line = linesCPL[i]
mwm = wm.findall(line)[0][4:-4].split('_') mwm = wm.findall(line)[0][4:-4].split('_')
freq = int(f.findall(line)[0][1:-4])
delay = float(cpl.findall(line)[0])
area = float(da.findall(linesDA[i])[0])
mod = mwm[0]
width = int(mwm[1])
power = p.findall(linesP[i]) power = p.findall(linesP[i])
oneSynth = [mwm[0], int(mwm[1])] lpower = float(power[2])
oneSynth += [int(f.findall(line)[0][1:-4])] denergy = float(power[1])/freq
oneSynth += [float(cpl.findall(line)[0])]
oneSynth += [float(da.findall(linesDA[i])[0])] oneSynth = [mod, width, freq, delay, area, lpower, denergy]
oneSynth += [float(power[1])]
oneSynth += [float(power[2])]
allSynths += [oneSynth] allSynths += [oneSynth]
return allSynths return allSynths
@ -47,133 +53,209 @@ def getVals(module, freq, var):
global allSynths global allSynths
if (var == 'delay'): if (var == 'delay'):
ind = 3 ind = 3
units = " (ps)" units = " (ns)"
elif (var == 'area'): elif (var == 'area'):
ind = 4 ind = 4
units = " (sq microns)" units = " (sq microns)"
elif (var == 'dpower'):
ind = 5
units = " (mW)"
elif (var == 'lpower'): elif (var == 'lpower'):
ind = 6 ind = 5
units = " (nW)" units = " (nW)"
elif (var == 'denergy'):
ind = 6
units = " (uJ)" #fix check math
else: else:
error error
widths = [] widths = []
ivar = [] metric = []
for oneSynth in allSynths: for oneSynth in allSynths:
if (oneSynth[0] == module) & (oneSynth[2] == freq): if (oneSynth[0] == module) & (oneSynth[2] == freq):
widths += [oneSynth[1]] widths += [oneSynth[1]]
ivar += [oneSynth[ind]] m = oneSynth[ind]
return widths, ivar, units if (ind==6): m*=1000
metric += [m]
return widths, metric, units
def writeCSV(allSynths): def writeCSV(allSynths):
file = open("ppaData.csv", "w") file = open("ppaData.csv", "w")
writer = csv.writer(file) writer = csv.writer(file)
writer.writerow(['Module', 'Width', 'Target Freq', 'Delay', 'Area', 'D Power (mW)', 'L Power (nW)']) writer.writerow(['Module', 'Width', 'Target Freq', 'Delay', 'Area', 'L Power (nW)', 'D energy (mJ)'])
for one in allSynths: for one in allSynths:
writer.writerow(one) writer.writerow(one)
file.close() file.close()
def polyfitR2(x, y, deg): def genLegend(fits, coefs, module, r2):
''' from internet, check math'''
z = np.polyfit(x, y, deg)
p = np.poly1d(z)
yhat = p(x) # or [p(z) for z in x]
ybar = np.sum(y)/len(y) # or sum(y)/len(y)
ssreg = np.sum((yhat-ybar)**2) # or sum([ (yihat - ybar)**2 for yihat in yhat])
sstot = np.sum((y - ybar)**2) # or sum([ (yi - ybar)**2 for yi in y])
r2 = ssreg / sstot
return p, r2
def plotPPA(module, freq, var): coefsr = [str(round(c, 3)) for c in coefs]
eq = ''
ind = 0
if 'c' in fits:
eq += coefsr[ind]
ind += 1
if 'l' in fits:
eq += " + " + coefsr[ind] + "*N"
ind += 1
if 's' in fits:
eq += " + " + coefsr[ind] + "*N^2"
ind += 1
if 'g' in fits:
eq += " + " + coefsr[ind] + "*log2(N)"
ind += 1
if 'n' in fits:
eq += " + " + coefsr[ind] + "*Nlog2(N)"
ind += 1
legend_elements = [lines.Line2D([0], [0], color='orange', label=eq),
lines.Line2D([0], [0], color='steelblue', ls='', marker='o', label=' R^2='+ str(round(r2, 4)))]
return legend_elements
def plotPPA(module, freq, var, ax=None, fits='clsgn'):
''' '''
module: string module name module: string module name
freq: int freq (GHz) freq: int freq (MHz)
var: string 'delay' or 'area' var: string delay, area, lpower, or denergy
fits: constant, linear, square, log2, Nlog2
plots chosen variable vs width for all matching syntheses with regression plots chosen variable vs width for all matching syntheses with regression
''' '''
widths, metric, units = getVals(module, freq, var)
# A = np.vstack([x, np.ones(len(x))]).T coefs, r2, funcArr = regress(widths, metric, fits)
# mcresid = np.linalg.lstsq(A, y, rcond=None)
# m, c = mcresid[0]
# resid = mcresid[1]
# r2 = 1 - resid / (y.size * y.var())
# p, r2p = polyfitR2(x, y, 2)
# zlog = np.polyfit(np.log(x), y, 1)
# plog = np.poly1d(zlog)
# xplog = np.log(xp)
# _ = plt.plot(x, m*x + c, 'r', label='Linear fit R^2='+ str(r2)[1:7])
# _ = plt.plot(xp, p(xp), label='Quadratic fit R^2='+ str(r2p)[:6])
# _ = plt.plot(xp, plog(xplog), label = 'Log fit')
widths, ivar, units = getVals(module, freq, var)
coefs, r2 = regress(widths, ivar)
xp = np.linspace(8, 140, 200) xp = np.linspace(8, 140, 200)
pred = [coefs[0] + x*coefs[1] + np.log(x)*coefs[2] + x*np.log(x)*coefs[3] for x in xp] pred = []
for x in xp:
y = [func(x) for func in funcArr]
pred += [sum(np.multiply(coefs, y))]
r2p = round(r2[0], 4) if ax is None:
rcoefs = [round(c, 3) for c in coefs] singlePlot = True
ax = plt.gca()
else:
singlePlot = False
l = "{} + {}*N + {}*log(N) + {}*Nlog(N)".format(*rcoefs) ax.scatter(widths, metric)
legend_elements = [lines.Line2D([0], [0], color='steelblue', label=module), ax.plot(xp, pred, color='orange')
lines.Line2D([0], [0], color='orange', label=l),
lines.Line2D([0], [0], ls='', label=' R^2='+ str(r2p))]
_ = plt.plot(widths, ivar, 'o', label=module, markersize=10) legend_elements = genLegend(fits, coefs, module, r2)
_ = plt.plot(xp, pred) ax.legend(handles=legend_elements)
_ = plt.legend(handles=legend_elements)
_ = plt.xlabel("Width (bits)") ax.set_xticks(widths)
_ = plt.ylabel(str.title(var) + units) ax.set_xlabel("Width (bits)")
_ = plt.title("Target frequency " + str(freq) + "MHz") ax.set_ylabel(str.title(var) + units)
if singlePlot:
ax.set_title(module + " (target " + str(freq) + "MHz)")
plt.show()
def makePlots(mod, freq):
fig, axs = plt.subplots(2, 2)
plotPPA(mod, freq, 'delay', ax=axs[0,0], fits='cgl')
plotPPA(mod, freq, 'area', ax=axs[0,1], fits='clg')
plotPPA(mod, freq, 'lpower', ax=axs[1,0], fits='c')
plotPPA(mod, freq, 'denergy', ax=axs[1,1], fits='glc')
plt.suptitle(mod + " (target " + str(freq) + "MHz)")
plt.show() plt.show()
def makePlots(mod): def regress(widths, var, fits='clsgn'):
plotPPA(mod, 5000, 'delay')
plotPPA(mod, 5000, 'area')
plotPPA(mod, 10, 'area')
plotPPA(mod, 5000, 'lpower')
plotPPA(mod, 5000, 'dpower')
def regress(widths, var): funcArr = genFuncs(fits)
mat = [] mat = []
for w in widths: for w in widths:
row = [1, w, np.log(w), w*np.log(w)] row = []
for func in funcArr:
row += [func(w)]
mat += [row] mat += [row]
y = np.array(var, dtype=np.float) y = np.array(var, dtype=np.float)
coefsResid = np.linalg.lstsq(mat, y, rcond=None) coefsResid = np.linalg.lstsq(mat, y, rcond=None)
coefs = coefsResid[0] coefs = coefsResid[0]
resid = coefsResid[1] try:
resid = coefsResid[1][0]
except:
resid = 0
r2 = 1 - resid / (y.size * y.var()) r2 = 1 - resid / (y.size * y.var())
return coefs, r2 return coefs, r2, funcArr
def makeCoefTable(): def makeCoefTable():
file = open("ppaFitting.csv", "w") file = open("ppaFitting.csv", "w")
writer = csv.writer(file) writer = csv.writer(file)
writer.writerow(['Module', 'Metric', 'Freq', '1', 'N', 'log(N)', 'Nlog(N)', 'R^2']) writer.writerow(['Module', 'Metric', 'Freq', '1', 'N', 'N^2', 'log2(N)', 'Nlog2(N)', 'R^2'])
for mod in ['add', 'mult', 'comparator', 'shifter']: for mod in ['add', 'mult', 'comparator', 'shifter']:
for comb in [['delay', 5000], ['area', 5000], ['area', 10]]: for comb in [['delay', 5000], ['area', 5000], ['area', 10]]:
var = comb[0] var = comb[0]
freq = comb[1] freq = comb[1]
widths, ivar, units = getVals(mod, freq, var) widths, metric, units = getVals(mod, freq, var)
coefs, r2 = regress(widths, ivar) coefs, r2, funcArr = regress(widths, metric)
row = [mod] + comb + np.ndarray.tolist(coefs) + [r2[0]] row = [mod] + comb + np.ndarray.tolist(coefs) + [r2]
writer.writerow(row) writer.writerow(row)
file.close() file.close()
def genFuncs(fits='clsgn'):
funcArr = []
if 'c' in fits:
funcArr += [lambda x: 1]
if 'l' in fits:
funcArr += [lambda x: x]
if 's' in fits:
funcArr += [lambda x: x**2]
if 'g' in fits:
funcArr += [lambda x: np.log2(x)]
if 'n' in fits:
funcArr += [lambda x: x*np.log2(x)]
return funcArr
def noOutliers(freqs, delays, areas):
med = statistics.median(freqs)
f=[]
d=[]
a=[]
for i in range(len(freqs)):
norm = freqs[i]/med
if (norm > 0.25) & (norm<1.75):
f += [freqs[i]]
d += [delays[i]]
a += [areas[i]]
return f, d, a
def freqPlot(mod, width):
freqs = []
delays = []
areas = []
for oneSynth in allSynths:
if (mod == oneSynth[0]) & (width == oneSynth[1]):
freqs += [oneSynth[2]]
delays += [oneSynth[3]]
areas += [oneSynth[4]]
freqs, delays, areas = noOutliers(freqs, delays, areas)
adprod = np.multiply(areas, delays)
adsq = np.multiply(adprod, delays)
f, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, sharex=True)
ax1.scatter(freqs, delays)
ax2.scatter(freqs, areas)
ax3.scatter(freqs, adprod)
ax4.scatter(freqs, adsq)
ax4.set_xlabel("Freq (MHz)")
ax1.set_ylabel('Delay (ns)')
ax2.set_ylabel('Area (sq microns)')
ax3.set_ylabel('Area * Delay')
ax4.set_ylabel('Area * Delay^2')
ax1.set_title(mod + '_' + str(width))
plt.show()
allSynths = getData() allSynths = getData()
writeCSV(allSynths) writeCSV(allSynths)
# makeCoefTable()
makePlots('shifter') freqPlot('comparator', 8)
makeCoefTable() # makePlots('shifter', 5000)
# plotPPA('comparator', 5000, 'delay', fits='cls')

View File

@ -1,67 +1,197 @@
Module,Width,Target Freq,Delay,Area,D Power (mW),L Power (nW) Module,Width,Target Freq,Delay,Area,L Power (nW),D energy (mJ)
add,128,10,7.100851,1867.879976,0.00501,465.925 add,128,10,7.100851,1867.879976,465.925,0.0005009999999999999
add,128,5000,0.389771,7007.980119,3.309,2.77 add,128,1538,0.633294,4623.64009,632.254,0.00027958387516254874
add,16,10,2.032906,221.479998,0.000575,55.29 add,128,2051,0.486762,4951.940095,885.884,0.0003568990736226231
add,16,4000,0.249839,551.74001,0.239,302.479 add,128,2359,0.423881,5520.340104,1.49,0.00045146248410343363
add,16,5000,0.228259,924.140017,0.519,641.631 add,128,2410,0.414767,5600.700103,1.57,0.00045684647302904563
add,16,6000,0.225754,1120.140018,0.739,1.01 add,128,2462,0.406101,5721.240105,1.77,0.0004780666125101544
add,32,10,4.160501,456.679995,0.00118,112.161 add,128,2513,0.397913,6085.800112,2.14,0.0005161161957819339
add,32,4000,0.280842,1730.680031,0.735,849.828 add,128,2564,0.436395,6456.240111,2.27,0.0005503120124804992
add,32,5000,0.2505,1933.540033,1.049,1.03 add,128,2615,0.390136,6662.040117,2.45,0.0006137667304015296
add,32,6000,0.271774,1746.36003,1.138,955.901 add,128,2667,0.394304,7494.060127,3.58,0.00072928383952006
add,64,10,8.474034,927.079988,0.00246,230.083 add,128,2718,0.407908,7287.280117,3.35,0.0006938925680647534
add,64,4000,0.323267,3758.300065,1.523,1.75 add,128,2769,0.431383,6941.340124,2.86,0.0006218851570964247
add,64,5000,0.334061,3798.480071,1.917,2.18 add,128,3077,0.387515,7712.60013,2.93,0.0007572310692232694
add,64,6000,0.328457,3749.480066,2.346,1.77 add,128,3590,0.386891,6860.000114,2.62,0.0006579387186629527
add,8,10,0.940062,103.879999,0.000241,24.765 add,128,5000,0.389771,7007.980119,2.77,0.0006618
add,8,5000,0.199689,197.960003,0.113,83.576 add,16,10,2.032906,221.479998,55.29,5.75e-05
comparator,128,10,0.842074,1997.240039,0.00087,243.506 add,16,2609,0.375085,405.720008,52.28,2.9359908010732082e-05
comparator,128,5000,0.260142,5215.56005,3.708,6.0 add,16,3478,0.287131,443.940009,126.253,4.1978148361127085e-05
comparator,16,10,0.576329,252.840005,0.000144,31.402 add,16,4000,0.249839,551.74001,302.479,5.9749999999999995e-05
comparator,16,4000,0.249312,280.280005,0.0581,55.248 add,16,4087,0.243761,503.720009,183.936,5.113775385368241e-05
comparator,16,5000,0.199026,313.600006,0.0859,78.893 add,16,4174,0.239287,549.780011,304.811,6.013416387158601e-05
comparator,16,6000,0.166568,422.380007,0.255,301.506 add,16,4261,0.234402,607.60001,368.742,6.688570758038019e-05
comparator,32,10,0.765874,495.88001,0.000226,66.41 add,16,4348,0.22992,610.540011,364.173,6.577736890524379e-05
comparator,32,4000,0.24995,608.580012,0.168,130.613 add,16,4435,0.22545,666.400011,419.709,7.891770011273957e-05
comparator,32,5000,0.205372,919.240014,0.43,840.47 add,16,4522,0.222724,820.260016,626.379,9.022556390977442e-05
comparator,32,6000,0.2012,1248.520016,0.928,1.48 add,16,4609,0.221986,815.360013,735.998,8.960729008461705e-05
comparator,64,10,0.561562,1008.42002,0.000449,127.626 add,16,4696,0.227412,866.320016,645.684,9.731686541737649e-05
comparator,64,4000,0.249905,1437.660027,0.462,558.66 add,16,5000,0.228259,924.140017,641.631,0.0001038
comparator,64,5000,0.219296,2738.120023,1.989,2.95 add,16,5217,0.22222,824.180016,601.276,8.778991757715163e-05
comparator,64,6000,0.221138,2341.220025,1.343,2.59 add,16,6000,0.225754,1120.140018,1.01,0.00012316666666666666
comparator,8,10,0.29577,118.580002,6.83e-05,16.053 add,16,6087,0.226225,857.500013,678.287,0.00010284212255626745
comparator,8,5000,0.195502,129.360003,0.0358,21.443 add,32,10,4.160501,456.679995,112.161,0.00011800000000000001
mult,128,10,9.334627,180734.540854,0.428,1.8 add,32,2400,0.41509,958.440019,151.083,6.875e-05
mult,128,5000,1.78322,314617.244472,997.34,1.63 add,32,3200,0.312424,1121.120021,296.836,0.000105625
mult,16,10,4.730546,3869.040009,0.0107,641.517 add,32,3680,0.271527,1465.100024,591.825,0.00015000000000000001
mult,16,4000,0.821111,9132.620147,14.407,8.03 add,32,3760,0.278449,1689.520028,834.387,0.00017898936170212767
mult,16,5000,0.820059,9583.420143,20.175,8.5 add,32,3840,0.291206,1547.420027,784.112,0.00015859375
mult,16,6000,0.831308,8594.600132,21.106,7.15 add,32,3920,0.273454,2044.280039,1.33,0.00022066326530612246
mult,32,10,7.575772,12412.680067,0.0229,1.18 add,32,4000,0.280842,1730.680031,849.828,0.00018375
mult,32,4000,1.091389,31262.980534,65.471,2.49 add,32,4080,0.256294,1991.360031,1.24,0.00021397058823529412
mult,32,5000,1.092153,31497.200524,79.554,2.58 add,32,4160,0.253175,2031.540036,1.24,0.00021995192307692308
mult,32,6000,1.084816,33519.920555,103.798,2.91 add,32,4240,0.268332,1829.660028,1.09,0.00019245283018867924
mult,64,10,4.7933,46798.920227,0.103,5.46 add,32,4320,0.254861,1716.960028,866.723,0.0001814814814814815
mult,64,4000,1.411752,93087.261425,227.876,6.05 add,32,4800,0.258491,1955.100033,1.07,0.00022458333333333334
mult,64,5000,1.404875,94040.801492,298.667,6.16 add,32,5000,0.2505,1933.540033,1.03,0.00020979999999999998
mult,64,6000,1.415466,89931.661403,337.302,5.63 add,32,5600,0.254525,1871.800028,877.446,0.0001967857142857143
mult,8,10,2.076433,1009.399998,0.00206,211.637 add,32,6000,0.271774,1746.36003,955.901,0.00018966666666666665
mult,8,5000,0.552339,4261.040075,5.543,5.05 add,64,10,8.474034,927.079988,230.083,0.000246
mux2,1,10,0.060639,6.86,5.15e-06,1.19 add,64,1818,0.538894,2114.840041,250.049,0.0001375137513751375
mux2,1,10,0.060639,6.86,5.15e-06,1.19 add,64,2424,0.412474,2298.100044,453.413,0.00017574257425742574
shifter,128,10,2.758726,9722.580189,0.00789,720.698 add,64,2788,0.358537,2637.180048,758.693,0.00023565279770444765
shifter,128,5000,0.401118,19106.080347,6.94,1.23 add,64,2848,0.351091,2625.420049,698.362,0.00023525280898876406
shifter,16,10,1.237745,681.100013,0.000441,52.029 add,64,2909,0.343753,2800.840049,852.781,0.0002536954279821244
shifter,16,5000,0.209586,2120.720031,1.025,2.15 add,64,2970,0.337807,3412.360059,1.37,0.00032895622895622896
shifter,32,10,1.906335,1656.200032,0.00115,118.773 add,64,3030,0.331556,3202.640054,1.28,0.0003099009900990099
shifter,32,4000,0.260606,3490.760054,1.282,2.57 add,64,3091,0.349251,3284.960053,1.35,0.00031802005823358134
shifter,32,4000,0.260606,3490.760054,1.282,2.57 add,64,3152,0.328164,3804.360061,1.89,0.00038229695431472085
shifter,32,4000,0.260606,3490.760054,1.282,2.57 add,64,3212,0.336436,3593.660062,1.72,0.00035523038605230384
shifter,32,5000,0.238962,4985.260077,2.489,4.9 add,64,3273,0.311119,3816.120062,1.96,0.0003923006416131989
shifter,32,6000,0.241742,4312.000069,2.411,3.71 add,64,3636,0.330032,3266.340054,1.22,0.00033938393839383937
shifter,32,6000,0.241742,4312.000069,2.411,3.71 add,64,4000,0.323267,3758.300065,1.75,0.00038074999999999996
shifter,32,6000,0.241742,4312.000069,2.411,3.71 add,64,4242,0.328234,3507.420063,1.57,0.00033757661480433756
shifter,64,10,2.919486,4346.300085,0.00297,210.734 add,64,5000,0.334061,3798.480071,2.18,0.0003834
shifter,64,5000,0.358993,9471.700156,4.518,6.94 add,64,6000,0.328457,3749.480066,1.77,0.000391
shifter,8,10,0.622998,244.020005,0.00019,26.943 add,8,10,0.940062,103.879999,24.765,2.41e-05
shifter,8,5000,0.198885,495.88001,0.285,300.128 add,8,5000,0.199689,197.960003,83.576,2.26e-05
comparator,128,10,0.842074,1997.240039,243.506,8.7e-05
comparator,128,5000,0.260142,5215.56005,6.0,0.0007416
comparator,16,10000,0.146177,1065.260009,1.61,0.00012470000000000002
comparator,16,10,0.576329,252.840005,31.402,1.4400000000000001e-05
comparator,16,5000,0.199026,313.600006,78.893,1.718e-05
comparator,16,6000,0.166568,422.380007,301.506,4.25e-05
comparator,32,10000,0.194087,1451.380013,1.85,0.00024430000000000003
comparator,32,10,0.765874,495.88001,66.41,2.26e-05
comparator,32,4000,0.24995,608.580012,130.613,4.2000000000000004e-05
comparator,32,5000,0.205372,919.240014,840.47,8.6e-05
comparator,32,6000,0.2012,1248.520016,1.48,0.00015466666666666667
comparator,64,10,0.561562,1008.42002,127.626,4.49e-05
comparator,64,4000,0.249905,1437.660027,558.66,0.0001155
comparator,64,5000,0.219296,2738.120023,2.95,0.0003978
comparator,64,6000,0.221138,2341.220025,2.59,0.00022383333333333332
comparator,8,10000,0.1136,496.86,810.074,6.46e-05
comparator,8,10909,0.11361,387.1,565.114,5.885049042075351e-05
comparator,8,10,0.29577,118.580002,16.053,6.830000000000001e-06
comparator,8,12727,0.113615,488.039998,768.445,6.364422094759174e-05
comparator,8,5000,0.195502,129.360003,21.443,7.16e-06
comparator,8,5455,0.182936,130.340003,22.567,7.259395050412466e-06
comparator,8,7273,0.13643,147.980003,61.898,1.4711948301938677e-05
comparator,8,8364,0.119528,210.700003,172.337,2.654232424677188e-05
comparator,8,8545,0.116724,205.800003,165.947,2.7969572849619658e-05
comparator,8,8727,0.124671,264.600002,278.768,3.55219433940644e-05
comparator,8,8909,0.11208,261.660004,251.629,3.5694241777977326e-05
comparator,8,9091,0.10991,297.920001,343.785,3.882961170388296e-05
comparator,8,9273,0.107742,309.680003,356.05,4.162622667960746e-05
comparator,8,9455,0.106411,345.94,438.668,4.569011105235325e-05
comparator,8,9636,0.111488,397.88,589.556,5.645496056454961e-05
comparator,8,9818,0.11361,381.219999,573.131,5.265838256264005e-05
mult,128,10,9.334627,180734.540854,1.8,0.0428
mult,128,337,2.963253,201889.800086,2.67,0.045112759643916915
mult,128,449,2.227145,212055.340673,3.27,0.04989086859688196
mult,128,5000,1.78322,314617.244472,1.63,0.199468
mult,128,517,1.934229,243417.302347,5.67,0.08774468085106382
mult,128,528,1.893939,255011.682875,6.65,0.10337878787878789
mult,128,539,1.855281,259737.242949,7.18,0.10912615955473098
mult,128,551,1.814879,274624.423573,8.73,0.12750816696914702
mult,128,562,1.779353,284850.723775,1.03,0.1501779359430605
mult,128,573,1.745187,296812.604204,1.08,0.14241186736474695
mult,128,584,1.712328,298800.044147,1.15,0.14923630136986302
mult,128,596,1.71139,312992.404301,1.44,0.16681040268456376
mult,128,607,1.707473,305974.624156,1.38,0.1625996705107084
mult,128,674,1.727276,311582.184447,1.52,0.18965133531157272
mult,128,787,1.735561,317542.544465,1.66,0.19689453621346886
mult,16,10,4.730546,3869.040009,641.517,0.00107
mult,16,1122,0.891172,6478.780105,3.54,0.002767379679144385
mult,16,1146,0.87258,7193.200125,4.57,0.003224258289703316
mult,16,1171,0.853963,7258.860127,4.57,0.0031195559350982068
mult,16,1195,0.836814,7685.16012,5.33,0.0032225941422594144
mult,16,1220,0.81966,8829.800131,6.95,0.0035008196721311477
mult,16,1244,0.822616,8780.800145,7.15,0.0033842443729903537
mult,16,1268,0.802449,9789.220166,8.8,0.0038998422712933755
mult,16,1293,0.813903,9702.000166,8.74,0.0036071152358855374
mult,16,1317,0.805748,10366.440177,1.01,0.003979498861047836
mult,16,1463,0.83466,8521.100128,6.71,0.0035974025974025974
mult,16,1707,0.829615,8563.24013,6.78,0.003674282366725249
mult,16,4000,0.821111,9132.620147,8.03,0.00360175
mult,16,5000,0.820059,9583.420143,8.5,0.004035
mult,16,6000,0.831308,8594.600132,7.15,0.0035176666666666668
mult,16,732,1.36399,4043.480026,624.48,0.0006612021857923497
mult,16,976,1.024406,4960.760064,1.32,0.0011854508196721312
mult,32,1000,1.099618,29507.800463,2.24,0.015257
mult,32,10,7.575772,12412.680067,1.18,0.00229
mult,32,1111,1.092041,31649.100517,2.53,0.01587128712871287
mult,32,1296,1.097292,30544.640517,2.37,0.015766203703703702
mult,32,4000,1.091389,31262.980534,2.49,0.01636775
mult,32,5000,1.092153,31497.200524,2.58,0.0159108
mult,32,556,1.796075,14371.700056,2.21,0.002714028776978417
mult,32,6000,1.084816,33519.920555,2.91,0.017299666666666668
mult,32,741,1.349466,17389.120212,4.65,0.005995951417004048
mult,32,852,1.173643,23514.120391,1.27,0.012269953051643193
mult,32,870,1.149401,25198.740416,1.5,0.013455172413793104
mult,32,889,1.124838,26822.600434,1.8,0.01463217097862767
mult,32,907,1.102529,29124.620481,2.08,0.014771775082690187
mult,32,926,1.101021,31000.340484,2.46,0.014745140388768898
mult,32,944,1.085045,32407.620517,2.68,0.01608262711864407
mult,32,963,1.089271,32490.92054,2.7,0.016202492211838004
mult,32,981,1.091413,33127.920535,2.84,0.017559633027522933
mult,64,1000,1.350119,103523.281624,7.3,0.05962
mult,64,10,4.7933,46798.920227,5.46,0.0103
mult,64,4000,1.411752,93087.261425,6.05,0.056969
mult,64,429,2.326205,53642.260108,7.4,0.011111888111888112
mult,64,5000,1.404875,94040.801492,6.16,0.05973339999999999
mult,64,571,1.751186,58587.340388,1.1,0.01569352014010508
mult,64,6000,1.415466,89931.661403,5.63,0.056217
mult,64,657,1.52205,69763.260863,2.39,0.03356773211567732
mult,64,671,1.490298,74604.461058,2.89,0.039280178837555885
mult,64,686,1.457722,78293.181181,3.18,0.04122594752186589
mult,64,700,1.428547,82949.161302,3.92,0.04733428571428572
mult,64,714,1.400528,87215.101373,4.39,0.04964425770308123
mult,64,729,1.371734,93726.221523,5.35,0.05337037037037037
mult,64,743,1.345895,95943.961579,5.62,0.05491924629878869
mult,64,757,1.341232,106627.921626,7.73,0.058137384412153235
mult,64,771,1.341474,98844.761554,6.33,0.05606225680933852
mult,64,857,1.336163,107976.401664,7.95,0.059478413068844806
mult,8,1091,0.915221,1167.180013,211.892,0.00017048579285059578
mult,8,10,2.076433,1009.399998,211.637,0.00020600000000000002
mult,8,1455,0.687251,1615.04003,680.207,0.0004233676975945017
mult,8,1673,0.611485,2094.260033,1.39,0.000639569635385535
mult,8,1709,0.599356,2453.920037,2.01,0.0008338209479227619
mult,8,1745,0.589521,2771.440043,2.58,0.0008406876790830946
mult,8,1782,0.582418,2549.960043,2.14,0.0008759820426487093
mult,8,1818,0.581954,2672.460046,2.2,0.0008663366336633663
mult,8,1855,0.605444,2332.40004,1.74,0.0007547169811320754
mult,8,1891,0.605341,2405.90004,1.93,0.0007599153886832364
mult,8,1927,0.574177,3273.200051,3.43,0.0009600415153087702
mult,8,1964,0.585681,2746.940044,2.48,0.0008778004073319755
mult,8,2182,0.550085,4360.02008,5.2,0.0011608615948670944
mult,8,2545,0.564127,4034.66007,4.58,0.0011772102161100196
mult,8,5000,0.552339,4261.040075,5.05,0.0011086
mux2,1,10,0.060639,6.86,1.19,5.149999999999999e-07
mux2,1,10,0.060639,6.86,1.19,5.149999999999999e-07
shifter,128,10,2.758726,9722.580189,720.698,0.000789
shifter,128,5000,0.401118,19106.080347,1.23,0.0013880000000000001
shifter,16,10,1.237745,681.100013,52.029,4.41e-05
shifter,16,5000,0.209586,2120.720031,2.15,0.000205
shifter,32,10,1.906335,1656.200032,118.773,0.000115
shifter,32,4000,0.260606,3490.760054,2.57,0.0003205
shifter,32,4000,0.260606,3490.760054,2.57,0.0003205
shifter,32,4000,0.260606,3490.760054,2.57,0.0003205
shifter,32,5000,0.238962,4985.260077,4.9,0.0004978
shifter,32,6000,0.241742,4312.000069,3.71,0.00040183333333333336
shifter,32,6000,0.241742,4312.000069,3.71,0.00040183333333333336
shifter,32,6000,0.241742,4312.000069,3.71,0.00040183333333333336
shifter,64,10,2.919486,4346.300085,210.734,0.000297
shifter,64,5000,0.358993,9471.700156,6.94,0.0009036
shifter,8,10,0.622998,244.020005,26.943,1.9e-05
shifter,8,5000,0.198885,495.88001,300.128,5.6999999999999996e-05

1 Module Width Target Freq Delay Area D Power (mW) L Power (nW) D energy (mJ)
2 add 128 10 7.100851 1867.879976 0.00501 465.925 0.0005009999999999999
3 add 128 5000 1538 0.389771 0.633294 7007.980119 4623.64009 3.309 2.77 632.254 0.00027958387516254874
4 add 16 128 10 2051 2.032906 0.486762 221.479998 4951.940095 0.000575 55.29 885.884 0.0003568990736226231
5 add 16 128 4000 2359 0.249839 0.423881 551.74001 5520.340104 0.239 302.479 1.49 0.00045146248410343363
6 add 16 128 5000 2410 0.228259 0.414767 924.140017 5600.700103 0.519 641.631 1.57 0.00045684647302904563
7 add 16 128 6000 2462 0.225754 0.406101 1120.140018 5721.240105 0.739 1.01 1.77 0.0004780666125101544
8 add 32 128 10 2513 4.160501 0.397913 456.679995 6085.800112 0.00118 112.161 2.14 0.0005161161957819339
9 add 32 128 4000 2564 0.280842 0.436395 1730.680031 6456.240111 0.735 849.828 2.27 0.0005503120124804992
10 add 32 128 5000 2615 0.2505 0.390136 1933.540033 6662.040117 1.049 1.03 2.45 0.0006137667304015296
11 add 32 128 6000 2667 0.271774 0.394304 1746.36003 7494.060127 1.138 955.901 3.58 0.00072928383952006
12 add 64 128 10 2718 8.474034 0.407908 927.079988 7287.280117 0.00246 230.083 3.35 0.0006938925680647534
13 add 64 128 4000 2769 0.323267 0.431383 3758.300065 6941.340124 1.523 1.75 2.86 0.0006218851570964247
14 add 64 128 5000 3077 0.334061 0.387515 3798.480071 7712.60013 1.917 2.18 2.93 0.0007572310692232694
15 add 64 128 6000 3590 0.328457 0.386891 3749.480066 6860.000114 2.346 1.77 2.62 0.0006579387186629527
16 add 8 128 10 5000 0.940062 0.389771 103.879999 7007.980119 0.000241 24.765 2.77 0.0006618
17 add 8 16 5000 10 0.199689 2.032906 197.960003 221.479998 0.113 83.576 55.29 5.75e-05
18 comparator add 128 16 10 2609 0.842074 0.375085 1997.240039 405.720008 0.00087 243.506 52.28 2.9359908010732082e-05
19 comparator add 128 16 5000 3478 0.260142 0.287131 5215.56005 443.940009 3.708 6.0 126.253 4.1978148361127085e-05
20 comparator add 16 10 4000 0.576329 0.249839 252.840005 551.74001 0.000144 31.402 302.479 5.9749999999999995e-05
21 comparator add 16 4000 4087 0.249312 0.243761 280.280005 503.720009 0.0581 55.248 183.936 5.113775385368241e-05
22 comparator add 16 5000 4174 0.199026 0.239287 313.600006 549.780011 0.0859 78.893 304.811 6.013416387158601e-05
23 comparator add 16 6000 4261 0.166568 0.234402 422.380007 607.60001 0.255 301.506 368.742 6.688570758038019e-05
24 comparator add 32 16 10 4348 0.765874 0.22992 495.88001 610.540011 0.000226 66.41 364.173 6.577736890524379e-05
25 comparator add 32 16 4000 4435 0.24995 0.22545 608.580012 666.400011 0.168 130.613 419.709 7.891770011273957e-05
26 comparator add 32 16 5000 4522 0.205372 0.222724 919.240014 820.260016 0.43 840.47 626.379 9.022556390977442e-05
27 comparator add 32 16 6000 4609 0.2012 0.221986 1248.520016 815.360013 0.928 1.48 735.998 8.960729008461705e-05
28 comparator add 64 16 10 4696 0.561562 0.227412 1008.42002 866.320016 0.000449 127.626 645.684 9.731686541737649e-05
29 comparator add 64 16 4000 5000 0.249905 0.228259 1437.660027 924.140017 0.462 558.66 641.631 0.0001038
30 comparator add 64 16 5000 5217 0.219296 0.22222 2738.120023 824.180016 1.989 2.95 601.276 8.778991757715163e-05
31 comparator add 64 16 6000 0.221138 0.225754 2341.220025 1120.140018 1.343 2.59 1.01 0.00012316666666666666
32 comparator add 8 16 10 6087 0.29577 0.226225 118.580002 857.500013 6.83e-05 16.053 678.287 0.00010284212255626745
33 comparator add 8 32 5000 10 0.195502 4.160501 129.360003 456.679995 0.0358 21.443 112.161 0.00011800000000000001
34 mult add 128 32 10 2400 9.334627 0.41509 180734.540854 958.440019 0.428 1.8 151.083 6.875e-05
35 mult add 128 32 5000 3200 1.78322 0.312424 314617.244472 1121.120021 997.34 1.63 296.836 0.000105625
36 mult add 16 32 10 3680 4.730546 0.271527 3869.040009 1465.100024 0.0107 641.517 591.825 0.00015000000000000001
37 mult add 16 32 4000 3760 0.821111 0.278449 9132.620147 1689.520028 14.407 8.03 834.387 0.00017898936170212767
38 mult add 16 32 5000 3840 0.820059 0.291206 9583.420143 1547.420027 20.175 8.5 784.112 0.00015859375
39 mult add 16 32 6000 3920 0.831308 0.273454 8594.600132 2044.280039 21.106 7.15 1.33 0.00022066326530612246
40 mult add 32 10 4000 7.575772 0.280842 12412.680067 1730.680031 0.0229 1.18 849.828 0.00018375
41 mult add 32 4000 4080 1.091389 0.256294 31262.980534 1991.360031 65.471 2.49 1.24 0.00021397058823529412
42 mult add 32 5000 4160 1.092153 0.253175 31497.200524 2031.540036 79.554 2.58 1.24 0.00021995192307692308
43 mult add 32 6000 4240 1.084816 0.268332 33519.920555 1829.660028 103.798 2.91 1.09 0.00019245283018867924
44 mult add 64 32 10 4320 4.7933 0.254861 46798.920227 1716.960028 0.103 5.46 866.723 0.0001814814814814815
45 mult add 64 32 4000 4800 1.411752 0.258491 93087.261425 1955.100033 227.876 6.05 1.07 0.00022458333333333334
46 mult add 64 32 5000 1.404875 0.2505 94040.801492 1933.540033 298.667 6.16 1.03 0.00020979999999999998
47 mult add 64 32 6000 5600 1.415466 0.254525 89931.661403 1871.800028 337.302 5.63 877.446 0.0001967857142857143
48 mult add 8 32 10 6000 2.076433 0.271774 1009.399998 1746.36003 0.00206 211.637 955.901 0.00018966666666666665
49 mult add 8 64 5000 10 0.552339 8.474034 4261.040075 927.079988 5.543 5.05 230.083 0.000246
50 mux2 add 1 64 10 1818 0.060639 0.538894 6.86 2114.840041 5.15e-06 1.19 250.049 0.0001375137513751375
51 mux2 add 1 64 10 2424 0.060639 0.412474 6.86 2298.100044 5.15e-06 1.19 453.413 0.00017574257425742574
52 shifter add 128 64 10 2788 2.758726 0.358537 9722.580189 2637.180048 0.00789 720.698 758.693 0.00023565279770444765
53 shifter add 128 64 5000 2848 0.401118 0.351091 19106.080347 2625.420049 6.94 1.23 698.362 0.00023525280898876406
54 shifter add 16 64 10 2909 1.237745 0.343753 681.100013 2800.840049 0.000441 52.029 852.781 0.0002536954279821244
55 shifter add 16 64 5000 2970 0.209586 0.337807 2120.720031 3412.360059 1.025 2.15 1.37 0.00032895622895622896
56 shifter add 32 64 10 3030 1.906335 0.331556 1656.200032 3202.640054 0.00115 118.773 1.28 0.0003099009900990099
57 shifter add 32 64 4000 3091 0.260606 0.349251 3490.760054 3284.960053 1.282 2.57 1.35 0.00031802005823358134
58 shifter add 32 64 4000 3152 0.260606 0.328164 3490.760054 3804.360061 1.282 2.57 1.89 0.00038229695431472085
59 shifter add 32 64 4000 3212 0.260606 0.336436 3490.760054 3593.660062 1.282 2.57 1.72 0.00035523038605230384
60 shifter add 32 64 5000 3273 0.238962 0.311119 4985.260077 3816.120062 2.489 4.9 1.96 0.0003923006416131989
61 shifter add 32 64 6000 3636 0.241742 0.330032 4312.000069 3266.340054 2.411 3.71 1.22 0.00033938393839383937
62 shifter add 32 64 6000 4000 0.241742 0.323267 4312.000069 3758.300065 2.411 3.71 1.75 0.00038074999999999996
63 shifter add 32 64 6000 4242 0.241742 0.328234 4312.000069 3507.420063 2.411 3.71 1.57 0.00033757661480433756
64 shifter add 64 10 5000 2.919486 0.334061 4346.300085 3798.480071 0.00297 210.734 2.18 0.0003834
65 shifter add 64 5000 6000 0.358993 0.328457 9471.700156 3749.480066 4.518 6.94 1.77 0.000391
66 shifter add 8 10 0.622998 0.940062 244.020005 103.879999 0.00019 26.943 24.765 2.41e-05
67 shifter add 8 5000 0.198885 0.199689 495.88001 197.960003 0.285 300.128 83.576 2.26e-05
68 comparator 128 10 0.842074 1997.240039 243.506 8.7e-05
69 comparator 128 5000 0.260142 5215.56005 6.0 0.0007416
70 comparator 16 10000 0.146177 1065.260009 1.61 0.00012470000000000002
71 comparator 16 10 0.576329 252.840005 31.402 1.4400000000000001e-05
72 comparator 16 5000 0.199026 313.600006 78.893 1.718e-05
73 comparator 16 6000 0.166568 422.380007 301.506 4.25e-05
74 comparator 32 10000 0.194087 1451.380013 1.85 0.00024430000000000003
75 comparator 32 10 0.765874 495.88001 66.41 2.26e-05
76 comparator 32 4000 0.24995 608.580012 130.613 4.2000000000000004e-05
77 comparator 32 5000 0.205372 919.240014 840.47 8.6e-05
78 comparator 32 6000 0.2012 1248.520016 1.48 0.00015466666666666667
79 comparator 64 10 0.561562 1008.42002 127.626 4.49e-05
80 comparator 64 4000 0.249905 1437.660027 558.66 0.0001155
81 comparator 64 5000 0.219296 2738.120023 2.95 0.0003978
82 comparator 64 6000 0.221138 2341.220025 2.59 0.00022383333333333332
83 comparator 8 10000 0.1136 496.86 810.074 6.46e-05
84 comparator 8 10909 0.11361 387.1 565.114 5.885049042075351e-05
85 comparator 8 10 0.29577 118.580002 16.053 6.830000000000001e-06
86 comparator 8 12727 0.113615 488.039998 768.445 6.364422094759174e-05
87 comparator 8 5000 0.195502 129.360003 21.443 7.16e-06
88 comparator 8 5455 0.182936 130.340003 22.567 7.259395050412466e-06
89 comparator 8 7273 0.13643 147.980003 61.898 1.4711948301938677e-05
90 comparator 8 8364 0.119528 210.700003 172.337 2.654232424677188e-05
91 comparator 8 8545 0.116724 205.800003 165.947 2.7969572849619658e-05
92 comparator 8 8727 0.124671 264.600002 278.768 3.55219433940644e-05
93 comparator 8 8909 0.11208 261.660004 251.629 3.5694241777977326e-05
94 comparator 8 9091 0.10991 297.920001 343.785 3.882961170388296e-05
95 comparator 8 9273 0.107742 309.680003 356.05 4.162622667960746e-05
96 comparator 8 9455 0.106411 345.94 438.668 4.569011105235325e-05
97 comparator 8 9636 0.111488 397.88 589.556 5.645496056454961e-05
98 comparator 8 9818 0.11361 381.219999 573.131 5.265838256264005e-05
99 mult 128 10 9.334627 180734.540854 1.8 0.0428
100 mult 128 337 2.963253 201889.800086 2.67 0.045112759643916915
101 mult 128 449 2.227145 212055.340673 3.27 0.04989086859688196
102 mult 128 5000 1.78322 314617.244472 1.63 0.199468
103 mult 128 517 1.934229 243417.302347 5.67 0.08774468085106382
104 mult 128 528 1.893939 255011.682875 6.65 0.10337878787878789
105 mult 128 539 1.855281 259737.242949 7.18 0.10912615955473098
106 mult 128 551 1.814879 274624.423573 8.73 0.12750816696914702
107 mult 128 562 1.779353 284850.723775 1.03 0.1501779359430605
108 mult 128 573 1.745187 296812.604204 1.08 0.14241186736474695
109 mult 128 584 1.712328 298800.044147 1.15 0.14923630136986302
110 mult 128 596 1.71139 312992.404301 1.44 0.16681040268456376
111 mult 128 607 1.707473 305974.624156 1.38 0.1625996705107084
112 mult 128 674 1.727276 311582.184447 1.52 0.18965133531157272
113 mult 128 787 1.735561 317542.544465 1.66 0.19689453621346886
114 mult 16 10 4.730546 3869.040009 641.517 0.00107
115 mult 16 1122 0.891172 6478.780105 3.54 0.002767379679144385
116 mult 16 1146 0.87258 7193.200125 4.57 0.003224258289703316
117 mult 16 1171 0.853963 7258.860127 4.57 0.0031195559350982068
118 mult 16 1195 0.836814 7685.16012 5.33 0.0032225941422594144
119 mult 16 1220 0.81966 8829.800131 6.95 0.0035008196721311477
120 mult 16 1244 0.822616 8780.800145 7.15 0.0033842443729903537
121 mult 16 1268 0.802449 9789.220166 8.8 0.0038998422712933755
122 mult 16 1293 0.813903 9702.000166 8.74 0.0036071152358855374
123 mult 16 1317 0.805748 10366.440177 1.01 0.003979498861047836
124 mult 16 1463 0.83466 8521.100128 6.71 0.0035974025974025974
125 mult 16 1707 0.829615 8563.24013 6.78 0.003674282366725249
126 mult 16 4000 0.821111 9132.620147 8.03 0.00360175
127 mult 16 5000 0.820059 9583.420143 8.5 0.004035
128 mult 16 6000 0.831308 8594.600132 7.15 0.0035176666666666668
129 mult 16 732 1.36399 4043.480026 624.48 0.0006612021857923497
130 mult 16 976 1.024406 4960.760064 1.32 0.0011854508196721312
131 mult 32 1000 1.099618 29507.800463 2.24 0.015257
132 mult 32 10 7.575772 12412.680067 1.18 0.00229
133 mult 32 1111 1.092041 31649.100517 2.53 0.01587128712871287
134 mult 32 1296 1.097292 30544.640517 2.37 0.015766203703703702
135 mult 32 4000 1.091389 31262.980534 2.49 0.01636775
136 mult 32 5000 1.092153 31497.200524 2.58 0.0159108
137 mult 32 556 1.796075 14371.700056 2.21 0.002714028776978417
138 mult 32 6000 1.084816 33519.920555 2.91 0.017299666666666668
139 mult 32 741 1.349466 17389.120212 4.65 0.005995951417004048
140 mult 32 852 1.173643 23514.120391 1.27 0.012269953051643193
141 mult 32 870 1.149401 25198.740416 1.5 0.013455172413793104
142 mult 32 889 1.124838 26822.600434 1.8 0.01463217097862767
143 mult 32 907 1.102529 29124.620481 2.08 0.014771775082690187
144 mult 32 926 1.101021 31000.340484 2.46 0.014745140388768898
145 mult 32 944 1.085045 32407.620517 2.68 0.01608262711864407
146 mult 32 963 1.089271 32490.92054 2.7 0.016202492211838004
147 mult 32 981 1.091413 33127.920535 2.84 0.017559633027522933
148 mult 64 1000 1.350119 103523.281624 7.3 0.05962
149 mult 64 10 4.7933 46798.920227 5.46 0.0103
150 mult 64 4000 1.411752 93087.261425 6.05 0.056969
151 mult 64 429 2.326205 53642.260108 7.4 0.011111888111888112
152 mult 64 5000 1.404875 94040.801492 6.16 0.05973339999999999
153 mult 64 571 1.751186 58587.340388 1.1 0.01569352014010508
154 mult 64 6000 1.415466 89931.661403 5.63 0.056217
155 mult 64 657 1.52205 69763.260863 2.39 0.03356773211567732
156 mult 64 671 1.490298 74604.461058 2.89 0.039280178837555885
157 mult 64 686 1.457722 78293.181181 3.18 0.04122594752186589
158 mult 64 700 1.428547 82949.161302 3.92 0.04733428571428572
159 mult 64 714 1.400528 87215.101373 4.39 0.04964425770308123
160 mult 64 729 1.371734 93726.221523 5.35 0.05337037037037037
161 mult 64 743 1.345895 95943.961579 5.62 0.05491924629878869
162 mult 64 757 1.341232 106627.921626 7.73 0.058137384412153235
163 mult 64 771 1.341474 98844.761554 6.33 0.05606225680933852
164 mult 64 857 1.336163 107976.401664 7.95 0.059478413068844806
165 mult 8 1091 0.915221 1167.180013 211.892 0.00017048579285059578
166 mult 8 10 2.076433 1009.399998 211.637 0.00020600000000000002
167 mult 8 1455 0.687251 1615.04003 680.207 0.0004233676975945017
168 mult 8 1673 0.611485 2094.260033 1.39 0.000639569635385535
169 mult 8 1709 0.599356 2453.920037 2.01 0.0008338209479227619
170 mult 8 1745 0.589521 2771.440043 2.58 0.0008406876790830946
171 mult 8 1782 0.582418 2549.960043 2.14 0.0008759820426487093
172 mult 8 1818 0.581954 2672.460046 2.2 0.0008663366336633663
173 mult 8 1855 0.605444 2332.40004 1.74 0.0007547169811320754
174 mult 8 1891 0.605341 2405.90004 1.93 0.0007599153886832364
175 mult 8 1927 0.574177 3273.200051 3.43 0.0009600415153087702
176 mult 8 1964 0.585681 2746.940044 2.48 0.0008778004073319755
177 mult 8 2182 0.550085 4360.02008 5.2 0.0011608615948670944
178 mult 8 2545 0.564127 4034.66007 4.58 0.0011772102161100196
179 mult 8 5000 0.552339 4261.040075 5.05 0.0011086
180 mux2 1 10 0.060639 6.86 1.19 5.149999999999999e-07
181 mux2 1 10 0.060639 6.86 1.19 5.149999999999999e-07
182 shifter 128 10 2.758726 9722.580189 720.698 0.000789
183 shifter 128 5000 0.401118 19106.080347 1.23 0.0013880000000000001
184 shifter 16 10 1.237745 681.100013 52.029 4.41e-05
185 shifter 16 5000 0.209586 2120.720031 2.15 0.000205
186 shifter 32 10 1.906335 1656.200032 118.773 0.000115
187 shifter 32 4000 0.260606 3490.760054 2.57 0.0003205
188 shifter 32 4000 0.260606 3490.760054 2.57 0.0003205
189 shifter 32 4000 0.260606 3490.760054 2.57 0.0003205
190 shifter 32 5000 0.238962 4985.260077 4.9 0.0004978
191 shifter 32 6000 0.241742 4312.000069 3.71 0.00040183333333333336
192 shifter 32 6000 0.241742 4312.000069 3.71 0.00040183333333333336
193 shifter 32 6000 0.241742 4312.000069 3.71 0.00040183333333333336
194 shifter 64 10 2.919486 4346.300085 210.734 0.000297
195 shifter 64 5000 0.358993 9471.700156 6.94 0.0009036
196 shifter 8 10 0.622998 244.020005 26.943 1.9e-05
197 shifter 8 5000 0.198885 495.88001 300.128 5.6999999999999996e-05

View File

@ -1,13 +1,13 @@
Module,Metric,Freq,1,N,log(N),Nlog(N),R^2 Module,Metric,Freq,1,N,N^2,log2(N),Nlog2(N),R^2
add,delay,5000,0.23935453005464438,0.015973094945355207,-0.058207695467226296,-0.002593789781151714,0.9902532112478974 add,delay,5000,-0.038978555556527635,-0.08911531250030817,-0.00012953428819478948,0.2083593333340971,0.013950093750045424,1.0
add,area,5000,-1032.1274349672115,64.4386855922132,374.6678949053879,-3.2579193244904823,0.9999180068922152 add,area,5000,-1913.1778463362505,-268.21377075092175,-0.4100347526051751,1046.9667200022955,47.59125331263557,1.0
add,area,10,-13.720004131149423,14.699999256147343,3.6067390521177815e-06,9.312480709428003e-08,1.0 add,area,10,-13.720001333167332,14.700000312552621,1.3021426840869221e-09,-1.3062278840780171e-10,-9.375775472819561e-08,1.0
mult,delay,5000,-0.21755360109289562,-0.00033127390710363004,0.36865114245083547,0.0004100845872014472,0.9999815499619515 mult,delay,5000,-0.2915958888891911,-0.02828693750009581,-3.445876736121953e-05,0.32169033333357117,0.0044735312500140964,1.0
mult,area,5000,-29928.193338752997,-11370.538120558254,39122.3984379376,2592.313970431163,0.9998454828501703 mult,area,5000,27780.605184113756,10418.196477973508,26.857274703166343,-24448.387256089416,-1468.2850310678027,1.0
mult,area,10,-24112.991162714883,-8735.874000034026,30452.017533199683,1892.3032427172166,0.9999575675635335 mult,area,10,-6472.791005245042,-2075.5787013197305,8.20962684330778,5345.246556351299,313.5693677823146,1.0
comparator,delay,5000,0.18302939890710385,-0.001793523907103751,0.00950014684425352,0.0004195522734073458,0.9999387049502957 comparator,delay,5000,0.1903951111111219,0.000987500000002994,3.427951388890516e-06,3.333333324460974e-06,-0.00012593750000039925,1.0
comparator,area,5000,1831.2076391201958,303.59984869227907,-1617.4342555852443,-44.475154143873425,0.9990603962758624 comparator,area,5000,-508.51109056188875,-579.7924890645068,-1.0888888741341944,969.5466443383111,101.5524983752957,1.0
comparator,area,10,-0.23027509289593326,18.299023530396347,-8.48304611908023,-0.4881808064440773,0.9999674500675539 comparator,area,10,-155.6022268893253,-40.3637507501383,-0.07230902908001494,132.9533363336765,8.452500156270371,1.0
shifter,delay,5000,0.4107033934426204,0.03923479405737683,-0.19848886911558317,-0.006549393512462493,0.989283342171845 shifter,delay,5000,0.06953233333235516,-0.08957893750031035,-0.00015877864583368578,0.16727300000076853,0.014763625000045773,1.0
shifter,area,5000,-3612.7138133224103,-65.6549821150965,1929.186263038338,35.02443853718661,0.9998392000511572 shifter,area,5000,-237.48663487568587,1208.7075255666841,1.5708073263938906,-1678.7400476770383,-166.69187856311666,1.0
shifter,area,10,806.0687632950834,120.52125970491868,-682.1783666753405,-5.1440062238735225,0.9998176364985187 shifter,area,10,-1079.4155736731122,-591.3687615645423,-0.877491337241916,1211.9333560050677,103.11437703155087,1.0

1 Module Metric Freq 1 N log(N) N^2 Nlog(N) log2(N) Nlog2(N) R^2
2 add delay 5000 0.23935453005464438 -0.038978555556527635 0.015973094945355207 -0.08911531250030817 -0.058207695467226296 -0.00012953428819478948 -0.002593789781151714 0.2083593333340971 0.013950093750045424 0.9902532112478974 1.0
3 add area 5000 -1032.1274349672115 -1913.1778463362505 64.4386855922132 -268.21377075092175 374.6678949053879 -0.4100347526051751 -3.2579193244904823 1046.9667200022955 47.59125331263557 0.9999180068922152 1.0
4 add area 10 -13.720004131149423 -13.720001333167332 14.699999256147343 14.700000312552621 3.6067390521177815e-06 1.3021426840869221e-09 9.312480709428003e-08 -1.3062278840780171e-10 -9.375775472819561e-08 1.0
5 mult delay 5000 -0.21755360109289562 -0.2915958888891911 -0.00033127390710363004 -0.02828693750009581 0.36865114245083547 -3.445876736121953e-05 0.0004100845872014472 0.32169033333357117 0.0044735312500140964 0.9999815499619515 1.0
6 mult area 5000 -29928.193338752997 27780.605184113756 -11370.538120558254 10418.196477973508 39122.3984379376 26.857274703166343 2592.313970431163 -24448.387256089416 -1468.2850310678027 0.9998454828501703 1.0
7 mult area 10 -24112.991162714883 -6472.791005245042 -8735.874000034026 -2075.5787013197305 30452.017533199683 8.20962684330778 1892.3032427172166 5345.246556351299 313.5693677823146 0.9999575675635335 1.0
8 comparator delay 5000 0.18302939890710385 0.1903951111111219 -0.001793523907103751 0.000987500000002994 0.00950014684425352 3.427951388890516e-06 0.0004195522734073458 3.333333324460974e-06 -0.00012593750000039925 0.9999387049502957 1.0
9 comparator area 5000 1831.2076391201958 -508.51109056188875 303.59984869227907 -579.7924890645068 -1617.4342555852443 -1.0888888741341944 -44.475154143873425 969.5466443383111 101.5524983752957 0.9990603962758624 1.0
10 comparator area 10 -0.23027509289593326 -155.6022268893253 18.299023530396347 -40.3637507501383 -8.48304611908023 -0.07230902908001494 -0.4881808064440773 132.9533363336765 8.452500156270371 0.9999674500675539 1.0
11 shifter delay 5000 0.4107033934426204 0.06953233333235516 0.03923479405737683 -0.08957893750031035 -0.19848886911558317 -0.00015877864583368578 -0.006549393512462493 0.16727300000076853 0.014763625000045773 0.989283342171845 1.0
12 shifter area 5000 -3612.7138133224103 -237.48663487568587 -65.6549821150965 1208.7075255666841 1929.186263038338 1.5708073263938906 35.02443853718661 -1678.7400476770383 -166.69187856311666 0.9998392000511572 1.0
13 shifter area 10 806.0687632950834 -1079.4155736731122 120.52125970491868 -591.3687615645423 -682.1783666753405 -0.877491337241916 -5.1440062238735225 1211.9333560050677 103.11437703155087 0.9998176364985187 1.0

View File

@ -14,9 +14,13 @@ def deleteRedundant(LoT):
bashCommand = synthStr.format(*synth) bashCommand = synthStr.format(*synth)
outputCPL = subprocess.check_output(['bash','-c', bashCommand]) outputCPL = subprocess.check_output(['bash','-c', bashCommand])
widths = ['1'] d = 0.26
modules = ['mux2'] f = 1/d * 1000
freqs = ['10'] arr = [-40, -20, -8, -6, -4, -2, 0, 2, 4, 6, 8, 20, 40]
widths = ['128']
modules = ['comparator']
freqs = [str(round(f+f*x/100)) for x in arr]
tech = 'sky90' tech = 'sky90'