⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnrom128.cpp

📁 8-1024可变点数FFT/IFFT变换,VHDL语言设计, 仿真通过,可以很容易综合.
💻 CPP
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <math.h>void main(){	const numbits = 32;	int i,k;
	long stmp;
	long scale;
	FILE *sintext;	FILE *costext;	char quote;	float pi,w;	long cosdata[128];	long sindata[128];	char data[32+1];//32 bits + /0           pi = 3.141592653589;		  w = 2*pi*1/256;		  quote = '"';		  scale = pow(2,numbits-1);		  sintext = fopen("sin128.txt","w+");
		  costext = fopen("cos128.txt","w+");		  // generate the first half wave cosine		  for (i=0;i<=127;i++){					 cosdata[i] = (long) ((scale-1)  * cos(i*w));	 };
		 // generate the sine half wave from the middle		  for (i=0;i<=127;i++){
					 sindata[i] = (long) ((scale-1)  * sin(i*w));
	 };
	 			for (i=0;i<=127;i++){					 stmp = sindata[i];					 for (k=0;k<=numbits-1;k++){						 if ((stmp & 0x0001) != 0){							 data[numbits-1-k]='1';						 }else{							 data[numbits-1-k]='0';						 };						 stmp = stmp >> 1;					 };					 data[numbits]='\0';					 fprintf(sintext,"\t\tROMWORD'(%c",quote);					 fprintf(sintext,"%s",data);					 fprintf(sintext,"%c),--address=%d\n",quote,i);			};			fclose(sintext);			for (i=0;i<=127;i++){					 stmp = cosdata[i];					 for (k=0;k<=numbits-1;k++){						 if ((stmp & 0x0001) != 0){							 data[numbits-1-k]='1';						 }else{							 data[numbits-1-k]='0';						 };						 stmp = stmp >> 1;					 };					 data[numbits]='\0';					 fprintf(costext,"\t\tROMWORD'(%c",quote);					 fprintf(costext,"%s",data);					 fprintf(costext,"%c),--address=%d\n",quote,i);			};			fclose(costext);};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -