Last active
January 26, 2016 15:11
-
-
Save cfelton/3b61802c7b15b130f1d7 to your computer and use it in GitHub Desktop.
code snippets for http://www.fpgarelated.com/showarticle/631.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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