class PipeFPCase:
- def __init__(self, dut, name, mod, fmod, width, fpfn, count, single_op):
+ def __init__(self, dut, name, mod, fmod, width, fpfn, count,
+ single_op, opcode):
self.dut = dut
self.name = name
self.mod = mod
self.fpfn = fpfn
self.count = count
self.single_op = single_op
+ self.opcode = opcode
def run(self, name, fn):
name = "%s_%s" % (self.name, name)
pipe_cornercases_repeat(self.dut, name, self.mod, self.fmod,
self.width, fn, corner_cases, self.fpfn,
- self.count, self.single_op)
+ self.count, self.single_op,
+ opcode=self.opcode)
def run_cornercases(self):
ccs = get_corner_cases(self.mod, self.single_op)
vals = repeat(self.dut.num_rows, ccs)
tname = "test_fp%s_pipe_fp%d_cornercases" % (self.name, self.width)
runfp(self.dut, self.width, tname, self.fmod, self.fpfn, vals=vals,
- single_op=self.single_op)
+ single_op=self.single_op,
+ opcode=self.opcode)
def run_regressions(self, regressions_fn):
vals = repeat(self.dut.num_rows, regressions_fn())
#print ("regressions", self.single_op, vals)
tname = "test_fp%s_pipe_fp%d_regressions" % (self.name, self.width)
runfp(self.dut, self.width, tname, self.fmod, self.fpfn, vals=vals,
- single_op=self.single_op)
+ single_op=self.single_op,
+ opcode=self.opcode)
def run_random(self):
tname = "test_fp%s_pipe_fp%d_rand" % (self.name, self.width)
runfp(self.dut, self.width, tname, self.fmod, self.fpfn,
- single_op=self.single_op)
+ single_op=self.single_op,
+ opcode=self.opcode)
def run_pipe_fp(dut, width, name, mod, fmod, regressions, fpfn, count,
- single_op=False):
- pc = PipeFPCase(dut, name, mod, fmod, width, fpfn, count, single_op)
+ single_op=False,
+ opcode=None):
+ pc = PipeFPCase(dut, name, mod, fmod, width, fpfn, count, single_op, opcode)
pc.run_regressions(regressions)
pc.run_cornercases()
pc.run("rand1", get_rand1)
#op2 = 0x4000
#op1 = 0x3c50
#op2 = 0x3e00
+ #op2 = 0xb371
+ #op1 = 0x4400
+ #op1 = 0x656c
+ op1 = 0x738c
+
vals.append((op1, op2,))
return vals
def pipe_cornercases_repeat(dut, name, mod, fmod, width, fn, cc, fpfn, count,
- single_op=False):
+ single_op=False, opcode=None):
for i, fixed_num in enumerate(cc(mod)):
vals = fn(mod, fixed_num, count, width, single_op)
vals = repeat(dut.num_rows, vals)
#print ("repeat", i, fn, single_op, list(vals))
fmt = "test_pipe_fp%d_%s_cornercases_%d"
runfp(dut, width, fmt % (width, name, i),
- fmod, fpfn, vals=vals, single_op=single_op)
+ fmod, fpfn, vals=vals, single_op=single_op, opcode=opcode)
def runfp(dut, width, name, fpkls, fpop, single_op=False, n_vals=10,
then be used to change the behaviour of the pipeline.
"""
- def __init__(self, width, num_rows, op_wid=1):
+ def __init__(self, width, num_rows, op_wid=2):
self.id_wid = num_bits(width)
self.pspec = PipelineSpec(width, self.id_wid, op_wid)
# get the standard mantissa width, store in the pspec HOWEVER...
from sfpy import Float64, Float32, Float16
from operator import truediv as div
-def test_pipe_fp16():
+def test_pipe_div_fp16():
dut = FPDIVMuxInOut(16, 4)
runfp(dut, 16, "test_fpdiv_pipe_fp16", Float16, div)
-def test_pipe_fp32():
+def test_pipe_div_fp32():
dut = FPDIVMuxInOut(32, 4)
runfp(dut, 32, "test_fpdiv_pipe_fp32", Float32, div)
-def test_pipe_fp64():
+def test_pipe_div_fp64():
dut = FPDIVMuxInOut(64, 4)
runfp(dut, 64, "test_fpdiv_pipe_fp64", Float64, div)
if __name__ == '__main__':
- test_pipe_fp16()
- test_pipe_fp32()
- test_pipe_fp64()
+ test_pipe_div_fp16()
+ test_pipe_div_fp32()
+ test_pipe_div_fp64()
--- /dev/null
+""" test of FPDIVMuxInOut
+"""
+
+from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
+from ieee754.fpcommon.test.fpmux import runfp
+
+from sfpy import Float64, Float32, Float16
+
+def sqrt(x):
+ return x.sqrt()
+
+def test_pipe_sqrt_fp16():
+ dut = FPDIVMuxInOut(16, 4)
+ runfp(dut, 16, "test_fpsqrt_pipe_fp16", Float16, sqrt,
+ single_op=True, opcode=1)
+
+def test_pipe_sqrt_fp32():
+ dut = FPDIVMuxInOut(32, 4)
+ runfp(dut, 32, "test_fpsqrt_pipe_fp32", Float32, sqrt,
+ single_op=True, opcode=1)
+
+def test_pipe_sqrt_fp64():
+ dut = FPDIVMuxInOut(64, 4)
+ runfp(dut, 64, "test_fpsqrt_pipe_fp64", Float64, sqrt,
+ single_op=True, opcode=1)
+
+if __name__ == '__main__':
+ test_pipe_sqrt_fp16()
+ test_pipe_sqrt_fp32()
+ test_pipe_sqrt_fp64()