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

📄 tan_noc_worm_fifo_in_test.pr.c

📁 片上网络
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Process model C form file: tan_noc_worm_FIFO_in_test.pr.c */
/* Portions of this file copyright 1992-2004 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char tan_noc_worm_FIFO_in_test_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 49DD5377 49DD5377 1 05934b0918b5482 Administrator 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 */

#define  QUEUE_EMPTY        (op_q_empty())
#define  PK_NUM             (op_q_stat(OPC_QSTAT_PKSIZE))

#define  SVC_COMPLETION     op_intrpt_type() == OPC_INTRPT_SELF
#define  ARRIVAL            op_intrpt_type() == OPC_INTRPT_STRM
#define  FLOW_CONTROL       (op_intrpt_type() == OPC_INTRPT_STAT)

#define  NEXT_FIFO_ALLOW  0

/* 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 */
	double	                 		service_rate                                    ;
	Objid	                  		own_id                                          ;
	Stathandle	             		fifo_full                                       ;
	Stathandle	             		pk_destroy                                      ;
	int	                    		server_busy                                     ;
	int	                    		next                                            ;
	Stathandle	             		crossbar_busy                                   ;
	Stathandle	             		req                                             ;
	} tan_noc_worm_FIFO_in_test_state;

#define pr_state_ptr            		((tan_noc_worm_FIFO_in_test_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define service_rate            		pr_state_ptr->service_rate
#define own_id                  		pr_state_ptr->own_id
#define fifo_full               		pr_state_ptr->fifo_full
#define pk_destroy              		pr_state_ptr->pk_destroy
#define server_busy             		pr_state_ptr->server_busy
#define next                    		pr_state_ptr->next
#define crossbar_busy           		pr_state_ptr->crossbar_busy
#define req                     		pr_state_ptr->req

/* 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	tan_noc_worm_FIFO_in_test_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 = ((tan_noc_worm_FIFO_in_test_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	tan_noc_worm_FIFO_in_test_state *op_sv_ptr;
#  define FIN_PREAMBLE_CODE	op_sv_ptr = pr_state_ptr;
#endif


/* No Function Block */


#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif

