from nmigen.hdl.ast import Signal
+
class SimdScope:
"""The global scope object for SimdSignal and friends
##################
def Signal(self, shape=None, *, name=None, reset=0, reset_less=False,
- attrs=None, decoder=None, src_loc_at=0):
+ attrs=None, decoder=None, src_loc_at=0):
if self.scalar:
# scalar mode, just return a nmigen Signal. THIS IS IMPORTANT.
# when passing in SimdShape it should go "oh, this is
# SIMD mode. shape here can be either a SimdShape,
# a Shape, or anything else that Signal can take (int or
# a tuple (int,bool) for (width,sign)
- s = SimdSignal(mask=self, # should contain *all* context needed,
- # which goes all the way through to
- # the layout() function, passing
- # 1) elwid 2) vec_el_counts
- shape=shape, # should contain the *secondary*
+ s = SimdSignal(mask=self, # should contain *all* context needed,
+ # which goes all the way through to
+ # the layout() function, passing
+ # 1) elwid 2) vec_el_counts
+ shape=shape, # should contain the *secondary*
# part of the context needed for
# the layout() function:
# 3) lane_shapes 4) fixed_width
- name=name, reset=reset,
- reset_less=reset_less, attrs=attrs,
- decoder=decoder, src_loc_at=src_loc_at)
+ name=name, reset=reset,
+ reset_less=reset_less, attrs=attrs,
+ decoder=decoder, src_loc_at=src_loc_at)
# set the module context so that the SimdSignal can create
# its own submodules during AST creation
s.set_module(self.module)
return s
# XXX TODO
- def Signal_like(self): pass
- #if self.scalar:
- # scalar mode, just return nmigen Signal.like. THIS IS IMPORTANT.
+ def Signal_like(self):
+ # if self.scalar:
+ # scalar mode, just return nmigen Signal.like. THIS IS IMPORTANT.
# else
- # simd mode.
+ # simd mode.
+ pass
# XXX TODO
def Shape(self, width=1, signed=False):
# the names are preserved to ensure parameter-compatibility
# with Shape()
return SimdShape(self, width=width, # actually widths_at_elwid
- signed=signed,
- fixed_width=None)
+ signed=signed,
+ fixed_width=None)
return Simulator(module)
-
class TestCatMod(Elaboratable):
def __init__(self, width, elwid, vec_el_counts):
self.m = Module()
shape2 = SimdShape(s, fixed_width=width*2)
shape3 = SimdShape(s, fixed_width=width*3)
self.a = s.Signal(shape)
- self.b = s.Signal(shape2) # TODO: shape*2
- self.o = s.Signal(shape3) # TODO: shape*3
+ self.b = s.Signal(shape2) # TODO: shape*2
+ self.o = s.Signal(shape3) # TODO: shape*3
self.cat_out = self.o.sig
def elaborate(self, platform):
apart, bpart = [], []
ajump, bjump = alen // 4, blen // 4
for i in range(4):
- apart.append((a >> (ajump*i) & ((1<<ajump)-1)))
- bpart.append((b >> (bjump*i) & ((1<<bjump)-1)))
+ apart.append((a >> (ajump*i) & ((1 << ajump)-1)))
+ bpart.append((b >> (bjump*i) & ((1 << bjump)-1)))
- print ("apart bpart", hex(a), hex(b),
- list(map(hex, apart)), list(map(hex, bpart)))
+ print("apart bpart", hex(a), hex(b),
+ list(map(hex, apart)), list(map(hex, bpart)))
yield module.a.lower().eq(a)
yield module.b.lower().eq(b)
for i in runlengths:
# a first
for _ in range(i):
- print ("runlength", i,
- "ai", ai,
- "apart", hex(apart[ai]),
- "j", j)
+ print("runlength", i,
+ "ai", ai,
+ "apart", hex(apart[ai]),
+ "j", j)
y |= apart[ai] << j
- print (" y", hex(y))
+ print(" y", hex(y))
j += ajump
ai += 1
# now b
for _ in range(i):
- print ("runlength", i,
- "bi", bi,
- "bpart", hex(bpart[bi]),
- "j", j)
+ print("runlength", i,
+ "bi", bi,
+ "bpart", hex(bpart[bi]),
+ "j", j)
y |= bpart[bi] << j
- print (" y", hex(y))
+ print(" y", hex(y))
j += bjump
bi += 1