mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
sim: make initialization cycle optional (selectable by function attribute)
This commit is contained in:
parent
8160ced2e9
commit
98e96b3952
3 changed files with 7 additions and 6 deletions
|
@ -13,6 +13,7 @@ class Counter:
|
||||||
else:
|
else:
|
||||||
s.wr(self.ce, 1)
|
s.wr(self.ce, 1)
|
||||||
print("Cycle: " + str(s.cycle_counter) + " Count: " + str(s.rd(self.count)))
|
print("Cycle: " + str(s.cycle_counter) + " Count: " + str(s.rd(self.count)))
|
||||||
|
do_simulation.initialize = True
|
||||||
|
|
||||||
def get_fragment(self):
|
def get_fragment(self):
|
||||||
sync = [If(self.ce, self.count.eq(self.count + 1))]
|
sync = [If(self.ce, self.count.eq(self.count + 1))]
|
||||||
|
|
|
@ -10,7 +10,6 @@ class Mem:
|
||||||
self.mem = Memory(16, 2**12, p, init=list(range(20)))
|
self.mem = Memory(16, 2**12, p, init=list(range(20)))
|
||||||
|
|
||||||
def do_simulation(self, s):
|
def do_simulation(self, s):
|
||||||
if s.cycle_counter >= 0:
|
|
||||||
value = s.rd(self.mem, s.cycle_counter)
|
value = s.rd(self.mem, s.cycle_counter)
|
||||||
print(value)
|
print(value)
|
||||||
if value == 10:
|
if value == 10:
|
||||||
|
|
|
@ -278,4 +278,5 @@ class Fragment:
|
||||||
|
|
||||||
def call_sim(self, simulator):
|
def call_sim(self, simulator):
|
||||||
for s in self.sim:
|
for s in self.sim:
|
||||||
|
if simulator.cycle_counter >= 0 or (hasattr(s, "initialize") and s.initialize):
|
||||||
s(simulator)
|
s(simulator)
|
||||||
|
|
Loading…
Reference in a new issue