花的翅膀在死亡後才懂得飛翔
林夕
//+FHDR------------------------------------------------
// (C) Copyright Company NTHU.EE VLSI Comm Lab.2009
// All Right Reserved
//-----------------------------------------------------
// FILE NAME: cmplx_fix.h
// AUTHOR: stanlly9
// CONTACT INFORMATION: stanlly9.blogspot.com
//-----------------------------------------------------
// RELEASE VERSION: V 1.0
// VERSION DESCRIPTION:
// 1.0 First release
//-----------------------------------------------------
// RELEASE DATE: Mar-25-2009
//-----------------------------------------------------
// PURPOSE: Complex fixed point
//-FHDR------------------------------------------------
#ifndef _CMPLX_FX_HDR
#define _CMPLX_FX_HDR
#define IWL 7//integer word-length
#define DWL 9 //decimal fraction word-length
//IWL+DWL=sizeof(short int)*2=16
typedef struct {
short int re;
short int im;
} cmplx_fix;
//check negaitve
int is_neg(short int);
//cmplx_fix fcns
void cf_print(cmplx_fix);//printer
void cf_seti_re(cmplx_fix*, int);//set rel part by integer values
void cf_seti_im(cmplx_fix*, int);//set img part by integer values
void cf_setf_re(cmplx_fix*, float);//set rel part by float values
void cf_setf_im(cmplx_fix*, float);//set img part by float values
//--cmplx_fix operator fcns--
//----cmplx_fix to cmplx_fix----
cmplx_fix cf_add(cmplx_fix, cmplx_fix);// +
cmplx_fix cf_sub(cmplx_fix, cmplx_fix);// -
cmplx_fix cf_mul(cmplx_fix, cmplx_fix);// *
cmplx_fix cf_div(cmplx_fix, cmplx_fix);// /
//----cmplx_fix to integer values----
cmplx_fix cf_add_re(cmplx_fix, int); // + real
cmplx_fix cf_add_im(cmplx_fix, int); // + imag
//cmplx_fix cf_sub_re(cmplx_fix, int); // - real as _add_re(-int)
//cmplx_fix cf_sub_im(cmplx_fix, int); // - imag as _add_im(-int)
cmplx_fix cf_mul_re(cmplx_fix, int); // * real
cmplx_fix cf_mul_im(cmplx_fix, int); // * imag
cmplx_fix cf_div_re(cmplx_fix, int); // / real
cmplx_fix cf_div_im(cmplx_fix, int); // / imag
#endif
//cmplx_fix + cmplx_fix
cmplx_fix cf_add(cmplx_fix a, cmplx_fix b)
{
short int real = a.re + b.re;
short int imag = a.im + b.im;
a.re = (short int) real;
a.im = (short int) imag;
return a;
}
\ | iPhone | GPhone |
目標消費者 | 一般大眾 | 重手機功能者 |
策略 | 改變使用者行為 | 改變產業模式 |
獨到強項 | 使用介面 | 網路技術 |
平台特色 | 封閉 | 開放 |
重要協力 | 手機營運商 | 手機製造商 |
獲利方式 | 硬體與軟體銷售 | 網路廣告 |
Recently, I have tried to using SystemC to perform a fixed-point simulation for my DSP program. There are lots of built-in C++ classes [datatypes] for fixed-point representations, which are also very useful. For examples, the support of operator overridding were compeletly done by OSCI. Program designers can multiply the real values they want without considering the representations for integer part and the decimal part. All the rest jobs like scalling, signed extension, rounding are automatically performed by default.
#define SC_INCLUDE_FX
sc_fixed_fast<8,3> x;