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

📄 ovalloc.c

📁 ofdm的完整系统模型,包含信道参数,多径模型,doppler频移等都可以自由修改!是您做仿真的有力帮助.c语言运行速度快!
💻 C
字号:
/*
 *	*************************************************************************
 *	*									*
 *	*	This confidential and proprietary software may be used only	*
 *	*  as authorized by a licensing agreement from the Alta Group of	*
 *	*  Cadence Design Systems, Inc.  In the event of publication, the	*
 *	*  following notice is applicable:					*
 *	*									*
 *	*    (c) COPYRIGHT 1995 ALTA GROUP OF CADENCE DESIGN SYSTEMS, INC.	*
 *	*			ALL RIGHTS RESERVED				*
 *	*									*
 *	*	The entire notice above must be reproduced on all authorized	*
 *	*  copies.								*
 *	*									*
 *	*************************************************************************
 *
 */
/*
 * FILE:  OvAlloc.c
 * DATE:  July 20, 1989
 * RELATED FILES:  
 * AUTHOR:  John Lundell
 * DESCRIPTION:  Ovector allocator
 * NOTES/WARNINGS:  
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 */
#include "cgs.h"
/*
 *  Default Objprops
 */

static struct obj_props_type def_Objprops[28] = {
	{ TYPE_VRD, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VRD, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VRI, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VRI, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VCD, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VCD, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VCI, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VCI, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_VRX, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRS, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRL, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRI, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRI, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRF, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRF, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRD, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRD, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SRX, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCL, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCI, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCI, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCF, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCD, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SCD, VEC_MIRROR, { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SMI, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SMF, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ TYPE_SMD, VEC_MEM,    { 0, 0, 0 }, FXP_DEFAULT_MODES },
	{ 0, 0, { 0, 0, 0 }, 0 }
};

/*---------------------------------------------------------------
 * FUNCTION:  OvAlloc
 * DESCRIPTION:  Allocate a Ovector
 * RETURN VALUE:  pointer to allocated Ovector
 * NOTES/WARNINGS: exits when out of memory.
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 */
Ovector OvAlloc(i_numelem, sp_props)
long		i_numelem;
Objprops	sp_props;
{
	long	size;
	Ovector	ret_vector;
/*
 *  Allocate the vector header
 */
	ret_vector = OvAllocHdr(sp_props);
/*
 *  Allocate the vector data
 */
	size = Osizeof(ret_vector->properties) * i_numelem;
	ret_vector->start = Oalloc(ret_vector->properties->mem_loc, size);
/*
 *  Fill in the rest of the structure.
 */
	ret_vector->virtstart = ret_vector->curr_loc = ret_vector->start;
	ret_vector->virtend = ret_vector->end = ret_vector->start + size;
	ret_vector->length = i_numelem;
/*
 *  Check if we need to fill with floating point zero
 */
	switch(ret_vector->properties->type) {
	      case TYPE_SRD:
	      case TYPE_VRD:
		Dvfill(0.0, ret_vector);
		break;
	}
	ret_vector->curr_loc = ret_vector->start;
/*
 *  Give it back
 */
	return ret_vector;
}



/*---------------------------------------------------------------
 * FUNCTION:  OvAllocHdr
 * DESCRIPTION:  Allocate a vector header.
 * RETURN VALUE:  vector header
 * NOTES/WARNINGS: 
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 */
Ovector OvAllocHdr(sp_props)
Objprops	sp_props;
{
	Ovector	ret_vector;
/*
 *  Check on default properties
 */
	if (sp_props == NULL) sp_props = def_Objprops;
/*
 *  Allocate the vector header
 */
	ret_vector = (Ovector) Oalloc(sp_props->mem_loc, sizeof(*ret_vector));
	ret_vector->stepsize = Osizeof(sp_props);
	ret_vector->properties = sp_props;

	return ret_vector;
}

/*---------------------------------------------------------------
 * FUNCTION:  OvConvert
 * DESCRIPTION:
 *	vect = OvConvert(dp_data, i_length, sp_prop)
 *
 *  Converts data pointer 'dp_data' into an Ovector of
 *  length 'i_length' with data type and determined by
 *  properties structure 'sp_prop'.
 *
 * RETURN VALUE:  The converted Ovector
 * NOTES/WARNINGS: 
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 */
Ovector OvConvert(dp_data, i_length, sp_prop)
Data		dp_data;
int		i_length;
Objprops	sp_prop;
{
	Ovector	ret;
	long	size;
/*
 *  Get the vector header
 */
	ret = OvAllocHdr(sp_prop);
	size = Osizeof(ret->properties);
/*
 *  Set structure elements
 */
	ret->virtstart = ret->curr_loc = dp_data;
	ret->virtend = ret->end = dp_data + size * i_length;
	ret->length = i_length;
/*
 *  Send it back
 */
	return ret;
}

	
/*---------------------------------------------------------------
 * FUNCTION:  ObjPropDefault
 * DESCRIPTION:  Get the default Objprops for a given type
 * RETURN VALUE:  the default Objprops.
 * NOTES/WARNINGS: 
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 */
Objprops ObjPropDefault(type, mem, bits, exp, format)
DATA_TYPE	type;
int		mem;
short		bits, exp, format;
{
	Objprops	list = def_Objprops;
	
	while (list->type != 0) {
		if (list->type == type) {
			list->mem_loc = mem;
			return list;
		}
		list++;
	}
	
	printf("Unknown type in ObjPropDefault!!\n");
	exit(1);
}

⌨️ 快捷键说明

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