# HG changeset patch # User Sean # Date 1337280144 -7200 # Node ID b924d86f829e5c1c7f4220669762ead9044c2e8d # Parent c11c48758df3617819e8149997840cb686b9a8a3 works in sequential mode diff -r c11c48758df3 -r b924d86f829e CircuitNetlistCreator.c --- a/CircuitNetlistCreator.c Tue May 15 06:15:34 2012 -0700 +++ b/CircuitNetlistCreator.c Thu May 17 20:42:24 2012 +0200 @@ -9,15 +9,12 @@ /* is an expr resolves to an actual commPath struct instance */ -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ - timeFnPtr, dataPtr)\ +#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort)\ do{\ commPath->idxOfFromElem = fromElIdx; \ commPath->idxOfFromOutPort = outPort; \ commPath->idxOfToElem = toElIdx; \ commPath->idxOfToInPort = inPort; \ - commPath->commTimeCalcFn = timeFnPtr;\ - commPath->archSpecCommPathData = dataPtr; \ }while(0); //macro magic for namespace @@ -51,76 +48,85 @@ int32 numCommPaths; netlist = malloc( sizeof(HWSimNetlist) ); - numElems= 2; + numElems= 2; elems = malloc( numElems * sizeof(HWSimElem *) ); netlist->numElems = numElems; netlist->elems = elems; netlist->numActivityTypes = 1; netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); - // Stefan: tocheck valgrind + netlist->activityTypes[PING_PONG_ACTIVITY] = createPingPongActivityType(); - elems[0] = createAPingPongElem( netlist ); //use info from netlist + elems[0] = createAPingPongElem( netlist ); //use activity types from netlist elems[1] = createAPingPongElem( netlist ); - //on one of the elems, make reset trigger an action - //Stefan: FIXME + + //make reset trigger an action on one of the elements elems[1]->inPorts[-1].triggeredActivityType = - netlist->activityTypes[PING_PONG_ACTIVITY]; //Connect elems together + netlist->activityTypes[PING_PONG_ACTIVITY]; - /*OutPorts and InPorts may have many commPaths attached. + /*OutPorts and InPorts may have many commPaths attached. * but an inPort only - * has one kind of activity that all incoming communications trigger. That - * activity can be zero time and then switch on the type of message then - * end with a continuation, where the continuation activity is chosen by the - * switch. - *So, a commPath only connects an out port to an in port - *The format is: sending TL-index, out-port, dest TL-index, in-port - */ + * has one kind of activity that all incoming communications trigger. That + * activity can be zero time and then switch on the type of message then + * end with a continuation, where the continuation activity is chosen by the + * switch. + *So, a commPath only connects an out port to an in port + *The format is: sending elem-index, out-port, dest elem-index, in-port + */ numCommPaths = 2; commPaths = malloc( numCommPaths * sizeof(HWSimCommPath *) ); netlist->numCommPaths= numCommPaths; netlist->commPaths= commPaths; - //TL 0, out-port 0 to TL 1, in-port 0 - commPaths[0]= malloc(sizeof(HWSimCommPath)); - setCommPathValuesTo(commPaths[0],0,0,1,0, commPath_TimeSpanCalc, NULL); - //TL 1, out-port 0 to TL 0, in-port 0 - commPaths[1]= malloc(sizeof(HWSimCommPath)); - setCommPathValuesTo(commPaths[1], 1,0,0,0, commPath_TimeSpanCalc, NULL); + //elem 0, out-port 0 to elem 1, in-port 0 + commPaths[0]= malloc(sizeof(HWSimCommPath)); + setCommPathValuesTo(commPaths[0],0,0,1,0); + commPaths[0]->hasFixedTiming = TRUE; + commPaths[0]->fixedFlightTime = 10; //all time is stated in (integer) units + + //elem 1, out-port 0 to elem 0, in-port 0 + commPaths[1]= malloc(sizeof(HWSimCommPath)); + setCommPathValuesTo(commPaths[1], 1,0,0,0); + commPaths[1]->hasFixedTiming = TRUE; + commPaths[1]->fixedFlightTime = 10; //all time is stated in (integer) units - //TODO: decide how do in-out bidirectional commPaths -- thinking make it two - // separate commPaths with guard between in-port and out-port + //TODO: decide how to do bidirectional commPaths, like connection to a bus + // thinking make it two separate commPaths with guard between in-port and out-port return netlist; } + +/* + */ void freePingPongNetlist (HWSimNetlist *netlist) -{ - int i; - for (i= 0; inumCommPaths; i++) { - free(netlist->commPaths[i]); - } - free(netlist->commPaths); - for (i= 0; inumElems; i++) { - free(&netlist->elems[i]->inPorts[-1]); - free(netlist->elems[i]); - } + { int i; + + for( i = 0; i < netlist->numCommPaths; i++ ) + { free(netlist->commPaths[i]); + } + free(netlist->commPaths); + for( i= 0; i < netlist->numElems; i++ ) + { HWSim_ext__free_inPortsArray( netlist->elems[i]->inPorts ); + free(netlist->elems[i]->outPorts); + free(netlist->elems[i]); + } - free(netlist->activityTypes); - free(netlist->elems); - free(netlist); -} + free(netlist->activityTypes); + free(netlist->elems); + free(netlist); + } HWSimElem * createAPingPongElem( HWSimNetlist *netlist ) - { HWSimElem *TL; - TL = malloc( sizeof(HWSimElem) ); - TL->numInPorts = 1; - TL->numOutPorts = 1; - TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); - TL->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port - TL->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_ACTIVITY]; - return TL; + { HWSimElem *elem; + elem = malloc( sizeof(HWSimElem) ); + elem->numInPorts = 1; + elem->numOutPorts = 1; + elem->inPorts = HWSim_ext__make_inPortsArray( elem->numInPorts ); + elem->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port + elem->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_ACTIVITY]; + return elem; } HWSimActivityType * @@ -128,9 +134,9 @@ { HWSimActivityType *pingPongActivityType; pingPongActivityType = malloc( sizeof(HWSimActivityType) ); - pingPongActivityType->hasBehavior = true; - pingPongActivityType->hasTiming = true; - pingPongActivityType->timingIsFixed = true; + pingPongActivityType->hasBehavior = TRUE; + pingPongActivityType->hasTiming = TRUE; + pingPongActivityType->timingIsFixed = TRUE; pingPongActivityType->fixedTime = 10; pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior; return pingPongActivityType; diff -r c11c48758df3 -r b924d86f829e HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h --- a/HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h Tue May 15 06:15:34 2012 -0700 +++ b/HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h Thu May 17 20:42:24 2012 +0200 @@ -19,20 +19,16 @@ //Different activityTypes #define PING_PONG_ACTIVITY 0 - +#define dbgHW true //============================== Structures ============================== -typedef struct - { - } -PingPongParams; //============================= Activity Functions ========================= -void * -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *timeLine ); +void +pingPongElem_PingActivity_behavior( HWSimActivityInst *activityInst ); -uint64 -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn ); +HWSimTimeSpan +pingPongElem_PingActivity_timing( HWSimActivityInst *activityInst ); HWSimTimeSpan commPath_TimeSpanCalc( HWSimCommPath *commPath, HWSimActivityInst *sendingActivity ); diff -r c11c48758df3 -r b924d86f829e HWSim__PingPong__HWDef/PingPongElem_Activities.c --- a/HWSim__PingPong__HWDef/PingPongElem_Activities.c Tue May 15 06:15:34 2012 -0700 +++ b/HWSim__PingPong__HWDef/PingPongElem_Activities.c Thu May 17 20:42:24 2012 +0200 @@ -24,19 +24,21 @@ #define NO_MSG NULL #define PORT0 0 -/* - *Note, the returned value is passed to the timing function +/*All behavior functions take a ptr to the activity instance they are + * executing the behavior of. */ -void * -pingPongElem_PingActivity_behavior( HWSimElem *elem ) - { DEBUG_printf( dbgHW, "ping pong activity\n" ); +void +pingPongElem_PingActivity_behavior( HWSimActivityInst *activityInst ) + { DEBUG__printf( dbgHW, "ping pong activity\n" ); - HWSim__send_on_port( NO_MSG, PORT0, elem ); - return NULL; + HWSim__send_comm_on_port_and_idle( NO_MSG, PORT0, activityInst ); } +/*All timing of activity functions take a ptr to the activity instance they are + * calculating the timing of. + */ HWSimTimeSpan -pingPongElem_PingActivity_timing( HWSimElem *elem ) +pingPongElem_PingActivity_timing( HWSimActivityInst *activityInst ) { return 10; } diff -r c11c48758df3 -r b924d86f829e main.c --- a/main.c Tue May 15 06:15:34 2012 -0700 +++ b/main.c Thu May 17 20:42:24 2012 +0200 @@ -10,14 +10,11 @@ #include "SimParams.h" #include "HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h" -#include "../C_Libraries/ParamHelper/Param.h" +#include "ParamHelper/Param.h" -#include "../VMS_Implementations/HWSim_impl/HWSim_tests.h" +#include "HWSim_impl/HWSim_tests.h" -char __ProgrammName[] = "HWSim Hello World"; -char __DataSet[255]; -char __Scheduler[1]; /* * @@ -36,10 +33,8 @@ printf("Paraver trace file %s\n", argv[2]); #else - - //TODO use the pure C branch of paramBag - simParams = makeParamBag(); - readParamFileIntoBag( argv[1], simParams ); + simParams = makeParamBag(); + readParamFileIntoBag( argv[1], simParams ); #endif netlist = createPingPongNetlist();