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:
|
||||
s.wr(self.ce, 1)
|
||||
print("Cycle: " + str(s.cycle_counter) + " Count: " + str(s.rd(self.count)))
|
||||
do_simulation.initialize = True
|
||||
|
||||
def get_fragment(self):
|
||||
sync = [If(self.ce, self.count.eq(self.count + 1))]
|
||||
|
|
|
@ -10,11 +10,10 @@ class Mem:
|
|||
self.mem = Memory(16, 2**12, p, init=list(range(20)))
|
||||
|
||||
def do_simulation(self, s):
|
||||
if s.cycle_counter >= 0:
|
||||
value = s.rd(self.mem, s.cycle_counter)
|
||||
print(value)
|
||||
if value == 10:
|
||||
s.interrupt = True
|
||||
value = s.rd(self.mem, s.cycle_counter)
|
||||
print(value)
|
||||
if value == 10:
|
||||
s.interrupt = True
|
||||
|
||||
def get_fragment(self):
|
||||
return Fragment(memories=[self.mem], sim=[self.do_simulation])
|
||||
|
|
|
@ -278,4 +278,5 @@ class Fragment:
|
|||
|
||||
def call_sim(self, simulator):
|
||||
for s in self.sim:
|
||||
s(simulator)
|
||||
if simulator.cycle_counter >= 0 or (hasattr(s, "initialize") and s.initialize):
|
||||
s(simulator)
|
||||
|
|
Loading…
Reference in a new issue