📄 noc_vc_queue.pr.c
字号:
/* Process model C form file: NOC_VC_queue.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_VC_queue_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 4397FE24 4397FE24 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 */
#define ARRIVAL op_intrpt_type () == OPC_INTRPT_STRM
#define SERVICE op_intrpt_type () == OPC_INTRPT_ACCESS
/* 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 */
int vc1 ;
int vc2 ;
int vc3 ;
int vc4 ;
int input1 ;
int input2 ;
int input3 ;
int input4 ;
int input5 ;
int vc_max ;
} NOC_VC_queue_state;
#define pr_state_ptr ((NOC_VC_queue_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define vc1 pr_state_ptr->vc1
#define vc2 pr_state_ptr->vc2
#define vc3 pr_state_ptr->vc3
#define vc4 pr_state_ptr->vc4
#define input1 pr_state_ptr->input1
#define input2 pr_state_ptr->input2
#define input3 pr_state_ptr->input3
#define input4 pr_state_ptr->input4
#define input5 pr_state_ptr->input5
#define vc_max pr_state_ptr->vc_max
/* 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_VC_queue_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_VC_queue_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC NOC_VC_queue_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 NOC_VC_queue (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype NOC_VC_queue_init (int * init_block_ptr);
VosT_Address NOC_VC_queue_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void NOC_VC_queue_diag (OP_SIM_CONTEXT_ARG_OPT);
void NOC_VC_queue_terminate (OP_SIM_CONTEXT_ARG_OPT);
void NOC_VC_queue_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_VC_queue (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (NOC_VC_queue ());
{
/* Temporary Variables */
Packet *pkptr;
Packet *out_pkt;
int vc_id;
int input_id;
int vc;
int input;
int head;
int dest_x;
int dest_y;
/* End of Temporary Variables */
FSM_ENTER ("NOC_VC_queue")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (INS_TAIL) enter executives **/
FSM_STATE_ENTER_UNFORCED (0, "INS_TAIL", state0_enter_exec, "NOC_VC_queue [INS_TAIL enter execs]")
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [INS_TAIL enter execs]", state0_enter_exec)
{
/* a new packet has arrived; acquire it */
pkptr = op_pk_get (op_intrpt_strm ());
/* Decide whether it is a data flit or control packet */
if (op_pk_total_size_get(pkptr) == 17)
{
op_pk_nfd_get_int32 (pkptr, "vc_id", &vc_id);
op_pk_nfd_get_int32 (pkptr, "input_id", &input_id);
switch(vc_id)
{
case 1: vc = vc1;break;
case 2: vc = vc2;break;
case 3: vc = vc3;break;
case 4: vc = vc4;break;
}
switch(input_id)
{
case 1: input = input1;break;
case 2: input = input2;break;
case 3: input = input3;break;
case 4: input = input4;break;
case 5: input = input5;break;
}
if(vc * input > vc_max)
vc_max = vc * input;
}
if (op_pk_total_size_get(pkptr) == 8)
{
op_pk_nfd_get_int32 (pkptr, "head", &head);
op_pk_nfd_get_int32 (pkptr, "dest_x", &dest_x);
op_pk_nfd_get_int32 (pkptr, "dest_y", &dest_y);
if(head == 1)
{
out_pkt = op_pk_create_fmt("NOC_ctr_packet");
op_pk_nfd_set_int32 (pkptr, "dest_x",dest_x);
op_pk_nfd_set_int32 (pkptr, "dest_y",dest_y);
op_pk_nfd_set_int32 (pkptr, "for_bak",0);
op_pk_send (out_pkt,0);
}
/* insert the new packet at tail of subqueue 0 */
if (op_subq_pk_insert (0, pkptr, OPC_QPOS_TAIL) !=
OPC_QINS_OK)
{
/* if the insertion failed, discard the packet */
op_pk_destroy (pkptr);
}
}
}
FSM_PROFILE_SECTION_OUT (state0_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (1,"NOC_VC_queue")
/** state (INS_TAIL) exit executives **/
FSM_STATE_EXIT_UNFORCED (0, "INS_TAIL", "NOC_VC_queue [INS_TAIL exit execs]")
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [INS_TAIL exit execs]", state0_exit_exec)
{
/* a new packet has arrived; acquire it */
pkptr = op_pk_get (op_intrpt_strm ());
if (op_pk_total_size_get(pkptr) == 17)
{
op_pk_nfd_get_int32 (pkptr, "vc_id", &vc_id);
op_pk_nfd_get_int32 (pkptr, "input_id", &input_id);
switch(vc_id)
{
case 1: vc = vc1;break;
case 2: vc = vc2;break;
case 3: vc = vc3;break;
case 4: vc = vc4;break;
}
switch(input_id)
{
case 1: input = input1;break;
case 2: input = input2;break;
case 3: input = input3;break;
case 4: input = input4;break;
case 5: input = input5;break;
}
if (vc * input != vc_max)
{
op_pk_nfd_set_int32 (pkptr, "vc_1", 0);
op_pk_nfd_set_int32 (pkptr, "vc_2", 0);
op_pk_nfd_set_int32 (pkptr, "vc_3", 0);
op_pk_nfd_set_int32 (pkptr, "vc_4", 0);
}
op_pk_send (pkptr,0);
}
}
FSM_PROFILE_SECTION_OUT (state0_exit_exec)
/** state (INS_TAIL) transition processing **/
FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "INS_TAIL", "BRANCH")
/*---------------------------------------------------------*/
/** state (SEND_HEAD) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "SEND_HEAD", state1_enter_exec, "NOC_VC_queue [SEND_HEAD enter execs]")
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [SEND_HEAD enter execs]", state1_enter_exec)
{
/* a request has been made to access the queue */
/* check if its empty */
if (!op_subq_empty (0))
{
/* access the first packet in the subqueue */
pkptr = op_subq_pk_remove (0, OPC_QPOS_HEAD);
/* forward it to the destination */
/* without causing a stream interrupt */
op_pk_send_quiet (pkptr, 0);
}
}
FSM_PROFILE_SECTION_OUT (state1_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"NOC_VC_queue")
/** state (SEND_HEAD) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "SEND_HEAD", "NOC_VC_queue [SEND_HEAD exit execs]")
/** state (SEND_HEAD) transition processing **/
FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "SEND_HEAD", "BRANCH")
/*---------------------------------------------------------*/
/** state (BRANCH) enter executives **/
FSM_STATE_ENTER_FORCED (2, "BRANCH", state2_enter_exec, "NOC_VC_queue [BRANCH enter execs]")
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [BRANCH enter execs]", state2_enter_exec)
{
vc1 = 1;
vc2 = 2;
vc3 = 3;
vc4 = 4;
input1 = 10;
input2 = 20;
input3 = 30;
input4 = 40;
input5 = 50;
vc_max = 0;
}
FSM_PROFILE_SECTION_OUT (state2_enter_exec)
/** state (BRANCH) exit executives **/
FSM_STATE_EXIT_FORCED (2, "BRANCH", "NOC_VC_queue [BRANCH exit execs]")
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [BRANCH exit execs]", state2_exit_exec)
{
}
FSM_PROFILE_SECTION_OUT (state2_exit_exec)
/** state (BRANCH) transition processing **/
FSM_PROFILE_SECTION_IN ("NOC_VC_queue [BRANCH trans conditions]", state2_trans_conds)
FSM_INIT_COND (SERVICE)
FSM_TEST_COND (ARRIVAL)
FSM_TEST_LOGIC ("BRANCH")
FSM_PROFILE_SECTION_OUT (state2_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "SERVICE", "", "BRANCH", "SEND_HEAD")
FSM_CASE_TRANSIT (1, 0, state0_enter_exec, ;, "ARRIVAL", "", "BRANCH", "INS_TAIL")
}
/*---------------------------------------------------------*/
}
FSM_EXIT (2,"NOC_VC_queue")
}
}
void
NOC_VC_queue_diag (OP_SIM_CONTEXT_ARG_OPT)
{
/* No Diagnostic Block */
}
void
NOC_VC_queue_terminate (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = __LINE__;
#endif
FIN_MT (NOC_VC_queue_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_VC_queue_svar function. */
#undef vc1
#undef vc2
#undef vc3
#undef vc4
#undef input1
#undef input2
#undef input3
#undef input4
#undef input5
#undef vc_max
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE
VosT_Obtype
NOC_VC_queue_init (int * init_block_ptr)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
VosT_Obtype obtype = OPC_NIL;
FIN_MT (NOC_VC_queue_init (init_block_ptr))
obtype = Vos_Define_Object_Prstate ("proc state vars (NOC_VC_queue)",
sizeof (NOC_VC_queue_state));
*init_block_ptr = 4;
FRET (obtype)
}
VosT_Address
NOC_VC_queue_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
NOC_VC_queue_state * ptr;
FIN_MT (NOC_VC_queue_alloc (obtype))
ptr = (NOC_VC_queue_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_VC_queue_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
{
NOC_VC_queue_state *prs_ptr;
FIN_MT (NOC_VC_queue_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
prs_ptr = (NOC_VC_queue_state *)gen_ptr;
if (strcmp ("vc1" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->vc1);
FOUT
}
if (strcmp ("vc2" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->vc2);
FOUT
}
if (strcmp ("vc3" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->vc3);
FOUT
}
if (strcmp ("vc4" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->vc4);
FOUT
}
if (strcmp ("input1" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->input1);
FOUT
}
if (strcmp ("input2" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->input2);
FOUT
}
if (strcmp ("input3" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->input3);
FOUT
}
if (strcmp ("input4" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->input4);
FOUT
}
if (strcmp ("input5" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->input5);
FOUT
}
if (strcmp ("vc_max" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->vc_max);
FOUT
}
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -