block diagram

Block Diagram i=1 i=2 i=3 i=4 0.463648 0.244979 0.124355 - PowerPoint PPT Presentation

Block Diagram i=1 i=2 i=3 i=4 0.463648 0.244979 0.124355 0.062419 + or - + or - + or - + or - > > > > + or - + or - + or - + or - 2 i 2 i 2 i 2 i 1 1 1 1 2 1 2 1 2


  1. Block Diagram i=1 i=2 i=3 i=4 0.463648 0.244979 0.124355 0.062419 + or - + or - + or - + or - > > > > + or - + or - + or - + or - −2 −i −2 −i −2 −i −2 −i 1 1 1 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1

  2. wire signed [15:0] angles [15:0]; Number Formats assign angles[0] = 16’h2000; assign angles[1] = 16’h12E4; >> dec2hex(round(atan(2.^(-(0:15)))*(2^16)/(2*pi))) assign angles[2] = 16’h09FB; ... i=0 '2000' >> atan(2.^(-(0:20))) i=1 i=2 i=3 i=4 '12E4' 0.463648 0.244979 0.124355 0.062419 '09FB' '0511' i=0 0.785398163397448 '028B' 0.463647609000806 '0146' 0.244978663126864 '00A3' + or - + or - + or - + or - 0.124354994546761 '0051' 0.062418809995957 '0029' > > > > 0.031239833430268 '0014' 0.015623728620477 '000A' 0.007812341060101 '0005' 0.003906230131967 '0003' + or - + or - + or - + or - 0.001953122516479 '0001' 0.000976562189559 '0001' −2 −i −2 −i −2 −i −2 −i 1 1 1 1 0.000488281211195 i =15 '0000‘ 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 0.000244140620149 0.000122070311894 0.000061035156174 0.000030517578116 0.000015258789061 >> %initial scaling factor 0.000007629394531 >> scale = prod(cos(atan(2.^(-(0:15))))) %this is an amplitude 0.000003814697266 0.607252935008973 0.000001907348633 >> dec2hex(floor(scale*(2^15- 1))) %don’t want to go all the way to 1 i=20 0.000000953674316 ‘4DB9’ Number Formats: Amplitudes: cosines and sines are 16- bit 2’s comp values from -1 to 1. Angles: rotation angles, thetas are 16- bit 2’s comp values from –π to π . (scaled radians) Input theta is a 16-bit value from 0 to 2 π . (scaled radians) *** could actually be signed from –π to π because of periodicity ***

  3. wire signed [15:0] angles [15:0]; Label nets and registers assign angles[0] = 16’h2000; assign angles[1] = 16’h12E4; assign angles[2] = 16’h09FB; ... i=1 i=2 i=3 i=4 angles[1] angles[2] angles[3] angles[4] 0.463648 0.244979 0.124355 0.062419 theta_approx[0] theta_approx[1] theta_approx[2] theta_approx[3] theta_approx[4] + or - + or - + or - + or - rotation[0] rotation[1] rotation[2] rotation[3] rotation[4] > > > > theta_desired + or - + or - + or - + or - −2 −i −2 −i −2 −i −2 −i 1 1 1 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 cos_approx[0] cos_approx[1] cos_approx[2] cos_approx[3] cos_approx[4] sin_approx[0] sin_approx[1] sin_approx[2] sin_approx[3] sin_approx[4] Number Formats: Amplitudes: cosines and sines are 16- bit 2’s comp values from -1 to 1. Angles: rotation angles, thetas are 16- bit 2’s comp values from –π to π . (scaled radians) Input theta is a 16-bit value from 0 to 2 π . (scaled radians) *** could actually be signed from –π to π because of periodicity ***

  4. wire signed [15:0] angles [15:0]; Initial Conditions assign angles[0] = 16’h2000; assign angles[1] = 16’h12E4; assign angles[2] = 16’h09FB; ... i=1 i=2 i=3 i=4 wire rotation [15:0]; angles[1] angles[2] angles[3] angles[4] a ssign rotation[0] = 1’b1; 0.463648 0.244979 0.124355 0.062419 wire signed [15:0] theta_approx [15:0]; theta_approx[1] theta_approx[2] theta_approx[3] theta_approx[4] assign theta_approx[0] = angles[0]; + or - + or - + or - + or - wire signed [15:0] theta_desired; rotation[1] rotation[2] rotation[3] rotation[4] wire [1:0] quadrant; > > > > assign theta_desired = (theta_in[14]) ? 16’h4000 – theta_in[13:0] : theta_in[13:0] ; assign quadrant = theta_in[15:14]; + or - + or - + or - + or - −2 −i −2 −i −2 −i −2 −i wire signed [15:0] cos_approx [15:0]; 1 1 1 1 wire signed [15:0] sin_approx [15:0]; 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 assign cos_approx[0] = 16’h4DB9; cos_approx[1] cos_approx[2] cos_approx[3] cos_approx[4] assign sin_approx [0] = 16’h4DB9; sin_approx[1] sin_approx[2] sin_approx[3] sin_approx[4] Number Formats: Amplitudes: (cos_approx and sin_approx) are 16- bit 2’s comp values from -1 to 1. Angles: (angles, theta_desired, and theta_approx) are 16- bit 2’s comp values from –π to π . (scaled radians) (theta) is a 16-bit value from 0 to 2 π . (scaled radians) *** could actually be signed from –π to π because of periodicity ***

  5. wire signed [15:0] angles [15:0]; assign rotation[i] = theta_desired > theta_approx[i-1]; assign angles[0] = 16’h2000; assign theta_approx[i] = (rotation[i]) ? theta_approx[i-1] + angles[i] : assign angles[1] = 16’h12E4; theta_approx[i-1] – angles[i] ; assign angles[2] = 16’h09FB; ... i=1 i=2 i=3 i=4 wire rotation [15:0]; Iterations angles[1] angles[2] angles[3] angles[4] a ssign rotation[0] = 1’b1; 0.463648 0.244979 0.124355 0.062419 wire signed [15:0] theta_approx [15:0]; theta_approx[1] theta_approx[2] theta_approx[3] theta_approx[4] assign theta_approx[0] = angles[0]; + or - + or - + or - + or - wire signed [15:0] theta_desired; rotation[1] rotation[2] rotation[3] rotation[4] wire [1:0] quadrant; > > > > assign theta_desired = (theta_in[14]) ? 16’h4000 – theta_in[13:0] : theta_in[13:0] ; assign quadrant = theta_in[15:14]; + or - + or - + or - + or - −2 −i −2 −i −2 −i −2 −i wire signed [15:0] cos_approx [15:0]; 1 1 1 1 wire signed [15:0] cos_approx [15:0]; 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 assign cos_approx[0] = 16’h4DB9; cos_approx[1] cos_approx[2] cos_approx[3] cos_approx[4] assign sin_approx [0] = 16’h4DB9; sin_approx[1] sin_approx[2] sin_approx[3] sin_approx[4] assign cos_approx[i] = (rotation[i]) ? cos_approx[i-1] – (sin_approx[i-1] >>> i) : cos_approx[i-1] + (sin_approx[i-1] >>> i) ; assign sin_approx[i] = (rotation[i]) ? sin_approx[i-1] + (cos_approx[i-1] >>> i) : sin_approx[i-1] - (cos_approx[i-1] >>> i) ; Number Formats: Amplitudes: (cos_approx and sin_approx) are 16- bit 2’s comp values from -1 to 1. Angles: (angles, theta_desired, and theta_approx) are 16- bit 2’s comp values from –π to π . (scaled radians) (theta) is a 16-bit value from 0 to 2 π . (scaled radians) *** could actually be signed from –π to π because of periodicity ***

  6. wire signed [15:0] angles [15:0]; assign rotation[i] = theta_desired > theta_approx[i-1]; assign angles[0] = 16’h2000; assign theta_approx[i] = (rotation[i]) ? theta_approx[i-1] + angles[i] : assign angles[1] = 16’h12E4; theta_approx[i-1] – angles[i] ; assign angles[2] = 16’h09FB; OUTPUT ... i=1 i=2 i=3 i=4 Quadrant wire rotation [15:0]; angles[1] angles[2] angles[3] angles[4] a ssign rotation[0] = 1’b1; 0.463648 0.244979 0.124355 0.062419 Corrections wire signed [15:0] theta_approx [15:0]; theta_approx[1] theta_approx[2] theta_approx[3] theta_approx[4] assign theta_approx[0] = angles[0]; + or - + or - + or - + or - wire signed [15:0] theta_desired; rotation[1] rotation[2] rotation[3] rotation[4] wire [1:0] quadrant; > > > > assign theta_desired = (theta_in[14]) ? 16’h4000 – theta_in[13:0] : theta_in[13:0] ; assign quadrant = theta_in[15:14]; + or - + or - + or - + or - −2 −i −2 −i −2 −i −2 −i wire signed [15:0] cos_approx [15:0]; 1 1 1 1 wire signed [15:0] sin_approx [15:0]; 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 2 − 𝐣 1 assign cos_approx[0] = 16’h4DB9; cos_approx[1] cos_approx[2] cos_approx[3] cos_approx[4] assign sin_approx [0] = 16’h4DB9; sin_approx[1] sin_approx[2] sin_approx[3] sin_approx[4] assign cos_out = (quadrant[1]^quadrant[0]) ? -cos_approx[15] : assign cos_approx[i] = (rotation[i]) ? cos_approx[i-1] – (sin_approx[i-1] >>> i) : cos_approx[15] ; cos_approx[i-1] + (sin_approx[i-1] >>> i) ; assign sin_out = (quadrant[1]) ? assign sin_approx[i] = (rotation[i]) ? sin_approx[i-1] + (cos_approx[i-1] >>> i) : -sin_approx[15] : sin_approx[i-1] - (cos_approx[i-1] >>> i) ; sin_approx[15] ; Number Formats: Amplitudes: (cos_approx and sin_approx) are 16- bit 2’s comp values from -1 to 1. Angles: (angles, theta_desired, and theta_approx) are 16- bit 2’s comp values from –π to π . (scaled radians) (theta) is a 16-bit value from 0 to 2 π . (scaled radians) *** could actually be signed from –π to π because of periodicity ***

Recommend


More recommend