|
|
|
@ -37,7 +37,7 @@ class Heap:
@@ -37,7 +37,7 @@ class Heap:
|
|
|
|
|
if self.chunks[loc] == size: |
|
|
|
|
del self.released[idx] |
|
|
|
|
return loc |
|
|
|
|
elif self.chunks[loc] > size: # split chunk |
|
|
|
|
if self.chunks[loc] > size: # split chunk |
|
|
|
|
chunksize = self.chunks[loc] |
|
|
|
|
self.chunks[loc] = size |
|
|
|
|
self.chunks[loc + size] = chunksize - size |
|
|
|
@ -103,7 +103,7 @@ class WaveSim:
@@ -103,7 +103,7 @@ class WaveSim:
|
|
|
|
|
|
|
|
|
|
self.cdata = np.zeros((len(self.interface), sims, 7), dtype='float32') |
|
|
|
|
|
|
|
|
|
if type(wavecaps) is int: |
|
|
|
|
if isinstance(wavecaps, int): |
|
|
|
|
wavecaps = [wavecaps] * len(circuit.lines) |
|
|
|
|
|
|
|
|
|
intf_wavecap = 4 # sufficient for storing only 1 transition. |
|
|
|
@ -117,7 +117,7 @@ class WaveSim:
@@ -117,7 +117,7 @@ class WaveSim:
|
|
|
|
|
|
|
|
|
|
# translate circuit structure into self.ops |
|
|
|
|
ops = [] |
|
|
|
|
interface_dict = dict([(n, i) for i, n in enumerate(self.interface)]) |
|
|
|
|
interface_dict = dict((n, i) for i, n in enumerate(self.interface)) |
|
|
|
|
for n in circuit.topological_order(): |
|
|
|
|
if n in interface_dict: |
|
|
|
|
inp_idx = self.ppi_offset + interface_dict[n] |
|
|
|
@ -255,8 +255,7 @@ class WaveSim:
@@ -255,8 +255,7 @@ class WaveSim:
|
|
|
|
|
def __repr__(self): |
|
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.cdata.nbytes |
|
|
|
|
return f'<WaveSim {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
|
f'levels={len(self.level_starts)} state_mem={hr_bytes(self.state.nbytes)} ' + \ |
|
|
|
|
f'total_mem={hr_bytes(total_mem)}>' |
|
|
|
|
f'levels={len(self.level_starts)} mem={hr_bytes(total_mem)}>' |
|
|
|
|
|
|
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
|
return self.timing[line, 0, polarity] |
|
|
|
@ -266,7 +265,7 @@ class WaveSim:
@@ -266,7 +265,7 @@ class WaveSim:
|
|
|
|
|
|
|
|
|
|
def assign(self, vectors, time=0.0, offset=0): |
|
|
|
|
nvectors = min(len(vectors) - offset, self.sims) |
|
|
|
|
for i, node in enumerate(self.interface): |
|
|
|
|
for i in range(len(self.interface)): |
|
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
|
if ppi_loc < 0: continue |
|
|
|
|
for p in range(nvectors): |
|
|
|
@ -321,7 +320,7 @@ class WaveSim:
@@ -321,7 +320,7 @@ class WaveSim:
|
|
|
|
|
return self.cdata |
|
|
|
|
|
|
|
|
|
def reassign(self, time=0.0): |
|
|
|
|
for i, node in enumerate(self.interface): |
|
|
|
|
for i in range(len(self.interface)): |
|
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
|
ppo_loc = self.sat[self.ppo_offset + i, 0] |
|
|
|
|
if ppi_loc < 0 or ppo_loc < 0: continue |
|
|
|
@ -386,8 +385,7 @@ class WaveSim:
@@ -386,8 +385,7 @@ class WaveSim:
|
|
|
|
|
accs[idx] += 1 |
|
|
|
|
if s_sqrt2 == 0: |
|
|
|
|
return values |
|
|
|
|
else: |
|
|
|
|
return accs |
|
|
|
|
return accs |
|
|
|
|
|
|
|
|
|
def vals(self, line, vector, times, sd=0): |
|
|
|
|
return self._vals(line, vector, times, sd) |
|
|
|
@ -464,7 +462,7 @@ def rand_gauss(seed, sd):
@@ -464,7 +462,7 @@ def rand_gauss(seed, sd):
|
|
|
|
|
return 1.0 |
|
|
|
|
while True: |
|
|
|
|
x = -6.0 |
|
|
|
|
for i in range(12): |
|
|
|
|
for _ in range(12): |
|
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
|
x *= sd |
|
|
|
@ -541,7 +539,7 @@ def wave_eval(op, state, sat, st_idx, line_times, sd=0.0, seed=0):
@@ -541,7 +539,7 @@ def wave_eval(op, state, sat, st_idx, line_times, sd=0.0, seed=0):
|
|
|
|
|
state[z_mem + z_cur, st_idx] = TMAX_OVL |
|
|
|
|
else: |
|
|
|
|
state[z_mem + z_cur, st_idx] = a if a > b else b # propagate overflow flags by storing biggest TMAX from input |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return overflows |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -565,8 +563,7 @@ class WaveSimCuda(WaveSim):
@@ -565,8 +563,7 @@ class WaveSimCuda(WaveSim):
|
|
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.timing.nbytes + \ |
|
|
|
|
self.tdata.nbytes + self.cdata.nbytes |
|
|
|
|
return f'<WaveSimCuda {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
|
f'levels={len(self.level_starts)} state_mem={hr_bytes(self.state.nbytes)} ' + \ |
|
|
|
|
f'total_mem={hr_bytes(total_mem)}>' |
|
|
|
|
f'levels={len(self.level_starts)} mem={hr_bytes(total_mem)}>' |
|
|
|
|
|
|
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
|
return self.d_timing[line, 0, polarity] |
|
|
|
@ -661,7 +658,7 @@ def reassign_kernel(state, sat, ppi_offset, ppo_offset, cdata, ppi_time):
@@ -661,7 +658,7 @@ def reassign_kernel(state, sat, ppi_offset, ppo_offset, cdata, ppi_time):
|
|
|
|
|
if vector >= state.shape[-1]: return |
|
|
|
|
if ppo_offset + y >= len(sat): return |
|
|
|
|
|
|
|
|
|
ppo, ppo_cap, _ = sat[ppo_offset + y] |
|
|
|
|
ppo, _, _ = sat[ppo_offset + y] |
|
|
|
|
ppi, ppi_cap, _ = sat[ppi_offset + y] |
|
|
|
|
if ppo < 0: return |
|
|
|
|
if ppi < 0: return |
|
|
|
@ -771,7 +768,7 @@ def rand_gauss_dev(seed, sd):
@@ -771,7 +768,7 @@ def rand_gauss_dev(seed, sd):
|
|
|
|
|
return 1.0 |
|
|
|
|
while True: |
|
|
|
|
x = -6.0 |
|
|
|
|
for i in range(12): |
|
|
|
|
for _ in range(12): |
|
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
|
x *= sd |
|
|
|
|