TWI420325B - Sine/cosine value generation apparatus - Google Patents

Sine/cosine value generation apparatus Download PDF

Info

Publication number
TWI420325B
TWI420325B TW98104798A TW98104798A TWI420325B TW I420325 B TWI420325 B TW I420325B TW 98104798 A TW98104798 A TW 98104798A TW 98104798 A TW98104798 A TW 98104798A TW I420325 B TWI420325 B TW I420325B
Authority
TW
Taiwan
Prior art keywords
sine
phase
octant
value
cosine
Prior art date
Application number
TW98104798A
Other languages
Chinese (zh)
Other versions
TW201032069A (en
Inventor
Tien Ju Tsai
Original Assignee
Himax Media Solutions Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Himax Media Solutions Inc filed Critical Himax Media Solutions Inc
Priority to TW98104798A priority Critical patent/TWI420325B/en
Publication of TW201032069A publication Critical patent/TW201032069A/en
Application granted granted Critical
Publication of TWI420325B publication Critical patent/TWI420325B/en

Links

Description

正弦/餘弦值產生裝置Sine/cosine value generating device

本發明係有關於一種正弦/餘弦值產生裝置,特別是有關於一種使用較少記憶體空間的正弦/餘弦值產生裝置。The present invention relates to a sine/cosine value generating apparatus, and more particularly to a sine/cosine value generating apparatus using less memory space.

在許許多多的工程領域當中,常常會使用到數學函式的計算,然而,在所有的數學計算中,三角函數(Trigonometric Functions)雖然相對簡單,但卻是非常重要。在三角函數的計算當中,正弦/餘弦(Sine/Cosine)係最常用的數學函數計算,因為工程領域的相關應用常常以正弦/餘弦函數為基礎,進而推導衍生出更繁瑣的數學計算。以通訊工程的領域來說,正弦/餘弦波形常常是信號處理機制中所需用到的最基本訊號形式。In many engineering fields, mathematical functions are often used. However, in all mathematical calculations, Trigonometric Functions are relatively simple, but they are very important. In the calculation of trigonometric functions, sine/cosine (Sine/Cosine) is the most commonly used mathematical function calculation, because the related applications in the engineering field are often based on sine/cosine functions, and then deduced to derive more cumbersome mathematical calculations. In the field of communications engineering, sine/cosine waveforms are often the most basic form of signal used in signal processing mechanisms.

根據數學上的定義,一個圓被分成四個象限,每個象限具有90度的角度值。在傳統的正弦/餘弦值產生機制中,通常先把第一象限(0至90度)中所有角度的正弦/餘弦值都計算出並儲存起來,然後利用這些值求出0至360間任意角度的正弦/餘弦值,但有時候需要加上負號。舉例來說,參考第1圖,其顯示正弦/餘弦函數的基本特性圖。其中,對於正弦函數而言,其第一和第二象限的所有值都是正的,而對於餘弦函數而言,其第一和第四象限的所有值都是正的。如使一來,若要求出正弦函數之一任意角度的值,假設是210度,則必須先把該角度映射至第一象限內的對應角度,然後才可進一步計算其正弦/餘弦值。更具體地說,透過公式:sin(π+θ)=sinπcosθ+cosπsinθ,該210度的角度可被轉換成第一象限內的對應角度30度,但最後的結果值必須再加上負號。因此,210度的正弦值等於30度的正弦值加負號。在上述的習知方式中,必須事先計算第一象限內所有正弦/餘弦函數的值,才可進一步求出任意角度的正弦/餘弦值。According to the mathematical definition, a circle is divided into four quadrants, each having an angular value of 90 degrees. In the traditional sine/cosine value generation mechanism, the sine/cosine values of all angles in the first quadrant (0 to 90 degrees) are usually calculated and stored, and then these values are used to find any angle between 0 and 360. Sine/cosine values, but sometimes you need to add a negative sign. For example, referring to Figure 1, it shows a basic characteristic diagram of a sine/cosine function. Wherein, for a sinusoidal function, all values of the first and second quadrants are positive, and for the cosine function, all values of the first and fourth quadrants are positive. If, for example, a value of any angle of the sine function is required, assuming 210 degrees, the angle must be mapped to the corresponding angle in the first quadrant before the sine/cosine value can be further calculated. More specifically, by the formula: sin(π + θ) = sinπcos θ + cosπsin θ, the angle of 210 degrees can be converted to a corresponding angle of 30 degrees in the first quadrant, but the final result value must be added with a minus sign. Therefore, the sine of 210 degrees is equal to the sine of 30 degrees plus a minus sign. In the above conventional method, the values of all the sine/cosine functions in the first quadrant must be calculated in advance to further obtain the sine/cosine values of any angle.

基於以上的考量,本發明的目的在於提供一種低成本的正弦/餘弦值產生裝置。與習知方式需要事先計算第一象限(90度)內所有正弦/餘弦值的特性相比,本發明只需要事先計算第一八分圓(Octant,45度)內所有的正弦/餘弦值,便可進而計算出任意角度的正弦/餘弦值,因而節省一半的記憶體佔用空間。Based on the above considerations, it is an object of the present invention to provide a low cost sine/cosine value generating device. Compared with the conventional method of calculating the characteristics of all sine/cosine values in the first quadrant (90 degrees) in advance, the present invention only needs to calculate all the sine/cosine values in the first octant (Octant, 45 degrees) in advance. You can then calculate the sine/cosine values at any angle, thus saving half the memory footprint.

有鑑於此,本發明揭露一種正弦/餘弦值產生裝置,用以產生一輸入相位的正弦/餘弦值,包括一相位投射器、一查表/算術單元、一臨時正弦/餘弦值產生器和一正弦/餘弦值產生器。相位投射器用以將輸入相位映射至介於八分圓之內的一八分圓相位,並決定用以判斷輸入相位是否為pi/4、3*pi/4、5*pi/4或7*pi/4的一旗標。查表/算術單元用以接收八分圓相位,並輸出對應於八分圓相位的正弦/餘弦值。臨時正弦/餘弦值產生器用以接收對應於八分圓相位的正弦/餘弦值,以便根據旗標產生臨時正弦/餘弦值。正弦/餘弦值產生器根據用以顯示輸入相位所在之八分圓位置的一八分圓索引,選擇性地將臨時正弦/餘弦值做正弦/餘弦函數值的對調或改變正負號,以作為上述輸入相位的正弦/餘弦值。In view of the above, the present invention discloses a sine/cosine value generating device for generating an input phase sine/cosine value, including a phase projector, a look-up table/arithmetic unit, a temporary sine/cosine value generator, and a Sine/cosine generator. The phase projector is used to map the input phase to an octant phase within an octant and is determined to determine whether the input phase is pi/4, 3*pi/4, 5*pi/4 or 7* A flag of pi/4. The look-up table/arithmetic unit is used to receive the octant phase and output a sine/cosine value corresponding to the octant phase. A temporary sine/cosine generator is used to receive a sine/cosine value corresponding to the octant phase to produce a temporary sine/cosine value based on the flag. The sine/cosine generator selectively selects the temporary sine/cosine value as a sine/cosine function value or changes the sign according to an octant index for displaying the octant position of the input phase, as the above Enter the sine/cosine value of the phase.

為使本發明之上述目的、特徵和優點能更明顯易懂,下文特舉較佳實施例,並配合所附圖式,作詳細說明如下:第2圖顯示根據本發明一實施例所述之正弦/餘弦值產生裝置100的方塊圖。正弦/餘弦值產生裝置100包括一相位投射器120、一查表/算術單元140、一臨時正弦/餘弦值產生器160和一正弦/餘弦值產生器180。在第2圖中,相位投射器120接收一輸入相位值Phase_Value,用以產生一八分圓相位Phase_Octant、一八分圓索引Octant_Idx和一旗標Ph_on_pi/4。查表/算術單元140用以接收八分圓相位Phase_Octant,並輸出對應的正弦函數值Sin_Dout和餘弦函數值Cos_Dout。臨時正弦/餘弦值產生器160用以接收正弦函數值Sin_Dout、餘弦函數值Cos_Dout、旗標Ph_on_pi/4和八分圓索引Octant_Idx,並輸出一對調索引Invert_Swap、一臨時正弦值Sin_Oct和一臨時餘弦值Cos_Oct。正弦/餘弦值產生器180用以接收對調索引Invert_Swap、臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct,並產生最終的正弦值Sin_Val和餘弦值Cos_Val。以下,本發明將說明正弦/餘弦值產生裝置100的詳細動作流程。The above described objects, features, and advantages of the present invention will become more apparent from the aspects of the preferred embodiments illustrated herein A block diagram of the sine/cosine value generating device 100. The sine/cosine value generating apparatus 100 includes a phase projector 120, a look-up table/arithmetic unit 140, a temporary sine/cosine value generator 160, and a sine/cosine value generator 180. In FIG. 2, the phase projector 120 receives an input phase value Phase_Value for generating an octant phase Phase_Octant, an octant index Octant_Idx, and a flag Ph_on_pi/4. The look-up table/arithmetic unit 140 is configured to receive the octant phase Phase_Octant and output a corresponding sine function value Sin_Dout and a cosine function value Cos_Dout. The temporary sine/cosine value generator 160 is configured to receive the sine function value Sin_Dout, the cosine function value Cos_Dout, the flag Ph_on_pi/4, and the octant index Octant_Idx, and output a pair of index indexes Invert_Swap, a temporary sine value Sin_Oct, and a temporary cosine value. Cos_Oct. The sine/cosine value generator 180 is operative to receive the offset index Invert_Swap, the temporary sine value Sin_Oct, and the temporary cosine value Cos_Oct, and to generate the final sine value Sin_Val and the cosine value Cos_Val. Hereinafter, the present invention will explain the detailed operational flow of the sine/cosine value generating apparatus 100.

第3圖顯示根據本發明一實施例所述之相位投射器120的方塊圖。相位投射器120所接收的輸入相位值Phase_Value係以N位元表示,分為兩個部分。第一部分係該N位元的前三高位元,表示為Phase_MSB。而第二部分係該N位元的後N-3低位元,表示為Phase_LSB。另外,八分圓索引Octant_Idx係用以顯示輸入相位值Phase_Value位於一個圓中的哪個八分圓,如此一來,輸入相位值Phase_Value的相位位置即可用八分圓索引Octant_Idx來定義。舉例來說,對於一個位於第0個八分圓的輸入相位值Phase_Value來說,其八分圓索引Octant_Idx係表示為000。同樣地,對於一個位於第7個八分圓的輸入相位值Phase_Value來說,其八分圓索引Octant_Idx係表示為111。旗標Ph_on_pi/4係用以顯示輸入相位值Phase_Value是否正好為π/4、3π/4、5π/4或7π/4的角度值。對於輸入相位值Phase_Value正好為角度值π/4、3π/4、5π/4或7π/4的情況,有可能會讀取到錯誤的正弦/餘弦值,因此必須採取另外的措施。必須了解的是,本發明只需要事先計算並儲存第一八分圓內0至45度所有的正弦/餘弦值,便可依此求出任意角度的正弦/餘弦值。Figure 3 shows a block diagram of a phase projector 120 in accordance with an embodiment of the present invention. The input phase value Phase_Value received by the phase projector 120 is represented by N bits and is divided into two parts. The first part is the first three high bits of the N-bit, denoted as Phase_MSB. The second part is the lower N-3 lower bit of the N-bit, which is represented as Phase_LSB. In addition, the octant index Octant_Idx is used to display which octant of the input phase value Phase_Value is located in a circle, so that the phase position of the input phase value Phase_Value can be defined by the octant index Octant_Idx. For example, for an input phase value Phase_Value at the 0th octant, its octant index Octant_Idx is expressed as 000. Similarly, for an input phase value Phase_Value at the 7th octant, its octant index Octant_Idx is represented as 111. The flag Ph_on_pi/4 is used to display whether the input phase value Phase_Value is exactly an angle value of π/4, 3π/4, 5π/4 or 7π/4. For the case where the input phase value Phase_Value is exactly the angle value π/4, 3π/4, 5π/4 or 7π/4, the wrong sine/cosine value may be read, so additional measures must be taken. It must be understood that the present invention only needs to calculate and store all sine/cosine values from 0 to 45 degrees in the first octant in advance, and thereby obtain the sine/cosine values of any angle.

如第3圖所示,相位投射器120包括擷取單元301和303、一2的補數碼產生器305、一選擇器307和一邏輯電路309。擷取單元301用以取得輸入相位值Phase_Value的前三高位元(Phase_MSB),並輸出八分圓索引Octant_Idx。擷取單元303用以取得輸入相位值Phase_Value的後N-3低位元(Phase_LSB)。2的補數碼產生器305用以求出擷取單元303輸出值的2的補數值。選擇器307用以選擇擷取單元303的輸出值或2的補數碼產生器305的輸出值,作為八分圓相位Phase_Octant。其選擇的機制係根據一控制信號Phase_MSB[0]而定,亦即輸入相位值Phase_Value前三高位元Phase_MSB的最低位元。換言之,當控制信號Phase_MSB[0]為1時(亦即輸入相位值Phase_Value位於第1、3、5或7個八分圓之內時),則將擷取單元303輸出值的2的補數值輸出為八分圓相位Phase_Octant。反之,當控制信號Phase_MSB[0]為0時(亦即輸入相位值Phase_Value位於第0、2、4或6個八分圓之內時),則直接將擷取單元303的輸出值作為八分圓相位Phase_Octant。透過擷取單元303、2的補數碼產生器305和選擇器307,可將輸入相位值Phase_Value映射至位於第0個八分圓之內的對應角度。As shown in FIG. 3, the phase projector 120 includes capture units 301 and 303, a complement digital generator 305 of a 2, a selector 307, and a logic circuit 309. The capturing unit 301 is configured to obtain the first three high bits (Phase_MSB) of the input phase value Phase_Value, and output an octant index Octant_Idx. The capturing unit 303 is configured to obtain the last N-3 lower bits (Phase_LSB) of the input phase value Phase_Value. The complement generator 305 of 2 is used to determine the complement value of 2 of the output value of the capture unit 303. The selector 307 is used to select the output value of the capture unit 303 or the output value of the complement generator 305 as an octant phase Phase_Octant. The mechanism of its selection is based on a control signal Phase_MSB[0], that is, the lowest bit of the first three high bits Phase_MSB of the phase value Phase_Value. In other words, when the control signal Phase_MSB[0] is 1 (that is, when the input phase value Phase_Value is within the first, third, fifth or seventh octant), the complement value of the output value of the capture unit 303 is 2 The output is the octant phase Phase_Octant. On the other hand, when the control signal Phase_MSB[0] is 0 (that is, when the input phase value Phase_Value is within 0, 2, 4 or 6 octants), the output value of the capturing unit 303 is directly taken as eight points. Round phase Phase_Octant. The input phase value Phase_Value can be mapped to a corresponding angle within the 0th octant by the complement digital generator 305 and the selector 307 of the capture units 303, 2.

如第3圖所示,邏輯電路309接收八分圓相位Phase_Octant和控制信號Phase_MSB[0],用以產生旗標Ph_on_pi/4。在本實施例中,邏輯電路309更包括一比較器311和一及閘313。比較器311用以判斷八分圓相位Phase_Octant的所有位元是否皆為0。及閘313只在控制信號Phase_MSB[0]和比較器311的輸出皆為邏輯1時,將旗標Ph_on_pi/4拉升為高電位。亦即,及閘313只在控制信號Phase_MSB[0]的輸出為邏輯1,且八分圓相位Phase_Octant的所有位元皆為0時,才將旗標Ph_on_pi/4拉升為高電位。換言之,在輸入相位值Phase_Value剛好為π/4、3π/4、5π/4或7π/4時,旗標Ph_on_pi/4才會為高電位狀態。As shown in FIG. 3, the logic circuit 309 receives the octant phase Phase_Octant and the control signal Phase_MSB[0] for generating the flag Ph_on_pi/4. In this embodiment, the logic circuit 309 further includes a comparator 311 and a gate 313. The comparator 311 is configured to determine whether all the bits of the octant phase Phase_Octant are 0. The gate 313 pulls the flag Ph_on_pi/4 to a high level only when the control signal Phase_MSB[0] and the output of the comparator 311 are both logic 1. That is, the gate 313 pulls the flag Ph_on_pi/4 to a high level only when the output of the control signal Phase_MSB[0] is logic 1 and all bits of the octant phase Phase_Octant are 0. In other words, when the input phase value Phase_Value is exactly π/4, 3π/4, 5π/4 or 7π/4, the flag Ph_on_pi/4 will be in a high potential state.

第4A、4B和4C圖顯示根據本發明所述之查表/算術單元140的三個實施例的方塊圖。查表/算術單元140用以接收八分圓相位Phase_Octant,並輸出對應的正弦函數值Sin_Dout和餘弦函數值Cos_Dout。第4A圖顯示根據本發明所述之查表/算術單元140的一實施例,其係以全查表法(full-Look Up Table(full-LUT)approach)的方式實現。在第4A圖中,第0個八分圓內的所有的正弦/餘弦值皆事先計算,且儲存於一唯讀記憶體(Read-Only Memory)中。根據從相位投射器120所接收的八分圓相位Phase_Octant,查表/算術單元140以查表的方式從該唯讀記憶體中讀取對應的正弦/餘弦值,並將所讀取的正弦/餘弦值輸出為正弦函數值Sin_Dout和餘弦函數值Cos_Dout。第4B圖顯示根據本發明所述之查表/算術單元140的另一實施例,其係以全算術(full-arithmetic)的方式實現。在第4B圖中,第0個八分圓內的所有的正弦/餘弦值皆以一個實現坐標旋轉數位電腦(Coordinate Rotation Digital Computer,CORDIC)疊代演算法(iteration algorithm)的處理器來事先計算,且一個可藉著將八分圓相位Phase_Octan乘上常數π/4再將結果值截短成K位元而求得的正規化八分圓相位Phase_Normalized,可使用該處理器計算其對應的正弦/餘弦值做為輸出的正弦函數值Sin_Dout和餘弦函數值Cos_Dout。第4C圖依然顯示根據本發明所述之查表/算術單元140的另一實施例,其係以查表-算術混合法(LUT-arithmetic hybrid approach)的方式實現。在第4C圖中,第0個八分圓內的所有的正弦/餘弦值皆儲存於一唯讀記憶體中,且可藉著將八分圓相位Phase_Octan乘上常數π/4,再將結果值截短成K位元的方式求得一正規化的八分圓相位Phase_Normalized。該正規化的八分圓相位Phase_Normalized包括兩個部分:第一部分係正規化八分圓相位Phase_Normalized的前L個高位元,而第二部分係正規化八分圓相位Phase_Normalized的後(K-L)個低位元。第一部分的正弦/餘弦值可用查表的方式由唯讀記憶體中讀取,而第二部分的正弦/餘弦值可用一個實現CORDIC疊代演算法的處理器來計算。由唯讀記憶體所讀取的輸出值,和實現CORDIC疊代演算法之處理器所輸出的值,兩者可合併為正弦函數值Sin_Dout和餘弦函數值Cos_Dout。更詳細地說,假設正規化八分圓相位Phase_Normalized表示為A+B,A為第一部分,而B為第二部分。由於sin(A +B )=sinA *cosB +cosA *sinB ,且cos(A +B )=cosA *cosB -sinA *sinB ,因此可藉著查表的方式求出sinA 和sinB 的值,而藉著使用一個實現CORDIC疊代演算法的處理器可計算出cosA 和cosB 的值,最後再將從唯讀記憶體讀取的輸出值與處理器的輸出值兩者結合而求出sin(A +B )和cos(A +B )。第4D圖顯示根據本發明一實施例所述之唯讀記憶體中的資料儲存格式。在第4D圖的實施例中,餘弦值係儲存於唯讀記憶體的左邊部分,而正弦值係儲存於唯讀記憶體的右邊部分。Figures 4A, 4B and 4C show block diagrams of three embodiments of the look-up table/arithmetic unit 140 in accordance with the present invention. The look-up table/arithmetic unit 140 is configured to receive the octant phase Phase_Octant and output a corresponding sine function value Sin_Dout and a cosine function value Cos_Dout. Figure 4A shows an embodiment of a look-up table/arithmetic unit 140 in accordance with the present invention implemented in a full-Look Up Table (full-LUT) approach. In Figure 4A, all sine/cosine values in the 0th octant are calculated in advance and stored in a Read-Only Memory. Based on the octant phase Phase_Octant received from the phase projector 120, the look-up table/arithmetic unit 140 reads the corresponding sine/cosine value from the read-only memory in a look-up manner and reads the sine/ The cosine value is output as a sine function value Sin_Dout and a cosine function value Cos_Dout. Figure 4B shows another embodiment of the look-up table/arithmetic unit 140 in accordance with the present invention, which is implemented in a full-arithmetic manner. In Figure 4B, all sine/cosine values in the 0th octant are calculated in advance by a processor that implements the Coordinate Rotation Digital Computer (CORDIC) iteration algorithm. And a normalized octant phase Phase_Normalized obtained by multiplying the octant phase Phase_Octan by a constant π/4 and then truncating the resulting value into K bits, the processor can be used to calculate the corresponding sine The /cosine value is taken as the sine function value Sin_Dout and the cosine function value Cos_Dout of the output. Figure 4C still shows another embodiment of the look-up table/arithmetic unit 140 in accordance with the present invention, which is implemented in a LUT-arithmetic hybrid approach. In Figure 4C, all sine/cosine values in the 0th octant are stored in a read-only memory, and the result can be multiplied by a constant π/4 by multiplying the octant phase Phase_Octan. A normalized octant phase Phase_Normalized is obtained by truncating the value into K bits. The normalized octant phase Phase_Normalized consists of two parts: the first part is the first L high order elements of the normalized octant phase Phase_Normalized, and the second part is the normal (KL) low order of the normalized octant phase Phase_Normalized. yuan. The sine/cosine values of the first part can be read by the read-only memory in a look-up manner, and the sine/cosine values of the second part can be calculated by a processor implementing the CORDIC iterative algorithm. The output values read by the read-only memory and the values output by the processor implementing the CORDIC iterative algorithm can be combined into a sine function value Sin_Dout and a cosine function value Cos_Dout. In more detail, it is assumed that the normalized octant phase Phase_Normalized is represented as A+B, A is the first part, and B is the second part. Since sin( A + B )=sin A *cos B +cos A *sin B and cos( A + B )=cos A *cos B -sin A *sin B , it can be obtained by looking up the table. The values of sin A and sin B , and by using a processor that implements the CORDIC iterative algorithm, the values of cos A and cos B can be calculated, and finally the output values read from the read-only memory are processed by the processor. The output values are combined to find sin( A + B ) and cos( A + B ). FIG. 4D is a diagram showing a data storage format in a read-only memory according to an embodiment of the invention. In the embodiment of Fig. 4D, the cosine value is stored in the left portion of the read only memory, and the sine value is stored in the right portion of the read only memory.

參考回第2圖,臨時正弦/餘弦值產生器160更包括選擇器501和502,以及一查表表格503,如第5A和5B圖所示。根據所接收的正弦函數值Sin_Dout、餘弦函數值Cos_Dout、旗標Ph_on_pi/4和八分圓索引Octant_Idx,臨時正弦/餘弦值產生器160輸出對調索引Invert_Swap、臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct。參考第5A圖,選擇器501選擇常數π/4或餘弦函數值Cos_Dout作為臨時餘弦值Cos_Oct,而選擇器502選擇常數π/4或正弦函數值Sin_Dout作為臨時正弦值Sin_Oct。該選擇係根據旗標Ph_on_pi/4而定。更詳細地說,當輸入相位值Phase_Value剛好為π/4、3π/4、5π/4或7π/4時,旗標Ph_on_pi/4將會為高電位狀態,且選擇器501和502將常數π/4同時輸出做為臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct。反之,旗標Ph_on_pi/4將會為低電位狀態,且選擇器501和502分別將正弦函數值Sin_Dout和餘弦函數值Cos_Dout輸出做為臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct。Referring back to FIG. 2, the temporary sine/cosine value generator 160 further includes selectors 501 and 502, and a look-up table 503 as shown in FIGS. 5A and 5B. Based on the received sine function value Sin_Dout, the cosine function value Cos_Dout, the flag Ph_on_pi/4, and the octant index Octant_Idx, the temporary sine/cosine value generator 160 outputs a reverse index Invert_Swap, a temporary sine value Sin_Oct, and a temporary cosine value Cos_Oct. Referring to FIG. 5A, the selector 501 selects the constant π/4 or the cosine function value Cos_Dout as the temporary cosine value Cos_Oct, and the selector 502 selects the constant π/4 or the sine function value Sin_Dout as the temporary sine value Sin_Oct. This selection is based on the flag Ph_on_pi/4. In more detail, when the input phase value Phase_Value is exactly π/4, 3π/4, 5π/4 or 7π/4, the flag Ph_on_pi/4 will be in a high potential state, and the selectors 501 and 502 will have a constant π. The /4 simultaneous output is used as the temporary sine value Sin_Oct and the temporary cosine value Cos_Oct. On the contrary, the flag Ph_on_pi/4 will be in a low potential state, and the selectors 501 and 502 respectively output the sine function value Sin_Dout and the cosine function value Cos_Dout as the temporary sine value Sin_Oct and the temporary cosine value Cos_Oct.

參考第5B圖,在查表表格503中的對調索引Invert_Swap和八分圓索引Octant_Idx之間具有一對一的映射關係。在本實施例中,對調索引Invert_Swap和八分圓索引Octant_Idx皆為三位元。必須了解的是,雖然在本實施例中查表表格503係整合於臨時正弦/餘弦值產生器160之內,但其亦可整合於其他元件中,像是相位投射器120、查表/算術單元140或正弦/餘弦值產生器180。對調索引Invert_Swap的詳細用法將於稍後說明。Referring to FIG. 5B, there is a one-to-one mapping relationship between the index index Invert_Swap and the octant index Octant_Idx in the lookup table 503. In this embodiment, the index index Invert_Swap and the octant index Octant_Idx are all three bits. It must be understood that although the lookup table 503 is integrated into the temporary sine/cosine generator 160 in this embodiment, it may be integrated into other components, such as the phase projector 120, table lookup/arithmetic. Unit 140 or sine/cosine value generator 180. The detailed usage of the index index Invert_Swap will be explained later.

參考回第2圖,根據所接收的對調索引Invert_Swap、臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct,正弦/餘弦值產生器180產生最終的正弦值Sin_Val和餘弦值Cos_Val。參考第6圖,第一選擇器601和603用以對臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct加上符號(正負號),而帶有正負號的臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct則進一步輸出到第二選擇器605和607。第一選擇器601和603根據由臨時正弦/餘弦值產生器160所輸出的控制信號Invert_Swap[1]和Invert_Swap[2],個別地選擇臨時正弦值Sin_Oct和臨時餘弦值Cos_Oct(正值),或著是其2的補數值(負值),作為其輸出。另一方面,第二選擇器605和607亦根據由臨時正弦/餘弦值產生器160所輸出的控制信號Invert_Swap[0],選定(1)選擇器603的輸出值為最終的餘弦值Cos_Val,選擇器601的輸出值為最終的正弦值Sin_Val,或著是(2)選擇器601的輸出為最終的餘弦值Cos_Val,選擇器603的輸出為最終的正弦值Sin_Val。Referring back to FIG. 2, the sine/cosine value generator 180 generates a final sine value Sin_Val and a cosine value Cos_Val according to the received index of the index Invert_Swap, the temporary sine value Sin_Oct, and the temporary cosine value Cos_Oct. Referring to Fig. 6, the first selectors 601 and 603 are used to add a sign (positive sign) to the temporary sine value Sin_Oct and the temporary cosine value Cos_Oct, and the temporary sine value Sin_Oct and the temporary cosine value Cos_Oct with positive and negative signs are further output. To the second selectors 605 and 607. The first selectors 601 and 603 individually select the temporary sine value Sin_Oct and the temporary cosine value Cos_Oct (positive value) according to the control signals Invert_Swap[1] and Invert_Swap[2] output by the temporary sine/cosine value generator 160, or It is its complement value (negative value) of 2 as its output. On the other hand, the second selectors 605 and 607 also select (1) the output value of the selector 603 as the final cosine value Cos_Val according to the control signal Invert_Swap[0] outputted by the temporary sine/cosine value generator 160, selecting The output of the 601 is the final sine value Sin_Val, or (2) the output of the selector 601 is the final cosine value Cos_Val, and the output of the selector 603 is the final sine value Sin_Val.

本發明之正弦/餘弦值產生裝置100至此已完整說明,然而,雖本發明以較佳實施例揭露如上,但其並非用以限定本發明的範圍,任何熟習此項技藝者,在不脫離本發明之精神和範圍內,當可做些許的更動與潤飾,因此本發明之保護範圍當視後附之申請專利範圍所界定者為準。The sine/cosine value generating device 100 of the present invention has been described in the above. However, although the present invention has been disclosed in the above preferred embodiments, it is not intended to limit the scope of the present invention. In the spirit and scope of the invention, the scope of the invention is defined by the scope of the appended claims.

100...正弦/餘弦值產生裝置100. . . Sine/cosine value generating device

120...相位投射器120. . . Phase projector

140...查表/算術單元140. . . Table lookup/arithmetic unit

160...臨時正弦/餘弦值產生器160. . . Temporary sine/cosine generator

180...正弦/餘弦值產生器180. . . Sine/cosine generator

301、303...擷取單元301, 303. . . Capture unit

305...2的補數碼產生器305. . . 2 complement digital generator

307、501、502、601、603、605、607...選擇器307, 501, 502, 601, 603, 605, 607. . . Selector

309...邏輯電路309. . . Logic circuit

311...比較器311. . . Comparators

313...及閘313. . . Gate

第1圖顯示正弦/餘弦函數的基本特性圖;Figure 1 shows the basic characteristic diagram of the sine/cosine function;

第2圖顯示根據本發明一實施例所述之正弦/餘弦值產生裝置的方塊圖;2 is a block diagram showing a sine/cosine value generating apparatus according to an embodiment of the present invention;

第3圖顯示根據本發明一實施例所述之相位投射器的方塊圖;3 is a block diagram showing a phase projector according to an embodiment of the invention;

第4A圖顯示根據本發明所述之查表/算術單元的一實施例,其係以全查表法的方式實現;4A is a diagram showing an embodiment of a look-up table/arithmetic unit according to the present invention, which is implemented in a full look-up table method;

第4B圖顯示根據本發明所述之查表/算術單元的另一實施例,其係以全算術的方式實現;Figure 4B shows another embodiment of a look-up table/arithmetic unit in accordance with the present invention, which is implemented in a fully arithmetic manner;

第4C圖依然顯示根據本發明所述之查表/算術單元的另一實施例,其係以查表-算術混合法的方式實現;Figure 4C still shows another embodiment of the look-up table/arithmetic unit according to the present invention, which is implemented in a table-arithmetic mixing method;

第4D圖顯示根據本發明一實施例所述之唯讀記憶體中的資料儲存格式;4D is a diagram showing a data storage format in a read-only memory according to an embodiment of the invention;

第5A圖顯示根據本發明一實施例所述之臨時正弦/餘弦值的產生過程;FIG. 5A is a diagram showing a process of generating a temporary sine/cosine value according to an embodiment of the invention;

第5B圖顯示根據本發明一實施例所述之對調索引和八分圓索引之間的查表表格;以及FIG. 5B is a diagram showing a lookup table between a index of an index and an index of an octant according to an embodiment of the invention;

第6圖顯示根據本發明一實施例所述之最終正弦/餘弦值的產生過程。Figure 6 shows the generation of the final sine/cosine value in accordance with an embodiment of the present invention.

100...正弦/餘弦值產生裝置100. . . Sine/cosine value generating device

120...相位投射器120. . . Phase projector

140...查表/算術單元140. . . Table lookup/arithmetic unit

160...臨時正弦/餘弦值產生器160. . . Temporary sine/cosine generator

180...正弦/餘弦值產生器180. . . Sine/cosine generator

Claims (9)

一種正弦/餘弦值產生裝置,用以產生一輸入相位的正弦/餘弦值,其中上述輸入相位介於0至2*pi,並且以N位元來表示,包括:一相位投射器,將上述輸入相位映射至介於八分圓之內的一八分圓相位,並決定用以判斷上述輸入相位是否為pi/4、3*pi/4、5*pi/4或7*pi/4的一旗標,其中上述相位投射器更決定上述八分圓索引,其中上述相位投射器更包括:一第一擷取單元,取得上述輸入相位的前三個高位元作為上述八分圓索引;一第二擷取單元,取得上述輸入相位的後N-3個低位元;一2的補數碼產生器,求出上述第二擷取單元所取得之N-3個低位元的補數;一選擇器,根據上述八分圓索引的低位元來選擇上述第二擷取單元所取得之N-3個低位元,或上述2的補數碼產生器所求出之N-3個低位元的補數,作為上述八分圓相位,以及一邏輯電路,根據上述八分圓相位和上述八分圓索引的低位元來產生上述旗標;一查表/算術單元,接收上述八分圓相位,並輸出對應於上述八分圓相位的正弦/餘弦值;一臨時正弦/餘弦值產生器,接收對應於上述八分圓相位的正弦/餘弦值,以便根據上述旗標產生臨時正弦/餘弦 值;以及一正弦/餘弦值產生器,根據用以顯示上述輸入相位所在之八分圓位置的一八分圓索引,選擇性地將上述臨時正弦/餘弦值做正弦/餘弦函數值的對調或改變正負號,以作為上述輸入相位的正弦/餘弦值。 A sine/cosine value generating device for generating an input phase sine/cosine value, wherein the input phase is between 0 and 2*pi, and is represented by N bits, including: a phase projector that inputs the input The phase is mapped to an octant phase within an octant and is determined to determine whether the input phase is pi/4, 3*pi/4, 5*pi/4 or 7*pi/4 a flag, wherein the phase projector further determines the octant index, wherein the phase projector further comprises: a first capturing unit, obtaining the first three high bits of the input phase as the octant index; a second capture unit obtains the last N-3 lower bits of the input phase; a complement generator of one 2 obtains a complement of N-3 low bits obtained by the second capture unit; a selector And selecting, according to the lower bit of the octant index, the N-3 lower bits obtained by the second capturing unit, or the complement of the N-3 low bits obtained by the complementary digital generator of the 2, As the above octant phase, and a logic circuit, according to the above octant phase and the above The lower bit of the circular index is used to generate the above flag; a lookup table/arithmetic unit receives the octant phase and outputs a sine/cosine value corresponding to the octant phase; a temporary sine/cosine value generator, Receiving a sine/cosine value corresponding to the above octant phase to generate a temporary sine/cosine according to the above flag And a sine/cosine value generator selectively aligning the temporary sine/cosine value to a sine/cosine function value according to an octant index for displaying an octant position of the input phase Change the sign to be the sine/cosine value of the above input phase. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述邏輯電路更包括:一比較器,判斷上述八分圓相位的所有位元是否皆為邏輯0;以及一及閘,當上述八分圓索引的低位元為邏輯1,且上述比較器判斷上述八分圓相位的所有位元皆為邏輯0的時候,將上述旗標拉高至邏輯1位準。 The sine/cosine value generating device of claim 1, wherein the logic circuit further comprises: a comparator for determining whether all of the bits of the octant phase are all logic 0; and The lower bit of the octant index is logic 1, and when the comparator determines that all the bits of the octant phase are logic 0, the flag is raised to a logic 1 level. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述查表/算術單元更包括:一唯讀記憶體,儲存第0個八分圓的正弦/餘弦值,並且輸出對應於上述八分圓相位的正弦/餘弦值。 The sine/cosine value generating apparatus according to claim 1, wherein the look-up table/arithmetic unit further comprises: a read-only memory storing a sine/cosine value of the 0th octant, and the output corresponds to The sine/cosine value of the above octant phase. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述查表/算術單元更包括:一處理器,根據一正規化的相位,使用CORDIC疊代演算法來輸出對應於上述八分圓相位的正弦/餘弦值,其中上述正規化相位係根據先求得上述八分圓相位與pi/4相乘後的結果值,再將該結果值切成K位元而求得。 The sine/cosine value generating apparatus according to claim 1, wherein the look-up table/arithmetic unit further comprises: a processor, according to a normalized phase, using a CORDIC iterative algorithm to output the corresponding eight The sine/cosine value of the rounded phase, wherein the normalized phase is obtained by first obtaining the result value obtained by multiplying the octant phase by pi/4, and then cutting the result value into K bits. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述查表/算術單元更包括:一唯讀記憶體,儲存第0個八分圓的正弦/餘弦值,並 且輸出一正規化相位之第一部分的正弦/餘弦值,其中上述正規化相位係根據先求得上述八分圓相位與pi/4相乘後的結果值,再將該結果值切成K位元而求得;以及一處理器,使用CORDIC疊代演算法產生上述正規化相位之第二部分的正弦/餘弦值,並藉著合併上述正規化相位之第一部分和第二部分的正弦/餘弦值來輸出對應於上述八分圓相位的正弦/餘弦值。 The sine/cosine value generating apparatus according to claim 1, wherein the look-up table/arithmetic unit further comprises: a read-only memory storing a sine/cosine value of the 0th octant, and And outputting a sine/cosine value of the first part of the normalized phase, wherein the normalized phase is obtained by first obtaining the result value of the octant phase multiplied by pi/4, and then cutting the result value into K bits. And a processor that uses a CORDIC iterative algorithm to generate a sine/cosine value of the second portion of the normalized phase, and by combining the sine/cosine of the first and second portions of the normalized phase The value is to output a sine/cosine value corresponding to the above octant phase. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述臨時正弦/餘弦值產生器更包括:一第一選擇器,根據上述旗標選擇一常數值或上述八分圓相位的餘弦值做為上述臨時正弦值;以及一第二選擇器,根據上述旗標選擇上述常數值或上述八分圓相位的正弦值做為上述臨時餘弦值。 The sine/cosine value generating device of claim 1, wherein the temporary sine/cosine value generator further comprises: a first selector for selecting a constant value or the octant phase according to the flag The cosine value is used as the temporary sine value; and a second selector selects the constant value or the sine value of the octant phase as the temporary cosine value according to the flag. 如申請專利範圍第6項所述之正弦/餘弦值產生裝置,其中上述臨時正弦/餘弦值產生器更包括:一查表表格,根據上述八分圓索引輸出一對調索引,用以顯示對應於上述八分圓相位的正弦/餘弦值是否需要於下一級的上述正弦/餘弦值產生器中,做正弦/餘弦函數值的對調或改變正負號的動作。 The sine/cosine value generating apparatus according to claim 6, wherein the temporary sine/cosine value generator further comprises: a look-up table, and outputting a pair of index according to the octant index to display corresponding to Whether the sine/cosine value of the above octant phase is required to be the sine/cosine function value in the sine/cosine value generator of the next stage, or the action of changing the sign. 如申請專利範圍第1項所述之正弦/餘弦值產生裝置,其中上述正弦/餘弦值產生器更包括:一第一選擇器,根據上述八分圓索引選擇上述臨時正弦/餘弦值,或上述臨時正弦/餘弦值之2的補數,做為上述第一選擇器的輸出;以及一第二選擇器,根據上述八分圓索引選擇上述第一選 擇器的輸出做為上述輸入相位的正弦/餘弦值。 The sine/cosine value generating apparatus of claim 1, wherein the sine/cosine value generator further comprises: a first selector, selecting the temporary sine/cosine value according to the octant index, or the above a complement of 2 of the temporary sine/cosine value as the output of the first selector; and a second selector for selecting the first selection according to the octant index The output of the selector is taken as the sine/cosine value of the above input phase. 如申請專利範圍第7項所述之正弦/餘弦值產生裝置,其中上述正弦/餘弦值產生器更包括:一第一選擇器,根據上述對調索引,選擇上述臨時正弦值或上述臨時正弦值之2的補數,以及根據上述對調索引,選擇上述臨時餘弦值或上述臨時餘弦值之2的補數,做為上述第一選擇器的輸出;以及一第二選擇器,根據上述對調索引,選擇上述第一選擇器的輸出作為上述輸入相位的正弦或餘弦值。 The sine/cosine value generating device of claim 7, wherein the sine/cosine value generator further comprises: a first selector, and selecting the temporary sine value or the temporary sine value according to the index of the above-mentioned index a complement of 2, and according to the above-mentioned index of reversal, selecting a comma of the temporary cosine value or 2 of the temporary cosine value as the output of the first selector; and a second selector, selecting according to the index of the above-mentioned index The output of the first selector described above is used as the sine or cosine of the input phase.
TW98104798A 2009-02-16 2009-02-16 Sine/cosine value generation apparatus TWI420325B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW98104798A TWI420325B (en) 2009-02-16 2009-02-16 Sine/cosine value generation apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW98104798A TWI420325B (en) 2009-02-16 2009-02-16 Sine/cosine value generation apparatus

Publications (2)

Publication Number Publication Date
TW201032069A TW201032069A (en) 2010-09-01
TWI420325B true TWI420325B (en) 2013-12-21

Family

ID=44854767

Family Applications (1)

Application Number Title Priority Date Filing Date
TW98104798A TWI420325B (en) 2009-02-16 2009-02-16 Sine/cosine value generation apparatus

Country Status (1)

Country Link
TW (1) TWI420325B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5737253A (en) * 1995-08-30 1998-04-07 Pentomics, Inc. Method and apparatus for direct digital frequency synthesizer
US5774082A (en) * 1997-03-13 1998-06-30 Raytheon Company Digital phase to digital sine and cosine amplitude translator
TW200306432A (en) * 2002-03-22 2003-11-16 Asahi Chemical Ind Angle examining apparatus and angle examining system
TW562934B (en) * 2001-04-09 2003-11-21 Eni Technology Inc Method and apparatus for determining the instantaneous power of a sinusoidal signal
US7031992B2 (en) * 2000-09-08 2006-04-18 Quartics, Inc. Hardware function generator support in a DSP

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5737253A (en) * 1995-08-30 1998-04-07 Pentomics, Inc. Method and apparatus for direct digital frequency synthesizer
US5774082A (en) * 1997-03-13 1998-06-30 Raytheon Company Digital phase to digital sine and cosine amplitude translator
US7031992B2 (en) * 2000-09-08 2006-04-18 Quartics, Inc. Hardware function generator support in a DSP
TW562934B (en) * 2001-04-09 2003-11-21 Eni Technology Inc Method and apparatus for determining the instantaneous power of a sinusoidal signal
TW200306432A (en) * 2002-03-22 2003-11-16 Asahi Chemical Ind Angle examining apparatus and angle examining system

Also Published As

Publication number Publication date
TW201032069A (en) 2010-09-01

Similar Documents

Publication Publication Date Title
US8200728B2 (en) Sine/cosine generator
JP2853230B2 (en) Digital filter device
US8392492B2 (en) Sine/cosine value generation apparatus
TWI420807B (en) An arbitrary frequency shifter in communication systems
US6260054B1 (en) Reciprocal generator using piece-wise-linear segments of varying width with floating-point format
CN102799412A (en) CORDIC (coordinate rotation digital computer) accelerator based on parallel pipeline design
TWI420325B (en) Sine/cosine value generation apparatus
US8549056B2 (en) Apparatus and program for arctangent calculation
EP0880101A2 (en) Apparatus and method for Fast Fourier Transform
CN109345463B (en) Optimization method and system for coordinate rotation digital calculation method
WO2020093676A1 (en) Apparatus of implementing activation logic for neural network and method thereof
US20150178047A1 (en) Method of fast arctangent calculation pre and post processing
JPH08201110A (en) Interpolation apparatus
JP3015011B1 (en) Sine / cosine operation circuit
CN110908633A (en) Coordinate rotation digital calculator and method
JP2004172794A (en) Composite trigonometric function computing element and phase rotation computing element
KR100328840B1 (en) Sine/cosine arithmetic apparatus
US20210117501A1 (en) System and method for performing vector rotation
TWI390848B (en) Digital wave generator and method of generating a digital wave
JP2010249704A (en) Interpolation device
TW202020655A (en) Coordinate rotation digital computing device and method using the same
JP6633252B2 (en) Likelihood generator
US20030038657A1 (en) Waveform data generation apparatus
JP2003051749A (en) Branch metric calculation device and its calculation method
TW202011176A (en) Coordinate rotation digital computer and method using the same

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees