You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I want to use generators to build a simulation model of some module. In migen, this wasn't possible for modules that implement combinatorial logic.
Trying my hand at nmigen syntax, an example could be something like this:
classRoutingPolicy:
def__init__(self, width, n):
self.data=Signal(width)
self.destination=Signal(max=n)
# I haven't decided yet what I want this module to do, let's try some optionsdefgen_destination(self):
whileTrue: # or something?data= (yieldself.data)
if (data==23):
yieldself.destination.eq(0)
else:
yieldself.destination.eq(self.data[:log2_int(n)])
classRouter:
def__init__(self, width, n):
self.in_port=Signal(width)
self.out_ports=Array(Signal(width) for_inrange(n))
self.policy=RoutingPolicy(width, n)
defget_fragment(self, platform):
m=Module()
m.submodules.policy=self.policym.d.comb+= [
self.policy.data.eq(self.in_port),
self.out_ports[self.policy.destination].eq(self.in_port)
]
returnm.lower(platform)
m=Router(8, 2)
run_simulation(m, m.policy.gen_destination())
There probably needs to be something to tell what constitutes one iteration of the generator, with while True it would just run indefinitely. while (yield input_values_changed()): ? Also the whole thing would need to be @passive or so since there's no predefined end point.
Another question is whether it's possible, or even makes sense, to mix combinatorial assignments and synchronous assignments in one generator.
The text was updated successfully, but these errors were encountered:
Issue by nakengelhardt
Tuesday Dec 18, 2018 at 05:24 GMT
Originally opened as m-labs/nmigen#11
Sometimes I want to use generators to build a simulation model of some module. In migen, this wasn't possible for modules that implement combinatorial logic.
Trying my hand at nmigen syntax, an example could be something like this:
There probably needs to be something to tell what constitutes one iteration of the generator, with
while True
it would just run indefinitely.while (yield input_values_changed()):
? Also the whole thing would need to be@passive
or so since there's no predefined end point.Another question is whether it's possible, or even makes sense, to mix combinatorial assignments and synchronous assignments in one generator.
The text was updated successfully, but these errors were encountered: