Circular rotation mode of operation:
Using an iterative algorithm, transform a vector x0,y0 to a resulting vector xN,yN using N iterations
Our goal is to compute a final x,y using n iterations
xn=x0cos(θ)−y0sin(θ)
yn=y0cos(θ)+x0sin(θ)
Simplifying:
Factor cos(θ):
xn=cos(θ)(x0−y0tan(θ))
yn=cos(θ)(y0+x0tan(θ))
We'll address the two muliplications of each equation to simplify them
we are going to restrict allowable rotations θ such that tan(θ)=±2−i so that the multiplication can be replaced by a shift and add/sub. We'll predetermine allowable rotations and store them in a table:
| i | tan(θ)=±2−i | tan−1(2−i)=θi | 2πθi | degrees |
|---|---|---|---|---|
| 0 | ±2−0 | ±tan−1(1)=±0.7853981633974483 | ±0.125=1/8th turn | ±45.0 |
| 1 | ±2−1 | ±tan−1(1/2)=±0.4636476090008061 | ±0.07379180882521663 | ±26.565051177077986 |
| 2 | ±2−2 | ±tan−1(1/4)=±0.24497866312686414 | ±0.03898956518868466 | ±14.036243467926479 |
| 3 | ±2−3 | ±tan−1(1/8)=±0.12435499454676144 | ±0.019791712080282773 | ±7.125016348901799 |
| 4 | ±2−4 | ±tan−1(1/16)=±0.06241880999595735 | ±0.00993426215277042 | ±3.5763343749973515 |
| 5 | ±2−5 | ±tan−1(1/32)=±0.031239833430268277 | ±0.004971973911794637 | ±1.7899106082460694 |
| 6 | ±2−6 | ±tan−1(1/64)=±0.015623728620476831 | ±0.0024865936394752068 | ±0.8951737102110744 |
| 7 | ±2−7 | ±tan−1(1/128)=±0.007812341060101111 | ±0.0012433726968348697 | ±0.4476141708605531 |
| 8 | ±2−8 | ±tan−1(1/256)=±0.0039062301319669718 | ±0.0006216958343570503 | ±0.22381050036853808 |
| 9 | ±2−9 | ±tan−1(1/512)=±0.0019531225164788188 | ±0.0003108491029616858 | ±0.1119056770662069 |
| 10 | ±2−10 | ±tan−1(1/1024)=±0.0009765621895593195 | ±0.0001554246997050102 | ±0.05595289189380367 |
| ... |
To achieve other angles not in the restricted set, we can allow a combination of multiple rotations from any of the allowable angles.
The series of rotations can be first calculated using an iterative process with an angle accumulator R as follows
Initialize R to θ
In each iteration i, we will rotate by θi or −θi according to R: R=R−riθi; ri={1,−1,R≥0otherwise
We'll solve this later with an intialization step
Iteration:
Note:
cos(±θi)=+cos(θi) ; tan(±θi)=±tan(θi)
therefore
We can pre-calculate each cos as (Ki) and use the fact that tan(θi)=2i
Ki=cos(tan−1(2−i))=1+2−2i1
Xi+1=Ki[Xi−riYi2−i]=Ki[Xi−ri(Yi<<i)]
Yi+1=Ki[Yi−riXi2−i]=Ki[Yi−ri(Xi<<i)]
Introduce initial rotation to reduce |R| to be less than 42π
Speed an Pipelining
single hardware iteration stage
pipeling allows throughput to "match" system clock rate (still have latency)
initialize system with X=A, Y=0, θ
initialize a pipeline implemention at each time t: X=A(t); Y=0; θ(t)=fclockF×2π×t
IF mapping the full binary range of n bits to the range of angles around the circle,