2019-06-24 04:04:55 -04:00
|
|
|
# This file is Copyright (c) 2017 Florent Kermarrec <florent@enjoy-digital.fr>
|
|
|
|
# License: BSD
|
|
|
|
|
2017-01-18 22:58:04 -05:00
|
|
|
import unittest
|
2017-01-18 23:30:25 -05:00
|
|
|
import os
|
|
|
|
from math import cos, sin
|
2017-01-18 22:58:04 -05:00
|
|
|
|
|
|
|
from litescope.software.dump import *
|
|
|
|
|
2017-01-18 23:30:25 -05:00
|
|
|
#TODO:
|
|
|
|
# - find a way to check if files are generated corectly
|
|
|
|
|
|
|
|
dump = Dump()
|
|
|
|
for i in range(4):
|
|
|
|
dump.add(DumpVariable("ramp"+str(i), 2**i, [j for j in range(256)]))
|
|
|
|
pi = 3.1415
|
|
|
|
dump.add(DumpVariable("sin", 8, [128+128*sin(j/(2*pi*16)) for j in range(1024)]))
|
|
|
|
dump.add(DumpVariable("cos", 8, [128+128*cos(j/(2*pi*16)) for j in range(1024)]))
|
|
|
|
|
|
|
|
|
2017-01-18 22:58:04 -05:00
|
|
|
class TestDump(unittest.TestCase):
|
2017-01-18 23:30:25 -05:00
|
|
|
def test_csv(self):
|
|
|
|
filename = "dump.csv"
|
|
|
|
CSVDump(dump).write(filename)
|
|
|
|
os.remove(filename)
|
|
|
|
|
|
|
|
def test_py(self):
|
|
|
|
filename = "dump.py"
|
|
|
|
PythonDump(dump).write(filename)
|
|
|
|
os.remove(filename)
|
|
|
|
|
|
|
|
def test_sigrok(self):
|
|
|
|
filename = "dump.sr"
|
|
|
|
SigrokDump(dump).write(filename)
|
|
|
|
SigrokDump(dump).read(filename)
|
|
|
|
SigrokDump(dump).write(filename)
|
|
|
|
os.remove(filename)
|
|
|
|
|
|
|
|
def test_vcd(self):
|
|
|
|
filename = "dump.vcd"
|
|
|
|
VCDDump(dump).write(filename)
|
|
|
|
os.remove(filename)
|