[myhdl-list] Array of constants and code generation
Brought to you by:
jandecaluwe
From: Thomas H. <th...@ct...> - 2015-06-02 07:03:40
|
I'm trying to implement a cordic module to calculate the phase of a vector with rectangular coordinates x and y. The cordic is a full parallel pipelined architecture; the vector rotations are generated in a loop. The angles are precalculated as integers in a list. The code simulates perfectly; but code generation with toVHDL or toVerilog fails with this error: ConversionError: in file C:\Users\thomas\devel\mytss5\dist\components\_Pythonlib\pmc4\hardware\ip\cordic.py, line 40: Object type is not supported in this context: angles, <type 'list'> I tried a tuple instead of a list but conversion failed as well. How can I rewrite the code for conversion? Thanks, Thomas <code> SCALE = 2000 N = 10 def Cordic(clk, x, y, phase): xi = [hdl_util.signed(13) for _ in range(N)] yi = [hdl_util.signed(13) for _ in range(N)] zi = [hdl_util.signed(12) for _ in range(N)] angles = [int(round(math.atan(2**-i) * SCALE / 2 / math.pi)) for i in range(N)] @myhdl.always(clk.posedge) def doit(): if x < 0: xi[0].next = -x yi[0].next = -y zi[0].next = SCALE // 4 * 3 else: xi[0].next = x yi[0].next = y zi[0].next = SCALE // 4 for i in range(9): if yi[i] < 0: xi[i+1].next = xi[i] - (yi[i] >> i) yi[i+1].next = yi[i] + (xi[i] >> i) zi[i+1].next = zi[i] + angles[i] else: xi[i+1].next = xi[i] + (yi[i] >> i) yi[i+1].next = yi[i] - (xi[i] >> i) zi[i+1].next = zi[i] - angles[i] print(xi[-1], yi[-1], zi[-1]) phase.next = zi[-1] return myhdl.instances() </code> |