[myhdl-list] Beginner Question: Loop Unrolling & Use of Tuple Elements
Brought to you by:
jandecaluwe
From: <co...@ne...> - 2015-06-28 19:02:13
|
Hello, I was attempting to make a simple FIR filter to compare MyHDL to previous work I'd done using Vivado C-based HLS. I'm basing this entirely on Christopher Felton's IIR example from https://bitbucket.org/cfelton/examples/src/tip/siir/siir.py . Two things have tripped me up, and I'm not sure if it's some limitation of MyHDL or my own failures? The first is as part of the FIR I'd like to have a line like this: @always(clk.posedge) def rtl_fir(): for i in range(0, len(B-1)): ffd[i+1].next = ffd[i] ffd[i].next = x But I can't seem to find references to loop unrolling anywhere? There was a few threads from ~2008 was all I saw. Instead I end up having to do something like this: @always(clk.posedge) def rtl_fir(): ffd[4].next = ffd[3] ffd[3].next = ffd[2] ffd[2].next = ffd[1] ffd[1].next = ffd[0] ffd[0].next = x Which I could have another chunk of python auto-generate, but seems silly. Is there some loop unrolling mechanism I'm missing? The second problem is for the accumulator (which again I'm manually unrolling), the most straight-forward definition to me would look like this: @always_comb def rtl_acc(): # Double precision accumulator yacc.next = B[0]*ffd[0] + B[1]*ffd[1] + B[2]*ffd[2] + B[3]*ffd[3] + B[4]*ffd[4] As get an error about use of tuples. Instead I've got to assign each element (which is an int() type) to another variable and use that: b0 = B[0] b1 = B[1] b2 = B[2] b3 = B[3] b4 = B[4] @always_comb def rtl_acc(): # Double precision accumulator yacc.next = b0*ffd[0] + b1*ffd[1] + b2*ffd[2] + b3*ffd[3] + b4*ffd[4] The full code is at http://pastebin.com/E2i16whb (which again is just a hacked version of Christopher's code that does FIR instead, I didn't finish changing some of the names). Is this something I'm doing incorrectly which stops me from using MyHDL in such a manner? Thanks, -Colin O'Flynn |