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

📄 fakelef.c

📁 MP3解码的ASIC全部过程
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "constants.h"int main(int argv, char* argc[]){	lef_file	lef;	FILE* ifile;	FILE* ofile;	char ch;	int  ok, pos, i;	char command[32];    float xpos, pin_distance;	if (argv == 6) {		strcpy(lef.name, argc[1]);		lef.xsize = (((int)((atof(argc[2])+1.499)/1.5)))*1.5;		lef.ysize = (((int)((atof(argc[3])+1.499)/1.5)))*1.5;		lef.data_bits = atoi(argc[4]);		lef.addr_bits = atoi(argc[5]);			memcpy(lef.type, lef.name, 4);		lef.type[4] = '\0';		strcpy(lef.filename, lef.name);		strcat(lef.filename, ".lef\0");		printf("Generating %s with %d data bits and %d address bits...", lef.filename, lef.data_bits, lef.addr_bits);		ifile = fopen(lef.type, "r");		ofile = fopen(lef.filename, "w");		ok = fscanf(ifile, "%c", &ch);		while (ok != EOF) {			if (ch != '%')				fprintf(ofile, "%c", ch);			else {				fscanf(ifile, "%c", &ch);				pos = 0;				while (ch != '%') {					command[pos++] = ch;					fscanf(ifile, "%c", &ch);				}				command[pos] = '\0';				if (strcmp(command, "NAME") == 0) 					fprintf(ofile, "%s", lef.name);				if (strcmp(command, "XSIZE") == 0) 					fprintf(ofile, "%0.2f", lef.xsize);				if (strcmp(command, "YSIZE") == 0) 					fprintf(ofile, "%0.2f", lef.ysize);				if (strcmp(command, "PINS") == 0) {                    pin_distance = (int)(lef.xsize / (15+lef.addr_bits+2*lef.data_bits));                     xpos = 10*pin_distance;      					for (i = 0; i < lef.addr_bits; i++) {						fprintf(ofile, "    PIN A<%d>\n        DIRECTION INPUT ;\n        PORT\n        LAYER metal2 ;\n        RECT  %.2f 1.90 %.2f 5.30 ;\n        END\n    END A<%d>\n", i, xpos, xpos+0.5, i);    	                    xpos = xpos + pin_distance;					}					for (i = 0; i < lef.data_bits; i++) {						fprintf(ofile, "    PIN D<%d>\n        DIRECTION INPUT ;\n        PORT\n        LAYER metal2 ;\n        RECT  %.2f 1.90 %.2f 5.30 ;\n        END\n    END D<%d>\n", i, xpos, xpos+0.5, i);    	                    xpos = xpos + pin_distance;					}					for (i = 0; i < lef.data_bits; i++) {						fprintf(ofile, "    PIN Q<%d>\n        DIRECTION INPUT ;\n        PORT\n        LAYER metal2 ;\n        RECT  %.2f 1.90 %.2f 5.30 ;\n        END\n    END Q<%d>\n", i, xpos, xpos+0.5, i);    	                    xpos = xpos + pin_distance;					}				}			}			ok = fscanf(ifile, "%c", &ch);		}		printf("done\n\n");	}	else		printf("usage: fakelef <mem name> <x size> <y size> <data bits> <addr_bits>\n\nSupports SPS2 SPS4 and ROMD\n\n\t<mem name>  = SPS4_96x16\n\t<x size>    = 100.50\n\t<y size>    = 250.50\n\t<data bits> = 16\n\t<addr bits> = 7\n\n");	return 0;}

⌨️ 快捷键说明

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