Array of constants and code generation

Thomas Heller <[email protected]>
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
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>


------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.