Skip to content

Instantly share code, notes, and snippets.

@cfelton
Last active January 26, 2016 15:11
Show Gist options
  • Save cfelton/3b61802c7b15b130f1d7 to your computer and use it in GitHub Desktop.
Save cfelton/3b61802c7b15b130f1d7 to your computer and use it in GitHub Desktop.
@always_seq(clock.posedge, reset=reset)
def beh_sop():
# tap update loop
xd[0].next = x
for ii in range(1, len(h)):
xd[ii].next = xd[ii-1]
# sum-of-products loop
sop = 0
for ii in range(len(h)):
c = h[ii]
sop = sop + (c * xd[ii])
# scale the sum of products to the
# output range (truncate)
y.next = sop >> scale
def taps(x, N):
return [x] if N <= 1 else [x] + taps(Reg(x), N-1)
w1 = sum([x*h for x, h in zip(taps(Reg(x), len(hs)), hs)])
w2 = w1 >> len(x)/2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment