This commit is contained in:
parent
4c26e9f978
commit
aa81b3ea0b
6 changed files with 301244 additions and 0 deletions
BIN
float/floatp.txt
Normal file
BIN
float/floatp.txt
Normal file
Binary file not shown.
170000
float/fltp_tests.txt
Normal file
170000
float/fltp_tests.txt
Normal file
File diff suppressed because it is too large
Load diff
65536
float/half_precision_values.txt
Normal file
65536
float/half_precision_values.txt
Normal file
File diff suppressed because it is too large
Load diff
114
float/tests.tsv
Normal file
114
float/tests.tsv
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
// ТЕСТЫ FixedPoint
|
||||||
|
//тесты из условия:
|
||||||
|
16.12 0 0x17360,23.210
|
||||||
|
8.8 1 0xdc9f + 0xd736,-76.168
|
||||||
|
|
||||||
|
//оффициальные тесты (github):
|
||||||
|
16.12 0 0x17360,23.210
|
||||||
|
16.16 1 0x173600,23.211
|
||||||
|
8.8 2 0x9c9f,-99.378
|
||||||
|
8.8 3 0x9c9f,-99.379
|
||||||
|
8.8 0 0x9c9f + 0x1736,-76.167
|
||||||
|
8.8 1 0xdc9f + 0xd736,-76.168
|
||||||
|
16.16 2 0x6f7600 + 0x173600,134.672
|
||||||
|
16.16 3 0x6f7600 + 0x173600,134.671
|
||||||
|
|
||||||
|
//Тесты на округление и вывод:
|
||||||
|
13.7 1 0x7ffff,4095.992
|
||||||
|
13.7 2 0x7ffff,4095.993
|
||||||
|
13.7 1 0xfffff,-0.008
|
||||||
|
13.7 2 0xfffff,-0.007
|
||||||
|
1.12 0 0x51,0.019
|
||||||
|
1.12 1 0x51,0.020
|
||||||
|
1.12 2 0x1051,-0.980
|
||||||
|
1.12 3 0x1051,-0.981
|
||||||
|
1.0 0 0x1,-1.000
|
||||||
|
2.0 0 0x1,1.000
|
||||||
|
12.0 0 0x539,1337.000
|
||||||
|
31.0 0 0x539,1337.000
|
||||||
|
1.27 2 0x8000001,-0.999
|
||||||
|
1.27 3 0x8000001,-1.000
|
||||||
|
4.16 3 0x2ffff,2.999
|
||||||
|
4.16 2 0x2ffff,3.000
|
||||||
|
4.16 0 0xeffff,-1.000
|
||||||
|
4.16 2 0xeffff,-1.000
|
||||||
|
4.16 3 0xeffff,-1.001
|
||||||
|
3.1 0 0xb,-2.500
|
||||||
|
3.1 1 0xb,-2.500
|
||||||
|
3.1 2 0xb,-2.500
|
||||||
|
3.1 3 0xb,-2.500
|
||||||
|
3.1 0 0x3,1.500
|
||||||
|
3.1 1 0x3,1.500
|
||||||
|
3.1 2 0x3,1.500
|
||||||
|
3.1 3 0x3,1.500
|
||||||
|
|
||||||
|
//Тесты на сложение (крайние случаи)
|
||||||
|
16.0 0 0x7b + 0xe4,351.000
|
||||||
|
1.16 0 0x172a + 0x2ad5,0.257
|
||||||
|
1.16 1 0x172a + 0x2ad5,0.258
|
||||||
|
1.16 2 0x172a + 0x2ad5,0.258
|
||||||
|
1.16 3 0x172a + 0x2ad5,0.257
|
||||||
|
1.0 0 0x1 + 0x0,-1.000
|
||||||
|
1.0 0 0x1 + 0x1,0.000
|
||||||
|
8.24 0 0x623db143 + 0x7434c23e,-41.552
|
||||||
|
|
||||||
|
//Тесты на вычитание
|
||||||
|
16.16 0 0x7b8ba0 - 0x6fc540,11.774
|
||||||
|
16.16 1 0x7b8ba0 - 0x6fc540,11.775
|
||||||
|
16.16 0 0x9ae8dfc - 0xc0000,2466.554
|
||||||
|
16.16 0 0x80060000 - 0x80190000,-19.000
|
||||||
|
3.4 0 0x50 - 0x10,-4.000
|
||||||
|
|
||||||
|
//Тесты на умножение
|
||||||
|
16.4 0 0x64 x 0x64,39.062
|
||||||
|
16.4 1 0x64 x 0x64,39.062
|
||||||
|
16.4 2 0x64 x 0x64,39.063
|
||||||
|
16.4 3 0x64 x 0x64,39.062
|
||||||
|
16.4 0 0x640 x 0x640,10000.000
|
||||||
|
16.4 0 0x68 x 0x28,16.250
|
||||||
|
8.1 0 0x7 x 0xb,19.000
|
||||||
|
8.1 1 0x7 x 0xb,19.000
|
||||||
|
8.1 3 0x7 x 0xb,19.000
|
||||||
|
8.1 2 0x7 x 0xb,19.500
|
||||||
|
|
||||||
|
//Тесты на деление
|
||||||
|
16.4 0 0x64 / 0x64,1.000
|
||||||
|
16.4 0 0x64 / 0x0,division by zero
|
||||||
|
16.8 0 0x6400 / 0x80,200.000
|
||||||
|
16.8 0 0x6400 / 0x400,25.000
|
||||||
|
16.8 0 0x6400 / 0x800,12.500
|
||||||
|
16.8 0 0x6400 / 0x1000,6.250
|
||||||
|
16.8 0 0x6400 / 0x300,33.332
|
||||||
|
16.8 1 0x6400 / 0x300,33.332
|
||||||
|
16.8 2 0x6400 / 0x300,33.336
|
||||||
|
16.8 3 0x6400 / 0x300,33.332
|
||||||
|
16.4 0 0x867ca x 0x00145a,28741.062
|
||||||
|
|
||||||
|
//ТЕСТЫ FixedPoint
|
||||||
|
f 0 0xB9CD542,0x1.39aa84p-104
|
||||||
|
f 1 0x3,0x1.800000p-148
|
||||||
|
f 0 0x00000023,0x1.180000p-144
|
||||||
|
f 0 0x414587dd x 0x42ebf110,0x1.6c1b72p+10
|
||||||
|
f 1 0x414587dd x 0x42ebf110,0x1.6c1b72p+10
|
||||||
|
f 2 0x414587dd x 0x42ebf110,0x1.6c1b74p+10
|
||||||
|
f 3 0x414587dd x 0x42ebf110,0x1.6c1b72p+10
|
||||||
|
f 0 0x414587dd + 0x42ebf110,0x1.04a20ap+7
|
||||||
|
f 1 0x414587dd + 0x42ebf110,0x1.04a20cp+7
|
||||||
|
f 2 0x414587dd + 0x42ebf110,0x1.04a20cp+7
|
||||||
|
f 3 0x414587dd + 0x42ebf110,0x1.04a20ap+7
|
||||||
|
h 0 0x4145 x 0x42eb,0x1.238p+3
|
||||||
|
h 1 0x4145 x 0x42eb,0x1.23cp+3
|
||||||
|
h 2 0x4145 x 0x42eb,0x1.23cp+3
|
||||||
|
h 3 0x4145 x 0x42eb,0x1.238p+3
|
||||||
|
h 0 0x8000 + 0x0,0x0.000p+0
|
||||||
|
h 0 0x8000 + 0x0,0x0.000p+0
|
||||||
|
f 0 0x0,0x0.000000p+0
|
||||||
|
f 0 0x7f800000,inf
|
||||||
|
f 0 0xff800000,-inf
|
||||||
|
f 0 0x7fc00000,nan
|
||||||
|
f 0 0x1 / 0x0,inf
|
||||||
|
f 0 0xff800000 / 0x7f800000,nan
|
||||||
|
|
||||||
|
,f 0 0x7F3CE508 / 0x003CE508,inf
|
||||||
|
,f 0 0x7F3CE508 / 0xD2A07070,-0x1.2d6770p+89
|
||||||
|
,f 0 0x00011C75 / 0x0061CFDA,0x1.744008p-7
|
||||||
|
57
sqrt/test.py
Normal file
57
sqrt/test.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
MAX_FAILED = 1
|
||||||
|
START_TEST = 0
|
||||||
|
|
||||||
|
TEMPFILE = subprocess.run("mktemp -u".split(), stdout=subprocess.PIPE).stdout.decode().strip() # use linux :)
|
||||||
|
FILL_SIZE = os.get_terminal_size().columns
|
||||||
|
filled = lambda x: f"{x}{' ' * (FILL_SIZE - len(x.replace('\r', '').replace('\n', '')))}"
|
||||||
|
|
||||||
|
with open("tests.csv") as f:
|
||||||
|
tests = [[y for y in x.split(',')] for x in f.read().strip().split('\n')[1:]][START_TEST:]
|
||||||
|
|
||||||
|
print('Compiling...', end='')
|
||||||
|
ps = subprocess.run(f'iverilog -g2012 -o {TEMPFILE} ./sqrt2_tb.sv'.split(), stderr=subprocess.PIPE)
|
||||||
|
exit_code = ps.returncode
|
||||||
|
output = ps.stderr.decode().strip()
|
||||||
|
|
||||||
|
if exit_code != 0:
|
||||||
|
print('\r!COMPILATION FAILED!')
|
||||||
|
print(output, file=sys.stderr)
|
||||||
|
exit(exit_code)
|
||||||
|
elif output:
|
||||||
|
print("\rCompiled with warnings")
|
||||||
|
print(output)
|
||||||
|
else:
|
||||||
|
print("\rCompiled successfully")
|
||||||
|
|
||||||
|
good = bad = 0
|
||||||
|
for i, test in enumerate(tests):
|
||||||
|
try:
|
||||||
|
ps = subprocess.run([TEMPFILE, '+' + test[0]], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=.1)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
out = 'TIMEOUT'
|
||||||
|
else:
|
||||||
|
out = ps.stdout.decode().strip().split('\n')[0]
|
||||||
|
|
||||||
|
cmp = ' '.join(test[1:])
|
||||||
|
if out != cmp:
|
||||||
|
bad += 1
|
||||||
|
print('\n'.join((
|
||||||
|
filled(f'\rTEST #{i + 1 + START_TEST}' + (' (TIMEOUT)' if out == 'TIMEOUT' else '')),
|
||||||
|
filled(f'INPUT: {test[0]}'),
|
||||||
|
filled(f'OUTPUT: {out}'),
|
||||||
|
filled(f'EXPECTED: {cmp}'),
|
||||||
|
)), end='\n\n')
|
||||||
|
else:
|
||||||
|
good += 1
|
||||||
|
|
||||||
|
print(filled(f'\rGOOD: {good}, BAD: {bad}, TOTAL: {len(tests)}'), end='')
|
||||||
|
|
||||||
|
if MAX_FAILED and bad >= MAX_FAILED:
|
||||||
|
print("\nToo many failed tests. Aborting.")
|
||||||
|
exit(1)
|
||||||
|
print()
|
||||||
65537
sqrt/tests.csv
Normal file
65537
sqrt/tests.csv
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue