Skip to content

Instantly share code, notes, and snippets.

@cfelton
Last active January 26, 2016 15:11
Show Gist options
  • Select an option

  • Save cfelton/3b61802c7b15b130f1d7 to your computer and use it in GitHub Desktop.

Select an option

Save cfelton/3b61802c7b15b130f1d7 to your computer and use it in GitHub Desktop.

Revisions

  1. cfelton revised this gist Jan 26, 2016. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions fpga631_snip1.py
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    @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])
    @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
    # scale the sum of products to the
    # output range (truncate)
    y.next = sop >> scale
  2. cfelton revised this gist Jan 26, 2016. No changes.
  3. cfelton revised this gist Jan 26, 2016. No changes.
  4. cfelton created this gist Jan 26, 2016.
    16 changes: 16 additions & 0 deletions fpga631_snip1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    @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
    5 changes: 5 additions & 0 deletions fpga631_snip2.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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