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

📄 noc_tile_proc.pr.c

📁 opnet
💻 C
字号:
/* Process model C form file: NOC_Tile_proc.pr.c */
/* Portions of this file copyright 1992-2004 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char NOC_Tile_proc_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 4397FCAD 4397FCAD 1 ccslab-yy 严晔 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 a0a 3                                                                                                                                                                                                                                                                                                                                                                                                            ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */

/* packet stream definitions */
#define RCV_IN_STRM 1
#define SRC_IN_STRM 0
#define XMT_OUT_STRM 0

/* transition marcos */
#define SRC_ARRVL (op_intrpt_type ()==\
OPC_INTRPT_STRM && op_intrpt_strm () == SRC_IN_STRM)

#define RCV_ARRVL (op_intrpt_type () ==\
OPC_INTRPT_STRM && op_intrpt_strm () == RCV_IN_STRM)






/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define	BINIT
#endif /* #if !defined (VOSD_NO_FIN) */



/* State variable definitions */
typedef struct
	{
	/* Internal state tracking for FSM */
	FSM_SYS_STATE
	/* State Variables */
	Distribution *	         		address_dist_x                                  ;
	int	                    		counter                                         ;
	Stathandle	             		ete_gsh                                         ;
	Stathandle	             		throughput_gsh                                  ;
	int	                    		rcvd_pkts                                       ;
	Distribution *	         		address_dist_y                                  ;
	} NOC_Tile_proc_state;

#define pr_state_ptr            		((NOC_Tile_proc_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define address_dist_x          		pr_state_ptr->address_dist_x
#define counter                 		pr_state_ptr->counter
#define ete_gsh                 		pr_state_ptr->ete_gsh
#define throughput_gsh          		pr_state_ptr->throughput_gsh
#define rcvd_pkts               		pr_state_ptr->rcvd_pkts
#define address_dist_y          		pr_state_ptr->address_dist_y