/* 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 tan_noc_worm_FIFO_in_test (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype tan_noc_worm_FIFO_in_test_init (int * init_block_ptr);
	VosT_Address tan_noc_worm_FIFO_in_test_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
	void tan_noc_worm_FIFO_in_test_diag (OP_SIM_CONTEXT_ARG_OPT);
	void tan_noc_worm_FIFO_in_test_terminate (OP_SIM_CONTEXT_ARG_OPT);
	void tan_noc_worm_FIFO_in_test_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
tan_noc_worm_FIFO_in_test (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (tan_noc_worm_FIFO_in_test ());
		{
		/* Temporary Variables */
		Packet*          pkptr;
		OpT_Packet_Size  pk_len;
		double           pk_svc_time;
		int              insert_ok;
		
		int              dest_address;
		Vvec_Vector      err_vec;
		/* End of Temporary Variables */


		FSM_ENTER ("tan_noc_worm_FIFO_in_test")

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "tan_noc_worm_FIFO_in_test [init enter execs]")
				FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [init enter execs]", state0_enter_exec)
				{
				/* initially the server is idle 	*/
				server_busy = 0;
				
				/* get queue module's own object id	*/
				own_id = op_id_self ();
				  						
				/* get assigned value of server 	*/
				/* processing rate 					*/
				op_ima_obj_attr_get (own_id, "service_rate", &service_rate);
				
				
				
				
				
				
				
				
				/* regdit a stathand of Local fifo full */
				fifo_full = op_stat_reg ("FULL", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				pk_destroy = op_stat_reg ("PK_DES", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				crossbar_busy = op_stat_reg ("CRO_BUSY", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				req = op_stat_reg ("REQUEST", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				next = 0;
				//next_0 = 0;
				//next_1 = 0;
				//next_2 = 0;
				//next_3 = 0;
				//next_4 = 0;
				
				//dest_address = 0;
				}
				FSM_PROFILE_SECTION_OUT (state0_enter_exec)

			/** state (init) exit executives **/
			FSM_STATE_EXIT_FORCED (0, "init", "tan_noc_worm_FIFO_in_test [init exit execs]")


			/** state (init) transition processing **/
			FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [init trans conditions]", state0_trans_conds)
			FSM_INIT_COND (ARRIVAL)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("init")
			FSM_PROFILE_SECTION_OUT (state0_trans_conds)

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "ARRIVAL", "", "init", "arrival")
				FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "default", "", "init", "idle")
				}
				/*---------------------------------------------------------*/



			/** state (arrival) enter executives **/
			FSM_STATE_ENTER_FORCED (1, "arrival", state1_enter_exec, "tan_noc_worm_FIFO_in_test [arrival enter execs]")
				FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [arrival enter execs]", state1_enter_exec)
				{
				/* acquire the arriving packet 				*/
				/* multiple arriving streams are supported. */
				pkptr = op_pk_get (op_intrpt_strm ());
				
				
				
				//if (op_subq_stat (0,OPC_QSTAT_FREE_PKSIZE) == 0)
				//	fifo_full = 1;
				//else
				//	fifo_full = 0;
				//fifo_full = (op_subq_stat (0,OPC_QSTAT_FREE_PKSIZE) == 0);
				
				
				
				
				
				/* attempt to enqueue the packet at tail 	*/
				/* of subqueue 0.							*/
				if (op_subq_pk_insert (0, pkptr, OPC_QPOS_TAIL) != OPC_QINS_OK)
				    {
				    /* the inserton failed (due to to a 	*/
					/* full queue) deallocate the packet.	*/
				    op_pk_destroy (pkptr);
					
				    op_stat_write (pk_destroy, 1.0);
					
					/* set flag indicating insertion fail 	*/
					/* this flag is used to determine 		*/
					/* transition out of this state 		*/
				    insert_ok = 0;
				    }
				else{
					/* insertion was successful 			*/
				    insert_ok = 1;
				    }
				
				
				}
				FSM_PROFILE_SECTION_OUT (state1_enter_exec)

			/** state (arrival) exit executives **/
			FSM_STATE_EXIT_FORCED (1, "arrival", "tan_noc_worm_FIFO_in_test [arrival exit execs]")
				FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [arrival exit execs]", state1_exit_exec)
				{
				op_stat_write (fifo_full, (op_subq_stat (0,OPC_QSTAT_FREE_PKSIZE) == 0));
				}
				FSM_PROFILE_SECTION_OUT (state1_exit_exec)


			/** state (arrival) transition processing **/
			FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [arrival trans conditions]", state1_trans_conds)
			FSM_INIT_COND ((PK_NUM > 1)&&server_busy)
			FSM_TEST_COND (PK_NUM == 1)
			FSM_TEST_COND ((PK_NUM > 1)&&(!server_busy))
			FSM_TEST_LOGIC ("arrival")
			FSM_PROFILE_SECTION_OUT (state1_trans_conds)

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "(PK_NUM > 1)&&server_busy", "", "arrival", "idle")
				FSM_CASE_TRANSIT (1, 7, state7_enter_exec, ;, "PK_NUM == 1", "", "arrival", "req_get")
				FSM_CASE_TRANSIT (2, 5, state5_enter_exec, ;, "(PK_NUM > 1)&&(!server_busy)", "", "arrival", "wait")
				}
				/*---------------------------------------------------------*/



			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (2, "idle", state2_enter_exec, "tan_noc_worm_FIFO_in_test [idle enter execs]")

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (5,"tan_noc_worm_FIFO_in_test")


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (2, "idle", "tan_noc_worm_FIFO_in_test [idle exit execs]")


			/** state (idle) transition processing **/
			FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [idle trans conditions]", state2_trans_conds)
			FSM_INIT_COND (ARRIVAL)
			FSM_TEST_COND (SVC_COMPLETION)
			FSM_TEST_COND (FLOW_CONTROL)
			FSM_TEST_LOGIC ("idle")
			FSM_PROFILE_SECTION_OUT (state2_trans_conds)

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "ARRIVAL", "", "idle", "arrival")
				FSM_CASE_TRANSIT (1, 4, state4_enter_exec, ;, "SVC_COMPLETION", "", "idle", "svc_compl")
				FSM_CASE_TRANSIT (2, 6, state6_enter_exec, ;, "FLOW_CONTROL", "", "idle", "FLOW_CON")
				}
				/*---------------------------------------------------------*/



			/** state (svc_start) enter executives **/
			FSM_STATE_ENTER_FORCED (3, "svc_start", state3_enter_exec, "tan_noc_worm_FIFO_in_test [svc_start enter execs]")
				FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_in_test [svc_start enter execs]", state3_enter_exec)
				{
				/* get a handle on packet at head of subqueue 0 */
				/* (this does not remove the packet) 			*/
				
				
				pkptr = op_subq_pk_access (0, OPC_QPOS_HEAD);
				
				/* determine the packets length (in bits) 		*/
				pk_len = op_pk_total_size_get (pkptr);
				
				/* determine the time required to complete 		*/
				/* service of the packet 						*/
				pk_svc_time = (double) pk_len / service_rate;
				
				
				/*
				if(op_intrpt_type () == OPC_INTRPT_STAT)
					{
					if(op_intrpt_stat ()==NEXT_FIFO_FULL_0)
						if(op_stat_local_read (NEXT_FIFO_FULL_0) == 1)
				            next_0=1;
				        else
					        next_0=0;
					if(op_intrpt_stat ()==NEXT_FIFO_FULL_1)
						if(op_stat_local_read (NEXT_FIFO_FULL_1) == 1)
				            next_1=1;
				        else
					        next_1=0;	
					if(op_intrpt_stat ()==NEXT_FIFO_FULL_2)
						if(op_stat_local_read (NEXT_FIFO_FULL_2) == 1)
				            next_2=1;
				        else
					        next_2=0;	
					if(op_intrpt_stat ()==NEXT_FIFO_FULL_3)
						if(op_stat_local_read (NEXT_FIFO_FULL_3) == 1)
				            next_3=1;
				        else
					        next_3=0;	
					if(op_intrpt_stat ()==NEXT_FIFO_FULL_4)
						if(op_stat_local_read (NEXT_FIFO_FULL_4) == 1)
				            next_4=1;
				        else
					        next_4=0;	
					}
				
				*/
				
				if(op_intrpt_type() == OPC_INTRPT_STAT)
					{
						if(op_intrpt_stat() == NEXT_FIFO_ALLOW)
							if(op_stat_local_read(NEXT_FIFO_ALLOW) == 1)
								next = 1;
							else
								next = 0;
					}
				
				//op_pk_fd_get (pkptr, 0, &dest_address);

⌨️ 快捷键说明

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