Browse Source

initial and final values from mvarrays

devel
Stefan Holst 9 months ago
parent
commit
795cac0716
  1. 12
      src/kyupy/logic.py
  2. 4
      src/kyupy/logic_sim.py

12
src/kyupy/logic.py

@ -269,6 +269,18 @@ def mv_to_bp(mva):
return np.packbits(unpackbits(mva)[...,:3], axis=-2, bitorder='little').swapaxes(-1,-2) return np.packbits(unpackbits(mva)[...,:3], axis=-2, bitorder='little').swapaxes(-1,-2)
def mv_init(mva):
"""Returns the initial binary values for mva.
"""
return (mva>>1) & ((mva>>2)|mva) & 1
def mv_final(mva):
"""Returns the final binary value of mva.
"""
return mva & ((mva>>2)|(mva>>1)) & 1
def bparray(*a): def bparray(*a):
"""Converts (lists of) Boolean values or strings into a bit-parallel array. """Converts (lists of) Boolean values or strings into a bit-parallel array.

4
src/kyupy/logic_sim.py

@ -10,7 +10,7 @@ import math
import numpy as np import numpy as np
from . import numba, logic, hr_bytes, sim, eng from . import numba, logic, hr_bytes, sim, eng, cdiv
from .circuit import Circuit from .circuit import Circuit
class LogicSim(sim.SimOps): class LogicSim(sim.SimOps):
@ -28,7 +28,7 @@ class LogicSim(sim.SimOps):
self.m = m self.m = m
self.mdim = math.ceil(math.log2(m)) self.mdim = math.ceil(math.log2(m))
self.sims = sims self.sims = sims
nbytes = (sims - 1) // 8 + 1 nbytes = cdiv(sims, 8)
self.c = np.zeros((self.c_len, self.mdim, nbytes), dtype=np.uint8) self.c = np.zeros((self.c_len, self.mdim, nbytes), dtype=np.uint8)
self.s = np.zeros((2, self.s_len, 3, nbytes), dtype=np.uint8) self.s = np.zeros((2, self.s_len, 3, nbytes), dtype=np.uint8)

Loading…
Cancel
Save