/* These macro definitions will define a local variable called	*/
/* "op_sv_ptr" in each function containing a FIN statement.	*/
/* This variable points to the state variable data structure,	*/
/* and can be used from a C debugger to display their values.	*/
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#if defined (OPD_PARALLEL)
#  define FIN_PREAMBLE_DEC	NOC_Tile_proc_state *op_sv_ptr; OpT_Sim_Context * tcontext_ptr;
#  define FIN_PREAMBLE_CODE	\
		if (VosS_Mt_Perform_Lock) \
			VOS_THREAD_SPECIFIC_DATA_GET (VosI_Globals.simi_mt_context_data_key, tcontext_ptr, SimT_Context *); \
		else \
			tcontext_ptr = VosI_Globals.simi_sequential_context_ptr; \
		op_sv_ptr = ((NOC_Tile_proc_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	NOC_Tile_proc_state *op_sv_ptr;
#  define FIN_PREAMBLE_CODE	op_sv_ptr = pr_state_ptr;
#endif


/* Function Block */


#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif
static void xmt(void)
	{
	Packet *pkptr;
	FIN(xmt());
	pkptr = op_pk_get (SRC_IN_STRM);
	counter%=2;
	if (counter == 0)
	{
	address_dist_x = op_dist_load("uniform_int", 0,3);
	address_dist_y = op_dist_load("uniform_int", 0,3);
	
	op_pk_nfd_set_int32 (pkptr, "dest_x",
		(int)op_dist_outcome (address_dist_x));
	op_pk_nfd_set_int32 (pkptr, "dest_y",
		(int)op_dist_outcome (address_dist_y));
	op_pk_nfd_set_int32 (pkptr, "head",1);
	op_pk_nfd_set_int32 (pkptr, "tail",0);
	counter++;
	}
	if (counter == 1)
		{
		op_pk_nfd_set_int32 (pkptr, "dest_x",
		(int)op_dist_outcome (address_dist_x));
		op_pk_nfd_set_int32 (pkptr, "dest_y",
		(int)op_dist_outcome (address_dist_y));
	    op_pk_nfd_set_int32 (pkptr, "head",0);
	    op_pk_nfd_set_int32 (pkptr, "tail",1);
		counter++;
	     }
	op_pk_send (pkptr, XMT_OUT_STRM);
	
	FOUT;
	}

static void rcv(void)
	{
	Packet *pkptr;
	double ete_delay;
	double throughput;
	double cur_time;
	FIN (rcv());
	pkptr = op_pk_get (RCV_IN_STRM);
	if (op_pk_total_size_get(pkptr)== 8)
	{
	cur_time = op_sim_time ();
	++rcvd_pkts;
	ete_delay = op_sim_time () - op_pk_creation_time_get (pkptr);
	op_stat_write (ete_gsh, ete_delay);
	throughput = rcvd_pkts*256;
	op_stat_write (throughput_gsh, throughput);
	op_stat_write (throughput_gsh, 0.0);
	}
	op_pk_destroy (pkptr);
	FOUT;
	}
	
	
	
	
	
	

/* End of Function Block */

/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing.		  */
#undef FIN_TRACING
#define FIN_TRACING

#undef FOUTRET_TRACING
#define FOUTRET_TRACING

#if defined (__cplusplus)
extern "C" {
#endif
	void NOC_Tile_proc (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype NOC_Tile_proc_init (int * init_block_ptr);
	VosT_Address NOC_Tile_proc_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
	void NOC_Tile_proc_diag (OP_SIM_CONTEXT_ARG_OPT);
	void NOC_Tile_proc_terminate (OP_SIM_CONTEXT_ARG_OPT);
	void NOC_Tile_proc_svar (void *, const char *, void **);


	VosT_Obtype Vos_Define_Object_Prstate (const char * _op_name, unsigned int _op_size);
	VosT_Address Vos_Alloc_Object_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype _op_ob_hndl);
	VosT_Fun_Status Vos_Poolmem_Dealloc_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Address _op_ob_ptr);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
NOC_Tile_proc (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (NOC_Tile_proc ());
		{


		FSM_ENTER ("NOC_Tile_proc")

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (0, "idle", state0_enter_exec, "NOC_Tile_proc [idle enter execs]")

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (1,"NOC_Tile_proc")


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (0, "idle", "NOC_Tile_proc [idle exit execs]")


			/** state (idle) transition processing **/
			FSM_PROFILE_SECTION_IN ("NOC_Tile_proc [idle trans conditions]", state0_trans_conds)
			FSM_INIT_COND (RCV_ARRVL)
			FSM_TEST_COND (SRC_ARRVL)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("idle")
			FSM_PROFILE_SECTION_OUT (state0_trans_conds)

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 0, state0_enter_exec, rcv();, "RCV_ARRVL", "rcv()", "idle", "idle")
				FSM_CASE_TRANSIT (1, 0, state0_enter_exec, xmt();, "SRC_ARRVL", "xmt()", "idle", "idle")
				FSM_CASE_TRANSIT (2, 0, state0_enter_exec, ;, "default", "", "idle", "idle")
				}
				/*---------------------------------------------------------*/



			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (1, "init", "NOC_Tile_proc [init enter execs]")
				FSM_PROFILE_SECTION_IN ("NOC_Tile_proc [init enter execs]", state1_enter_exec)
				{
				ete_gsh = op_stat_reg ("ETE Delay",
					OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				
				throughput_gsh = op_stat_reg ("Throughput",
					OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				
				counter = 0;
				rcvd_pkts =0;
				}
				FSM_PROFILE_SECTION_OUT (state1_enter_exec)

			/** state (init) exit executives **/
			FSM_STATE_EXIT_FORCED (1, "init", "NOC_Tile_proc [init exit execs]")


			/** state (init) transition processing **/
			FSM_TRANSIT_FORCE (0, state0_enter_exec, ;, "default", "", "init", "idle")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (1,"NOC_Tile_proc")
		}
	}




void
NOC_Tile_proc_diag (OP_SIM_CONTEXT_ARG_OPT)
	{
	/* No Diagnostic Block */
	}




void
NOC_Tile_proc_terminate (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = __LINE__;
#endif

	FIN_MT (NOC_Tile_proc_terminate ())


	/* No Termination Block */

	Vos_Poolmem_Dealloc_MT (OP_SIM_CONTEXT_THREAD_INDEX_COMMA pr_state_ptr);

	FOUT
	}


/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in NOC_Tile_proc_svar function. */
#undef address_dist_x
#undef counter
#undef ete_gsh
#undef throughput_gsh
#undef rcvd_pkts
#undef address_dist_y

#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE

#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE

VosT_Obtype
NOC_Tile_proc_init (int * init_block_ptr)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	VosT_Obtype obtype = OPC_NIL;
	FIN_MT (NOC_Tile_proc_init (init_block_ptr))

	obtype = Vos_Define_Object_Prstate ("proc state vars (NOC_Tile_proc)",
		sizeof (NOC_Tile_proc_state));
	*init_block_ptr = 2;

	FRET (obtype)
	}

VosT_Address
NOC_Tile_proc_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	NOC_Tile_proc_state * ptr;
	FIN_MT (NOC_Tile_proc_alloc (obtype))

	ptr = (NOC_Tile_proc_state *)Vos_Alloc_Object_MT (VOS_THREAD_INDEX_COMMA obtype);
	if (ptr != OPC_NIL)
		ptr->_op_current_block = init_block;
	FRET ((VosT_Address)ptr)
	}



void
NOC_Tile_proc_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
	{
	NOC_Tile_proc_state		*prs_ptr;

	FIN_MT (NOC_Tile_proc_svar (gen_ptr, var_name, var_p_ptr))

	if (var_name == OPC_NIL)
		{
		*var_p_ptr = (void *)OPC_NIL;
		FOUT
		}
	prs_ptr = (NOC_Tile_proc_state *)gen_ptr;

	if (strcmp ("address_dist_x" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->address_dist_x);
		FOUT
		}
	if (strcmp ("counter" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->counter);
		FOUT
		}
	if (strcmp ("ete_gsh" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->ete_gsh);
		FOUT
		}
	if (strcmp ("throughput_gsh" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->throughput_gsh);
		FOUT
		}
	if (strcmp ("rcvd_pkts" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->rcvd_pkts);
		FOUT
		}
	if (strcmp ("address_dist_y" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->address_dist_y);
		FOUT
		}
	*var_p_ptr = (void *)OPC_NIL;

	FOUT
	}

⌨️ 快捷键说明

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