changeset 24:b924d86f829e

works in sequential mode
author Sean <seanhalle@yahoo.com>
date Thu, 17 May 2012 20:42:24 +0200
parents c11c48758df3
children b1c9d67643f2
files CircuitNetlistCreator.c HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h HWSim__PingPong__HWDef/PingPongElem_Activities.c main.c
diffstat 4 files changed, 76 insertions(+), 77 deletions(-) [+]
line diff
     1.1 --- a/CircuitNetlistCreator.c	Tue May 15 06:15:34 2012 -0700
     1.2 +++ b/CircuitNetlistCreator.c	Thu May 17 20:42:24 2012 +0200
     1.3 @@ -9,15 +9,12 @@
     1.4   
     1.5  /* is an expr resolves to an actual commPath struct instance
     1.6   */
     1.7 -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\
     1.8 -                             timeFnPtr, dataPtr)\
     1.9 +#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort)\
    1.10  do{\
    1.11     commPath->idxOfFromElem     = fromElIdx; \
    1.12     commPath->idxOfFromOutPort  = outPort; \
    1.13     commPath->idxOfToElem       = toElIdx; \
    1.14     commPath->idxOfToInPort     = inPort; \
    1.15 -   commPath->commTimeCalcFn     = timeFnPtr;\
    1.16 -   commPath->archSpecCommPathData  = dataPtr; \
    1.17   }while(0); //macro magic for namespace
    1.18  
    1.19  
    1.20 @@ -51,76 +48,85 @@
    1.21     int32 numCommPaths;
    1.22     
    1.23     netlist = malloc( sizeof(HWSimNetlist) );
    1.24 -  	numElems= 2; 
    1.25 +   numElems= 2; 
    1.26     elems = malloc( numElems * sizeof(HWSimElem *) );
    1.27     netlist->numElems = numElems;
    1.28     netlist->elems    = elems;
    1.29     netlist->numActivityTypes = 1;
    1.30     netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*));
    1.31 -	// Stefan: tocheck valgrind
    1.32 +
    1.33     netlist->activityTypes[PING_PONG_ACTIVITY] = createPingPongActivityType();
    1.34  	
    1.35 -   elems[0] = createAPingPongElem( netlist ); //use info from netlist
    1.36 +   elems[0] = createAPingPongElem( netlist ); //use activity types from netlist
    1.37     elems[1] = createAPingPongElem( netlist ); 
    1.38 -      //on one of the elems, make reset trigger an action   
    1.39 -	//Stefan: FIXME
    1.40 +   
    1.41 +      //make reset trigger an action on one of the elements
    1.42     elems[1]->inPorts[-1].triggeredActivityType =
    1.43 -              netlist->activityTypes[PING_PONG_ACTIVITY]; //Connect elems together
    1.44 +              netlist->activityTypes[PING_PONG_ACTIVITY];
    1.45  			  
    1.46 -	/*OutPorts and InPorts may have many commPaths attached.
    1.47 +   /*OutPorts and InPorts may have many commPaths attached.
    1.48      *  but an inPort only     
    1.49 -	 * has one kind of activity that all incoming communications trigger.  That
    1.50 -	 * activity can be zero time and then switch on the type of message then
    1.51 -	 * end with a continuation, where the continuation activity is chosen by the    
    1.52 -	 * switch. 
    1.53 -	 *So, a commPath only connects an out port to an in port
    1.54 -	 *The format is: sending TL-index, out-port, dest TL-index, in-port
    1.55 -	 */
    1.56 +    * has one kind of activity that all incoming communications trigger.  That
    1.57 +    * activity can be zero time and then switch on the type of message then
    1.58 +    * end with a continuation, where the continuation activity is chosen by the    
    1.59 +    * switch. 
    1.60 +    *So, a commPath only connects an out port to an in port
    1.61 +    *The format is: sending elem-index, out-port, dest elem-index, in-port
    1.62 +    */
    1.63     numCommPaths          = 2;
    1.64     commPaths             = malloc( numCommPaths * sizeof(HWSimCommPath *) );
    1.65     netlist->numCommPaths= numCommPaths;
    1.66     netlist->commPaths= commPaths;
    1.67 -      //TL 0, out-port 0 to TL 1, in-port 0
    1.68 -	commPaths[0]= malloc(sizeof(HWSimCommPath));
    1.69 -	setCommPathValuesTo(commPaths[0],0,0,1,0, commPath_TimeSpanCalc, NULL); 
    1.70 -      //TL 1, out-port 0 to TL 0, in-port 0
    1.71 -	commPaths[1]= malloc(sizeof(HWSimCommPath));
    1.72 -   setCommPathValuesTo(commPaths[1], 1,0,0,0, commPath_TimeSpanCalc, NULL);
    1.73 +      //elem 0, out-port 0 to elem 1, in-port 0
    1.74 +   commPaths[0]= malloc(sizeof(HWSimCommPath));
    1.75 +   setCommPathValuesTo(commPaths[0],0,0,1,0);
    1.76 +   commPaths[0]->hasFixedTiming  = TRUE;
    1.77 +   commPaths[0]->fixedFlightTime = 10; //all time is stated in (integer) units
    1.78 +
    1.79 +      //elem 1, out-port 0 to elem 0, in-port 0
    1.80 +   commPaths[1]= malloc(sizeof(HWSimCommPath));
    1.81 +   setCommPathValuesTo(commPaths[1], 1,0,0,0);
    1.82 +   commPaths[1]->hasFixedTiming  = TRUE;
    1.83 +   commPaths[1]->fixedFlightTime = 10; //all time is stated in (integer) units
    1.84     
    1.85 -   //TODO: decide how do in-out bidirectional commPaths -- thinking make it two
    1.86 -   // separate commPaths with guard between in-port and out-port
    1.87 +   //TODO: decide how to do bidirectional commPaths, like connection to a bus
    1.88 +   // thinking make it two separate commPaths with guard between in-port and out-port
    1.89  
    1.90  	return netlist;
    1.91   }
    1.92  
    1.93 +
    1.94 +/*
    1.95 + */
    1.96  void
    1.97  freePingPongNetlist (HWSimNetlist *netlist) 
    1.98 -{
    1.99 -	int i;
   1.100 -	for (i= 0; i<netlist->numCommPaths; i++) {
   1.101 -		free(netlist->commPaths[i]);
   1.102 -	}	
   1.103 -	free(netlist->commPaths);
   1.104 -	for (i= 0; i<netlist->numElems; i++) {
   1.105 -		free(&netlist->elems[i]->inPorts[-1]);
   1.106 -		free(netlist->elems[i]);
   1.107 -	}
   1.108 + { int i;
   1.109 + 
   1.110 +   for( i = 0; i < netlist->numCommPaths; i++ )
   1.111 +    { free(netlist->commPaths[i]);
   1.112 +    }	
   1.113 +   free(netlist->commPaths);
   1.114 +   for( i= 0; i < netlist->numElems; i++ ) 
   1.115 +    { HWSim_ext__free_inPortsArray( netlist->elems[i]->inPorts );
   1.116 +      free(netlist->elems[i]->outPorts);
   1.117 +      free(netlist->elems[i]);
   1.118 +    }
   1.119  
   1.120 -	free(netlist->activityTypes);
   1.121 -	free(netlist->elems);
   1.122 -	free(netlist);
   1.123 -}
   1.124 +   free(netlist->activityTypes);
   1.125 +   free(netlist->elems);
   1.126 +   free(netlist);
   1.127 + }
   1.128   
   1.129  HWSimElem *
   1.130  createAPingPongElem( HWSimNetlist *netlist )
   1.131 - { HWSimElem *TL;
   1.132 -   TL = malloc( sizeof(HWSimElem) );
   1.133 -   TL->numInPorts  = 1;
   1.134 -   TL->numOutPorts = 1;
   1.135 -   TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts );
   1.136 -   TL->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port
   1.137 -   TL->inPorts[0].triggeredActivityType  = netlist->activityTypes[PING_PONG_ACTIVITY];
   1.138 -	return TL;
   1.139 + { HWSimElem *elem;
   1.140 +   elem = malloc( sizeof(HWSimElem) );
   1.141 +   elem->numInPorts  = 1;
   1.142 +   elem->numOutPorts = 1;
   1.143 +   elem->inPorts = HWSim_ext__make_inPortsArray( elem->numInPorts );
   1.144 +   elem->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port
   1.145 +   elem->inPorts[0].triggeredActivityType  = netlist->activityTypes[PING_PONG_ACTIVITY];
   1.146 +	return elem;
   1.147   }
   1.148   
   1.149  HWSimActivityType *
   1.150 @@ -128,9 +134,9 @@
   1.151   { HWSimActivityType *pingPongActivityType;
   1.152     pingPongActivityType = malloc( sizeof(HWSimActivityType) );
   1.153     
   1.154 -   pingPongActivityType->hasBehavior   = true;
   1.155 -   pingPongActivityType->hasTiming     = true;
   1.156 -   pingPongActivityType->timingIsFixed = true;
   1.157 +   pingPongActivityType->hasBehavior   = TRUE;
   1.158 +   pingPongActivityType->hasTiming     = TRUE;
   1.159 +   pingPongActivityType->timingIsFixed = TRUE;
   1.160     pingPongActivityType->fixedTime     = 10;
   1.161     pingPongActivityType->behaviorFn    = &pingPongElem_PingActivity_behavior;
   1.162     return pingPongActivityType;
     2.1 --- a/HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h	Tue May 15 06:15:34 2012 -0700
     2.2 +++ b/HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h	Thu May 17 20:42:24 2012 +0200
     2.3 @@ -19,20 +19,16 @@
     2.4  //Different activityTypes
     2.5  #define PING_PONG_ACTIVITY 0
     2.6  
     2.7 -
     2.8 +#define dbgHW true
     2.9  //==============================  Structures  ==============================
    2.10 -typedef struct
    2.11 - { 
    2.12 - }
    2.13 -PingPongParams;
    2.14  
    2.15  
    2.16  //============================= Activity Functions =========================
    2.17 -void *
    2.18 -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *timeLine );
    2.19 +void
    2.20 +pingPongElem_PingActivity_behavior( HWSimActivityInst *activityInst );
    2.21  
    2.22 -uint64
    2.23 -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn );
    2.24 +HWSimTimeSpan
    2.25 +pingPongElem_PingActivity_timing( HWSimActivityInst *activityInst );
    2.26  
    2.27  HWSimTimeSpan
    2.28  commPath_TimeSpanCalc( HWSimCommPath *commPath, HWSimActivityInst *sendingActivity );
     3.1 --- a/HWSim__PingPong__HWDef/PingPongElem_Activities.c	Tue May 15 06:15:34 2012 -0700
     3.2 +++ b/HWSim__PingPong__HWDef/PingPongElem_Activities.c	Thu May 17 20:42:24 2012 +0200
     3.3 @@ -24,19 +24,21 @@
     3.4  #define NO_MSG NULL
     3.5  #define PORT0 0
     3.6  
     3.7 -/*
     3.8 - *Note, the returned value is passed to the timing function
     3.9 +/*All behavior functions take a ptr to the activity instance they are 
    3.10 + * executing the behavior of.
    3.11   */
    3.12 -void *
    3.13 -pingPongElem_PingActivity_behavior( HWSimElem *elem )
    3.14 - {          DEBUG_printf( dbgHW, "ping pong activity\n" );
    3.15 +void
    3.16 +pingPongElem_PingActivity_behavior( HWSimActivityInst *activityInst )
    3.17 + {          DEBUG__printf( dbgHW, "ping pong activity\n" );
    3.18  
    3.19 -   HWSim__send_on_port( NO_MSG, PORT0, elem );
    3.20 -	return NULL;
    3.21 +   HWSim__send_comm_on_port_and_idle( NO_MSG, PORT0, activityInst );
    3.22   }
    3.23  
    3.24 +/*All timing of activity functions take a ptr to the activity instance they are 
    3.25 + * calculating the timing of.
    3.26 + */
    3.27  HWSimTimeSpan
    3.28 -pingPongElem_PingActivity_timing( HWSimElem *elem )
    3.29 +pingPongElem_PingActivity_timing( HWSimActivityInst *activityInst )
    3.30   {
    3.31     return 10;
    3.32   }
     4.1 --- a/main.c	Tue May 15 06:15:34 2012 -0700
     4.2 +++ b/main.c	Thu May 17 20:42:24 2012 +0200
     4.3 @@ -10,14 +10,11 @@
     4.4  
     4.5  #include "SimParams.h"
     4.6  #include "HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h"
     4.7 -#include "../C_Libraries/ParamHelper/Param.h"
     4.8 +#include "ParamHelper/Param.h"
     4.9  
    4.10 -#include "../VMS_Implementations/HWSim_impl/HWSim_tests.h"
    4.11 +#include "HWSim_impl/HWSim_tests.h"
    4.12  
    4.13  
    4.14 -char __ProgrammName[] = "HWSim Hello World";
    4.15 -char __DataSet[255];
    4.16 -char __Scheduler[1];
    4.17  
    4.18  /*
    4.19   *
    4.20 @@ -36,10 +33,8 @@
    4.21      printf("Paraver trace file %s\n", argv[2]);
    4.22  
    4.23  #else
    4.24 -
    4.25 -     //TODO use the pure C branch of paramBag
    4.26 -       simParams = makeParamBag();
    4.27 -       readParamFileIntoBag( argv[1], simParams );
    4.28 +   simParams = makeParamBag();
    4.29 +   readParamFileIntoBag( argv[1], simParams );
    4.30  #endif
    4.31  
    4.32      netlist = createPingPongNetlist();