mirror of
https://github.com/supleed2/cordic.git
synced 2024-12-22 05:35:51 +00:00
Update testbench for clocked saw2sin.sv
This commit is contained in:
parent
36b8ed998e
commit
00d35d90b2
|
@ -1,4 +1,5 @@
|
||||||
import cocotb
|
import cocotb
|
||||||
|
from cocotb.clock import Clock
|
||||||
from cocotb.triggers import Timer
|
from cocotb.triggers import Timer
|
||||||
from math import sin, cos, pi
|
from math import sin, cos, pi
|
||||||
|
|
||||||
|
@ -6,10 +7,11 @@ from math import sin, cos, pi
|
||||||
async def test_new_cordic(dut):
|
async def test_new_cordic(dut):
|
||||||
"""Test that cordic matches sin"""
|
"""Test that cordic matches sin"""
|
||||||
|
|
||||||
|
await cocotb.start(Clock(dut.i_clk, 10, units='ps').start())
|
||||||
diff = 0
|
diff = 0
|
||||||
for cycle in range(0, 65536):
|
for cycle in range(0, 65536):
|
||||||
dut.i_saw.value = cycle
|
dut.i_saw.value = cycle
|
||||||
await Timer(1, units='ps')
|
await Timer(20, units='ps')
|
||||||
e_sin = 32768 * (sin((cycle * pi) / (2**15)) + 1)
|
e_sin = 32768 * (sin((cycle * pi) / (2**15)) + 1)
|
||||||
error = float(dut.o_sin.value) - e_sin
|
error = float(dut.o_sin.value) - e_sin
|
||||||
if abs(error) > 2:
|
if abs(error) > 2:
|
||||||
|
|
Loading…
Reference in a new issue