fix pulse threshold selection
This commit is contained in:
1 parent
8096416b0e
commit
967a232b1c
2 files changed
+36
-4
No files matched your search
@@ -5,6 +5,38 @@ from kyupy.logic_sim import LogicSim
|
||||
from kyupy import logic, bench, sim
|
||||
from kyupy.logic import mvarray
|
||||
|
||||
def test_xnor2_delays():
|
||||
op = (sim.XNOR2, 2, 0, 1, 3, 3, -1, 0, 0)
|
||||
#op = (0b0111, 4, 0, 1)
|
||||
c = np.full((4*16, 1), TMAX) # 4 waveforms of capacity 16
|
||||
c_locs = np.zeros((4,), dtype='int')
|
||||
c_caps = np.zeros((4,), dtype='int')
|
||||
|
||||
for i in range(4): c_locs[i], c_caps[i] = i*16, 16 # 1:1 mapping
|
||||
delays = np.zeros((1, 4, 2, 2))
|
||||
delays[0, 0, 0, 0] = 0.031 # A rise -> Z rise
|
||||
delays[0, 0, 0, 1] = 0.027 # A rise -> Z fall
|
||||
delays[0, 0, 1, 0] = 0.033 # A fall -> Z rise
|
||||
delays[0, 0, 1, 1] = 0.037 # A fall -> Z fall
|
||||
delays[0, 1, 0, 0] = 0.032 # B rise -> Z rise
|
||||
delays[0, 1, 0, 1] = 0.030 # B rise -> Z fall
|
||||
delays[0, 1, 1, 0] = 0.038 # B fall -> Z rise
|
||||
delays[0, 1, 1, 1] = 0.036 # B fall -> Z fall
|
||||
|
||||
simctl_int = np.asarray([0], dtype=np.int32)
|
||||
|
||||
def wave_assert(inputs, output):
|
||||
for i, a in zip(inputs, c.reshape(-1,16)): a[:len(i)] = i
|
||||
wave_eval_cpu(op, c, c_locs, c_caps, 0, delays, simctl_int)
|
||||
for i, v in enumerate(output): np.testing.assert_allclose(c.reshape(-1,16)[2,i], v)
|
||||
|
||||
wave_assert([[TMIN,TMAX],[TMIN,TMAX]], [TMIN,TMAX]) # XNOR(1,1) => 1
|
||||
wave_assert([[TMAX,TMAX],[TMIN,TMAX]], [TMAX]) # XNOR(0,1) => 0
|
||||
# using Afall/Zfall for pulse length, bug: was using Arise/Zfall
|
||||
#wave_assert([[0.07, 0.10, TMAX], [0.0, TMAX]], [TMIN, 0.03, 0.101, 0.137, TMAX])
|
||||
wave_assert([[0.07, 0.10, TMAX], [0.0, TMAX]], [TMIN, 0.03, TMAX])
|
||||
wave_assert([[0.06, 0.10, TMAX], [0.0, TMAX]], [TMIN, 0.03, 0.091, 0.137, TMAX])
|
||||
|
||||
def test_nand_delays():
|
||||
op = (sim.NAND4, 4, 0, 1, 2, 3, -1, 0, 0)
|
||||
#op = (0b0111, 4, 0, 1)
|
||||
|
||||
Reference in new issue
Block a user