changeset 14:ddd87abfeefd

Changed Timeline to Element and Span to Activity, and fixed includes in app code
author Me@portablequad
date Sat, 11 Feb 2012 16:59:18 -0800
parents abe3db0025d5
children 8d9d367e96f9
files CircuitNetlistCreator.c HWSim__Hello_World_HW/FakeSim.c HWSim__Hello_World_HW/HWSim__Hello_World_HW.h HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt HWSim__Hello_World_HW/PingPong_TimeLine.c HWSim__PingPong__HWDef/CommPath_TimeSpan_Fns.c HWSim__PingPong__HWDef/FakeSim.c HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h HWSim__PingPong__HWDef/HW_DESIGN_NOTES.txt HWSim__PingPong__HWDef/PingPongElem_Activities.c SimParams.h main.c
diffstat 12 files changed, 324 insertions(+), 285 deletions(-) [+]
line diff
     1.1 --- a/CircuitNetlistCreator.c	Wed Feb 01 17:54:13 2012 +0100
     1.2 +++ b/CircuitNetlistCreator.c	Sat Feb 11 16:59:18 2012 -0800
     1.3 @@ -5,101 +5,105 @@
     1.4   * Author: seanhalle@yahoo.com
     1.5   *
     1.6   */
     1.7 - #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h"
     1.8 +#include "HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h"
     1.9   
    1.10 -/*'wire' is an expr resolves to an actual wire struct instance
    1.11 +/*'' is an expr resolves to an actual commPath struct instance
    1.12   */
    1.13 -#define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\
    1.14 +#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\
    1.15 +                             commTimeFnPtr, dataPtr)\
    1.16  do{\
    1.17 -   wire->idxOfFromTimeline = fromTLIdx; \
    1.18 -   wire->idxOfFromOutPort  = fromTLIdx; \
    1.19 -   wire->idxOfToTimeline   = toTLIdx; \
    1.20 -   wire->idxOfToInPort     = inPort; \
    1.21 -   wire->archSpecCommPathData  = dataPtr; \
    1.22 +   commPath->idxOfFromElem     = fromElIdx; \
    1.23 +   commPath->idxOfFromOutPort  = fromElIdx; \
    1.24 +   commPath->idxOfToElem       = toElIdx; \
    1.25 +   commPath->idxOfToInPort     = inPort; \
    1.26 +   commPath->commTimeFnPtr     = commTimeFnPtr;\
    1.27 +   commPath->archSpecCommPathData  = dataPtr; \
    1.28   }while(0); //macro magic for namespace
    1.29  
    1.30  
    1.31 -HWSimSpanType* createPingPongSpanType (); 
    1.32 +HWSimActivityType* createPingPongActivityType (); 
    1.33  
    1.34 -HWSimTimeline* createAPingPongTimeline (HWSimNetlist *netlist);
    1.35 +HWSimElem* createAPingPongElem (HWSimNetlist *netlist);
    1.36  
    1.37  /*This file constructs the netlist for the Hello World circuit, which is
    1.38   * used during design and implementation of the HWSim language
    1.39   *
    1.40 - *It has two timelines, each with one input port and one output port, and
    1.41 - * a single span-type.
    1.42 + *It has two elements, each with one input port and one output port, and
    1.43 + * a single activity-type.
    1.44   *
    1.45 - *The timelines are cross-coupled, so output port of one connects to input
    1.46 + *The elements are cross-coupled, so output port of one connects to input
    1.47   * port of the other.  The input port has a single trigger, which fires
    1.48 - * the one span-type.
    1.49 + * the one activity-type.
    1.50   *
    1.51 - *The span does nothing, except send a NULL message on the output port.
    1.52 - *The span-sim-time and communication-sim-time are both constants.
    1.53 + *The activity does nothing, except send a NULL message on the output port.
    1.54 + *The activity-sim-time and communication-sim-time are both constants.
    1.55   *
    1.56 - *Note that timelines are generic.  They are specialized by declaring
    1.57 + *Note that elements are generic.  They are specialized by declaring
    1.58   * inports and outports, and by registering triggers that fire particular
    1.59 - * span-types.
    1.60 + * activity-types.
    1.61   */
    1.62  HWSimNetlist *createPingPongNetlist()
    1.63   { HWSimNetlist   *netlist;
    1.64 -   HWSimCommPath  **wires;
    1.65 -   HWSimTimeline **timelines;
    1.66 -   int32 numTimelines;
    1.67 -   int32 numWires;
    1.68 -	HWSimSpanType *foo;
    1.69 +   HWSimCommPath  **commPaths;
    1.70 +   HWSimElem **elems;
    1.71 +   int32 numElems;
    1.72 +   int32 numCommPaths;
    1.73 +	HWSimActivityType *foo;
    1.74     
    1.75     netlist = malloc( sizeof(HWSimNetlist) );
    1.76 -   //declare timelines   numTimelines = 2;
    1.77 -   timelines = malloc( numTimelines * sizeof(HWSimTimeline) );
    1.78 -   netlist->numTimelines = numTimelines;
    1.79 -   netlist->timelines    = timelines;
    1.80 -   netlist->numSpanTypes = 1;
    1.81 -   netlist->spanTypes = malloc(netlist->numSpanTypes*sizeof(HWSimSpanType*));
    1.82 -   netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType();
    1.83 -   timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist
    1.84 -   timelines[1] = createAPingPongTimeline( netlist ); 
    1.85 -      //on one of the timelines, make reset trigger an action   
    1.86 -   timelines[1]->inPorts[-1].triggeredSpanType =
    1.87 -              netlist->spanTypes[PING_PONG_TYPE]; //Connect timelines together
    1.88 +   //declare elems   numElems = 2;
    1.89 +   elems = malloc( numElems * sizeof(HWSimElem) );
    1.90 +   netlist->numElems = numElems;
    1.91 +   netlist->elems    = elems;
    1.92 +   netlist->numActivityTypes = 1;
    1.93 +   netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*));
    1.94 +   netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType();
    1.95 +   elems[0] = createAPingPongElem( netlist ); //use info from netlist
    1.96 +   elems[1] = createAPingPongElem( netlist ); 
    1.97 +      //on one of the elems, make reset trigger an action   
    1.98 +   elems[1]->inPorts[-1].triggeredActivityType =
    1.99 +              netlist->activityTypes[PING_PONG_TYPE]; //Connect elems together
   1.100  			  
   1.101 -	/*OutPorts and InPorts may have many wires attached, but an inPort only     
   1.102 -	 * has one kind of span that all incoming communications trigger.  That
   1.103 -	 * span can be zero time and then switch on the type of message then
   1.104 -	 * end with a continuation, where the continuation span is chosen by the    
   1.105 +	/*OutPorts and InPorts may have many commPaths attached.
   1.106 +    *  but an inPort only     
   1.107 +	 * has one kind of activity that all incoming communications trigger.  That
   1.108 +	 * activity can be zero time and then switch on the type of message then
   1.109 +	 * end with a continuation, where the continuation activity is chosen by the    
   1.110  	 * switch. 
   1.111 -	 *So, a wire only connects an out port to an in port
   1.112 +	 *So, a commPath only connects an out port to an in port
   1.113  	 *The format is: sending TL-index, out-port, dest TL-index, in-port
   1.114  	 */
   1.115 -   numWires          = 2;
   1.116 -   wires             = malloc( numWires * sizeof(HWSimCommPath) );
   1.117 -   netlist->numCommPaths= numWires;
   1.118 -   netlist->commPaths= wires;
   1.119 -   //TL 0, out-port 0 to TL 1, in-port 0
   1.120 -   setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into
   1.121 -   setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create
   1.122 -   //TODO: decide how do in-out bidirectional wires -- thinking make it two
   1.123 -   // separate wires with guard between in-port and out-port
   1.124 -   //TODO: decide how do guards between ports
   1.125 +   numCommPaths          = 2;
   1.126 +   commPaths             = malloc( numCommPaths * sizeof(HWSimCommPath) );
   1.127 +   netlist->numCommPaths= numCommPaths;
   1.128 +   netlist->commPaths= commPaths;
   1.129 +      //TL 0, out-port 0 to TL 1, in-port 0
   1.130 +   setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); 
   1.131 +      //TL 1, out-port 0 to TL 0, in-port 0
   1.132 +   setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL);
   1.133 +   
   1.134 +   //TODO: decide how do in-out bidirectional commPaths -- thinking make it two
   1.135 +   // separate commPaths with guard between in-port and out-port
   1.136   }
   1.137   
   1.138 -   //Note: copy netlist struct with VMS malloc after VMS initialized
   1.139 -HWSimTimeline *
   1.140 -createAPingPongTimeline( HWSimNetlist *netlist )
   1.141 - { HWSimTimeline *TL;
   1.142 -   TL = malloc( sizeof(HWSimTimeline) );
   1.143 +   //Stefan: copy netlist struct with VMS malloc after VMS initialized?
   1.144 +HWSimElem *
   1.145 +createAPingPongElem( HWSimNetlist *netlist )
   1.146 + { HWSimElem *TL;
   1.147 +   TL = malloc( sizeof(HWSimElem) );
   1.148     TL->numInPorts  = 1;
   1.149     TL->numOutPorts = 1;
   1.150     TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts );
   1.151 -   TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port
   1.152 -   TL->inPorts[0].triggeredSpanType  = netlist->spanTypes[PING_PONG_TYPE];
   1.153 +   TL->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port
   1.154 +   TL->inPorts[0].triggeredActivityType  = netlist->activityTypes[PING_PONG_TYPE];
   1.155   }
   1.156   
   1.157 -HWSimSpanType *
   1.158 -createPingPongSpanType( )
   1.159 - { HWSimSpanType *pingPongSpanType;
   1.160 -   pingPongSpanType = malloc( sizeof(HWSimSpanType) );
   1.161 -   pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span;
   1.162 -   pingPongSpanType->timingFn   = &timingOf_ping_pong_span;
   1.163 -   return pingPongSpanType;
   1.164 +HWSimActivityType *
   1.165 +createPingPongActivityType( )
   1.166 + { HWSimActivityType *pingPongActivityType;
   1.167 +   pingPongActivityType = malloc( sizeof(HWSimActivityType) );
   1.168 +   pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior;
   1.169 +   pingPongActivityType->timingFn   = &pingPongElem_PingActivity_timing;
   1.170 +   return pingPongActivityType;
   1.171   } 
   1.172   
     2.1 --- a/HWSim__Hello_World_HW/FakeSim.c	Wed Feb 01 17:54:13 2012 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,126 +0,0 @@
     2.4 -#include <stdlib.h>
     2.5 -#include "HWSim__Hello_World_HW.h"
     2.6 -
     2.7 -void checkMalloc (void *ptr) {
     2.8 -	if (ptr == NULL) {
     2.9 -		printf("Memory allocation failed!\n");
    2.10 -		exit(1);
    2.11 -	}
    2.12 -}
    2.13 -
    2.14 -HWSimTimeline* malloc_timlines (int nrTimelines) {
    2.15 -	HWSimTimeline *timelines;
    2.16 -	int i;
    2.17 -
    2.18 -	timelines= malloc(nrTimelines*(sizeof(HWSimTimeline)));
    2.19 -	checkMalloc(timelines);
    2.20 -	for (i= 0; i<nrTimelines; i++) {
    2.21 -		timelines[i].animatingVP= malloc(sizeof(VirtProcr));
    2.22 -		checkMalloc(timelines[i].animatingVP);
    2.23 -	}
    2.24 -	return timelines;
    2.25 -}
    2.26 -
    2.27 -HWSimResults* malloc_simResults (int nrExecutions, int nrComms) {
    2.28 -	HWSimResults *simResults;
    2.29 -	int i;
    2.30 -	
    2.31 -	
    2.32 -	simResults= malloc(sizeof(HWSimResults));
    2.33 -	checkMalloc(simResults);
    2.34 -
    2.35 -	simResults->numTimelines= nrExecutions;
    2.36 -	simResults->timelineTraces= 
    2.37 -		malloc(simResults->numTimelines*sizeof(HWSimTimelineTrace *));
    2.38 -
    2.39 -	for (i= 0; i<simResults->numTimelines; i++) {
    2.40 -		simResults->timelineTraces[i]= malloc(sizeof(HWSimTimelineTrace));
    2.41 -		checkMalloc(simResults->timelineTraces[i]);
    2.42 -		simResults->timelineTraces[i]->spanRecs= malloc(sizeof(HWSimSpanRec));
    2.43 -	}
    2.44 -
    2.45 -	simResults->numCommTraces= nrComms;
    2.46 -	simResults->commTraces= 
    2.47 -		malloc(simResults->numCommTraces*sizeof(HWSimWireTrace *));
    2.48 -	checkMalloc(simResults->commTraces);
    2.49 -	for (i= 0; i<simResults->numCommTraces; i++) {
    2.50 -		simResults->commTraces[i]= malloc(sizeof(HWSimWireTrace));
    2.51 -		checkMalloc(simResults->commTraces[i]);
    2.52 -		// FRAGILE -> valgrind
    2.53 -		simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec));
    2.54 -		checkMalloc(simResults->commTraces[i]->commRecs);
    2.55 -	}
    2.56 -
    2.57 -	return simResults;
    2.58 -}
    2.59 -
    2.60 -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) {
    2.61 -	HWSimResults *simResults;
    2.62 -
    2.63 -	simResults= malloc_simResults(4,3);
    2.64 -
    2.65 -	//--------------- timelineTraces ------------------------------------
    2.66 -	// 2 times a ping span
    2.67 -	simResults->timelineTraces[0]->timeline= netlist->timelines[0]; 
    2.68 -	simResults->timelineTraces[0]->spanRecs->spanSeqNum= 0; // unique ???
    2.69 -	simResults->timelineTraces[0]->spanRecs->startTime= 1;
    2.70 -	simResults->timelineTraces[0]->spanRecs->endTime=2;
    2.71 -
    2.72 -	simResults->timelineTraces[1]->timeline= netlist->timelines[0]; 
    2.73 -	simResults->timelineTraces[1]->spanRecs->spanSeqNum= 1;
    2.74 -	simResults->timelineTraces[1]->spanRecs->startTime= 5;
    2.75 -	simResults->timelineTraces[1]->spanRecs->endTime=6;
    2.76 -
    2.77 -	// 2 times a pong span
    2.78 -	simResults->timelineTraces[2]->timeline= netlist->timelines[1];
    2.79 -	simResults->timelineTraces[2]->spanRecs->spanSeqNum= 2; // unique ???
    2.80 -	simResults->timelineTraces[2]->spanRecs->startTime= 3;
    2.81 -	simResults->timelineTraces[2]->spanRecs->endTime=4;
    2.82 -
    2.83 -	simResults->timelineTraces[3]->timeline= netlist->timelines[1]; 
    2.84 -	simResults->timelineTraces[3]->spanRecs->spanSeqNum= 3;
    2.85 -	simResults->timelineTraces[3]->spanRecs->startTime= 7;
    2.86 -	simResults->timelineTraces[3]->spanRecs->endTime=8;
    2.87 -
    2.88 -
    2.89 -	// a HWSimTimeline does not contain any helpful additional information to
    2.90 -	// identify or label a Timeline .
    2.91 -	// But a unique Timeline identifier is disireable. Therefore at the moment the
    2.92 -	// procrID of the anumating Procr ist used
    2.93 -
    2.94 -	// Information about the Span is required, at least a ID.The current
    2.95 -	// spanType doesn't provide it
    2.96 -
    2.97 -
    2.98 -	//--------------------  Coomunication Trace ---------------------
    2.99 -
   2.100 -	//ping to pong 2 - 3 
   2.101 -	simResults->commTraces[0]->fromTimeline= netlist->timelines[0];
   2.102 -	simResults->commTraces[0]->toTimeline= netlist->timelines[1];
   2.103 -	simResults->commTraces[0]->numComms= 1;
   2.104 -	simResults->commTraces[0]->commRecs->commID= 0;
   2.105 -	simResults->commTraces[0]->commRecs->msgID= 0;
   2.106 -	simResults->commTraces[0]->commRecs->startTime= 2;
   2.107 -	simResults->commTraces[0]->commRecs->endTime= 3;
   2.108 -
   2.109 -	//pong to ping 4 - 5 
   2.110 -	simResults->commTraces[1]->fromTimeline= netlist->timelines[1];
   2.111 -	simResults->commTraces[1]->toTimeline= netlist->timelines[0];
   2.112 -	simResults->commTraces[1]->numComms= 1;
   2.113 -	simResults->commTraces[1]->commRecs->commID= 1;
   2.114 -	simResults->commTraces[1]->commRecs->msgID= 1;
   2.115 -	simResults->commTraces[1]->commRecs->startTime= 4;
   2.116 -	simResults->commTraces[1]->commRecs->endTime= 5;
   2.117 -
   2.118 -	//ping to pong 6 - 7 
   2.119 -	simResults->commTraces[2]->fromTimeline= netlist->timelines[0];
   2.120 -	simResults->commTraces[2]->toTimeline= netlist->timelines[1];
   2.121 -	simResults->commTraces[2]->numComms= 1;
   2.122 -	simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec));
   2.123 -	simResults->commTraces[2]->commRecs->commID= 2;
   2.124 -	simResults->commTraces[2]->commRecs->msgID= 0;
   2.125 -	simResults->commTraces[2]->commRecs->startTime= 6;
   2.126 -	simResults->commTraces[2]->commRecs->endTime= 7;
   2.127 -
   2.128 -	return simResults;
   2.129 -}
     3.1 --- a/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h	Wed Feb 01 17:54:13 2012 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,48 +0,0 @@
     3.4 -/*
     3.5 - *  Copyright 2011 OpenSourceStewardshipFoundation.org
     3.6 - *  Licensed under GNU General Public License version 2
     3.7 - */
     3.8 -
     3.9 -
    3.10 -#ifndef _HWSim_TERAFLUX_H_
    3.11 -#define _HWSim_TERAFLUX_H_
    3.12 -
    3.13 -#include <stdio.h>
    3.14 -
    3.15 -#include "../../HWSim_lib/HWSim_lib.h"
    3.16 -
    3.17 -
    3.18 -//===============================  Defines  ==============================
    3.19 -   //Port 0 is unused, as a bug-catch
    3.20 -#define COMMUNICATOR_OUTPORT  1
    3.21 -
    3.22 -//Different spanTypes
    3.23 -#define PING_PONG_TYPE 0
    3.24 -
    3.25 -
    3.26 -//==============================  Structures  ==============================
    3.27 -typedef struct
    3.28 - { 
    3.29 - }
    3.30 -PingPongParams;
    3.31 -
    3.32 -
    3.33 -//============================= Span Functions =========================
    3.34 -void *
    3.35 -behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeLine );
    3.36 -
    3.37 -uint64
    3.38 -timingOf_ping_pong_span( void * dataFromBehaviorFn );
    3.39 -
    3.40 -//======================== Simulation Fake ==================================
    3.41 -#ifdef FAKE
    3.42 -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist);
    3.43 -#endif
    3.44 -
    3.45 -//======================== Netlist creation ==================================
    3.46 -
    3.47 -HWSimNetlist* createPingPongNetlist ();
    3.48 -
    3.49 -#endif /**/
    3.50 -
    3.51 -
     4.1 --- a/HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt	Wed Feb 01 17:54:13 2012 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,1 +0,0 @@
     4.4 -Implementing the hardware model
     4.5 
     4.6 
     4.7 This is the "hello world" for HWSim.  It is hardware that has just two timelines that send a message back and forth between them.  The message has no content, it simply triggers the other timeline, which then sends the same empty message back, repeating the cycle.
     4.8 
     4.9 Each timeline has one in-port and one out-port.  The out-port of the first timeline is connected to the in-port of the second and vice-versa.
    4.10 
    4.11 The code of the span consists only of sending an empty message on the timeline's out-port.
    4.12 
    4.13 The trigger for the span is registered on the in-port and message type 0.
    4.14 
    4.15 The span timing is a constant.
    4.16 
    4.17 The port-to-port timing is a constant.
    4.18 
    4.19 Both timelines are in the same time-domain.
    4.20 
    4.21 at_reset of one timeline is set to the ping-pong span, the other timeline's at_reset is set to idle.
    4.22 
    4.23 And that is the entire hardware.
    4.24 
    4.25 \ No newline at end of file
     5.1 --- a/HWSim__Hello_World_HW/PingPong_TimeLine.c	Wed Feb 01 17:54:13 2012 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,44 +0,0 @@
     5.4 -/*
     5.5 - *  Copyright 2011 OpenSourceStewardshipFoundation.org
     5.6 - *  Licensed under GNU General Public License version 2
     5.7 - *
     5.8 - * Author: seanhalle@yahoo.com
     5.9 - *
    5.10 - */
    5.11 -
    5.12 -#include "HWSim__Hello_World_HW.h"
    5.13 -
    5.14 -
    5.15 -
    5.16 -//====================================================================
    5.17 -/*This is the ping-pong timeline for the Hello World hardware
    5.18 - *
    5.19 - *It has only one kind of span, which only puts a communication on
    5.20 - * the timeline's one out-port.
    5.21 - * 
    5.22 - *The in-port has only one trigger registered on it, which fires that
    5.23 - * span.
    5.24 - */
    5.25 -
    5.26 -#define NO_MSG NULL
    5.27 -#define PORT0 0
    5.28 -
    5.29 -/*
    5.30 - *Note, the returned value is passed to the timing function
    5.31 - */
    5.32 -void *
    5.33 -behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeline )
    5.34 - {
    5.35 -   PingPongParams  *params;
    5.36 -   params    = (PingPongParams *)_params;
    5.37 -//         DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) );
    5.38 -   
    5.39 -//   HWSim__send_on_port( NO_MSG, PORT0, timeline );
    5.40 - }
    5.41 -
    5.42 -HWSimTimePeriod
    5.43 -timingOf_ping_pong_span( void * dataFromBehaviorFn )
    5.44 - {
    5.45 -   return 10;
    5.46 - }
    5.47 -
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/HWSim__PingPong__HWDef/CommPath_TimeSpan_Fns.c	Sat Feb 11 16:59:18 2012 -0800
     6.3 @@ -0,0 +1,35 @@
     6.4 +/*
     6.5 + *  Copyright 2011 OpenSourceStewardshipFoundation.org
     6.6 + *  Licensed under GNU General Public License version 2
     6.7 + *
     6.8 + * Author: seanhalle@yahoo.com
     6.9 + *
    6.10 + */
    6.11 +
    6.12 +#include "HWSim__PingPong__HWDef.h"
    6.13 +
    6.14 +
    6.15 +
    6.16 +//====================================================================
    6.17 +/*This is the ping-pong element for the Hello World hardware
    6.18 + *
    6.19 + *It has only one kind of activity, which only puts a communication on
    6.20 + * the element's one out-port.
    6.21 + * 
    6.22 + *The in-port has only one trigger registered on it, which fires that
    6.23 + * activity.
    6.24 + */
    6.25 +
    6.26 +#define NO_MSG NULL
    6.27 +#define PORT0 0
    6.28 +
    6.29 +/*
    6.30 + *Note, the returned value is passed to the timing function
    6.31 + */
    6.32 +HWSimTimeSpan
    6.33 +commPath_TimeSpanCalc( HWSimCommPath *commPath, HWSimActivityInst *sendingActivity )
    6.34 + {
    6.35 +//         DEBUG( dbgHW, "comm", debugInfoForCommPath(commPath), debugInfoForActivity(sendingActivity) );
    6.36 +   return 5;
    6.37 + }
    6.38 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/HWSim__PingPong__HWDef/FakeSim.c	Sat Feb 11 16:59:18 2012 -0800
     7.3 @@ -0,0 +1,126 @@
     7.4 +#include <stdlib.h>
     7.5 +#include "HWSim__PingPong__HWDef.h"
     7.6 +
     7.7 +void checkMalloc (void *ptr) {
     7.8 +	if (ptr == NULL) {
     7.9 +		printf("Memory allocation failed!\n");
    7.10 +		exit(1);
    7.11 +	}
    7.12 +}
    7.13 +
    7.14 +HWSimElem* malloc_timlines (int nrElems) {
    7.15 +	HWSimElem *elems;
    7.16 +	int i;
    7.17 +
    7.18 +	elems= malloc(nrElems*(sizeof(HWSimElem)));
    7.19 +	checkMalloc(elems);
    7.20 +	for (i= 0; i<nrElems; i++) {
    7.21 +		elems[i].animatingVP= malloc(sizeof(VirtProcr));
    7.22 +		checkMalloc(elems[i].animatingVP);
    7.23 +	}
    7.24 +	return elems;
    7.25 +}
    7.26 +
    7.27 +HWSimResults* malloc_simResults (int nrExecutions, int nrComms) {
    7.28 +	HWSimResults *simResults;
    7.29 +	int i;
    7.30 +	
    7.31 +	
    7.32 +	simResults= malloc(sizeof(HWSimResults));
    7.33 +	checkMalloc(simResults);
    7.34 +
    7.35 +	simResults->numElems= nrExecutions;
    7.36 +	simResults->elemTraces= 
    7.37 +		malloc(simResults->numElems*sizeof(HWSimElemTrace *));
    7.38 +
    7.39 +	for (i= 0; i<simResults->numElems; i++) {
    7.40 +		simResults->elemTraces[i]= malloc(sizeof(HWSimElemTrace));
    7.41 +		checkMalloc(simResults->elemTraces[i]);
    7.42 +		simResults->elemTraces[i]->activityRecs= malloc(sizeof(HWSimActivityRec));
    7.43 +	}
    7.44 +
    7.45 +	simResults->numCommTraces= nrComms;
    7.46 +	simResults->commTraces= 
    7.47 +		malloc(simResults->numCommTraces*sizeof(HWSimCommPathTrace *));
    7.48 +	checkMalloc(simResults->commTraces);
    7.49 +	for (i= 0; i<simResults->numCommTraces; i++) {
    7.50 +		simResults->commTraces[i]= malloc(sizeof(HWSimCommPathTrace));
    7.51 +		checkMalloc(simResults->commTraces[i]);
    7.52 +		// FRAGILE -> valgrind
    7.53 +		simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec));
    7.54 +		checkMalloc(simResults->commTraces[i]->commRecs);
    7.55 +	}
    7.56 +
    7.57 +	return simResults;
    7.58 +}
    7.59 +
    7.60 +HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) {
    7.61 +	HWSimResults *simResults;
    7.62 +
    7.63 +	simResults= malloc_simResults(4,3);
    7.64 +
    7.65 +	//--------------- elemTraces ------------------------------------
    7.66 +	// 2 times a ping activity
    7.67 +	simResults->elemTraces[0]->elem= netlist->elems[0]; 
    7.68 +	simResults->elemTraces[0]->activityRecs->activitySeqNum= 0; // unique ???
    7.69 +	simResults->elemTraces[0]->activityRecs->startTime= 1;
    7.70 +	simResults->elemTraces[0]->activityRecs->endTime=2;
    7.71 +
    7.72 +	simResults->elemTraces[1]->elem= netlist->elems[0]; 
    7.73 +	simResults->elemTraces[1]->activityRecs->activitySeqNum= 1;
    7.74 +	simResults->elemTraces[1]->activityRecs->startTime= 5;
    7.75 +	simResults->elemTraces[1]->activityRecs->endTime=6;
    7.76 +
    7.77 +	// 2 times a pong activity
    7.78 +	simResults->elemTraces[2]->elem= netlist->elems[1];
    7.79 +	simResults->elemTraces[2]->activityRecs->activitySeqNum= 2; // unique ???
    7.80 +	simResults->elemTraces[2]->activityRecs->startTime= 3;
    7.81 +	simResults->elemTraces[2]->activityRecs->endTime=4;
    7.82 +
    7.83 +	simResults->elemTraces[3]->elem= netlist->elems[1]; 
    7.84 +	simResults->elemTraces[3]->activityRecs->activitySeqNum= 3;
    7.85 +	simResults->elemTraces[3]->activityRecs->startTime= 7;
    7.86 +	simResults->elemTraces[3]->activityRecs->endTime=8;
    7.87 +
    7.88 +
    7.89 +	// a HWSimElem does not contain any helpful additional information to
    7.90 +	// identify or label a Element .
    7.91 +	// But a unique Element identifier is disireable. Therefore at the moment the
    7.92 +	// procrID of the anumating Procr ist used
    7.93 +
    7.94 +	// Information about the Activity is required, at least a ID.The current
    7.95 +	// activityType doesn't provide it
    7.96 +
    7.97 +
    7.98 +	//--------------------  Coomunication Trace ---------------------
    7.99 +
   7.100 +	//ping to pong 2 - 3 
   7.101 +	simResults->commTraces[0]->fromElem= netlist->elems[0];
   7.102 +	simResults->commTraces[0]->toElem= netlist->elems[1];
   7.103 +	simResults->commTraces[0]->numComms= 1;
   7.104 +	simResults->commTraces[0]->commRecs->commID= 0;
   7.105 +	simResults->commTraces[0]->commRecs->msgID= 0;
   7.106 +	simResults->commTraces[0]->commRecs->startTime= 2;
   7.107 +	simResults->commTraces[0]->commRecs->endTime= 3;
   7.108 +
   7.109 +	//pong to ping 4 - 5 
   7.110 +	simResults->commTraces[1]->fromElem= netlist->elems[1];
   7.111 +	simResults->commTraces[1]->toElem= netlist->elems[0];
   7.112 +	simResults->commTraces[1]->numComms= 1;
   7.113 +	simResults->commTraces[1]->commRecs->commID= 1;
   7.114 +	simResults->commTraces[1]->commRecs->msgID= 1;
   7.115 +	simResults->commTraces[1]->commRecs->startTime= 4;
   7.116 +	simResults->commTraces[1]->commRecs->endTime= 5;
   7.117 +
   7.118 +	//ping to pong 6 - 7 
   7.119 +	simResults->commTraces[2]->fromElem= netlist->elems[0];
   7.120 +	simResults->commTraces[2]->toElem= netlist->elems[1];
   7.121 +	simResults->commTraces[2]->numComms= 1;
   7.122 +	simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec));
   7.123 +	simResults->commTraces[2]->commRecs->commID= 2;
   7.124 +	simResults->commTraces[2]->commRecs->msgID= 0;
   7.125 +	simResults->commTraces[2]->commRecs->startTime= 6;
   7.126 +	simResults->commTraces[2]->commRecs->endTime= 7;
   7.127 +
   7.128 +	return simResults;
   7.129 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h	Sat Feb 11 16:59:18 2012 -0800
     8.3 @@ -0,0 +1,48 @@
     8.4 +/*
     8.5 + *  Copyright 2011 OpenSourceStewardshipFoundation.org
     8.6 + *  Licensed under GNU General Public License version 2
     8.7 + */
     8.8 +
     8.9 +
    8.10 +#ifndef _HWSim_TERAFLUX_H_
    8.11 +#define _HWSim_TERAFLUX_H_
    8.12 +
    8.13 +#include <stdio.h>
    8.14 +
    8.15 +#include "../../VMS_Implementations/HWSim_impl/HWSim_lib.h"
    8.16 +
    8.17 +
    8.18 +//===============================  Defines  ==============================
    8.19 +   //Port 0 is unused, as a bug-catch
    8.20 +#define COMMUNICATOR_OUTPORT  1
    8.21 +
    8.22 +//Different activityTypes
    8.23 +#define PING_PONG_TYPE 0
    8.24 +
    8.25 +
    8.26 +//==============================  Structures  ==============================
    8.27 +typedef struct
    8.28 + { 
    8.29 + }
    8.30 +PingPongParams;
    8.31 +
    8.32 +
    8.33 +//============================= Activity Functions =========================
    8.34 +void *
    8.35 +pingPongElem_PingActivity_behavior( void *_params, HWSimElem *timeLine );
    8.36 +
    8.37 +uint64
    8.38 +pingPongElem_PingActivity_timing( void * dataFromBehaviorFn );
    8.39 +
    8.40 +//======================== Simulation Fake ==================================
    8.41 +#ifdef FAKE
    8.42 +HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist);
    8.43 +#endif
    8.44 +
    8.45 +//======================== Netlist creation ==================================
    8.46 +
    8.47 +HWSimNetlist* createPingPongNetlist ();
    8.48 +
    8.49 +#endif /**/
    8.50 +
    8.51 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/HWSim__PingPong__HWDef/HW_DESIGN_NOTES.txt	Sat Feb 11 16:59:18 2012 -0800
     9.3 @@ -0,0 +1,1 @@
     9.4 +Implementing the hardware model
     9.5 
     9.6 
     9.7 This is the "hello world" for HWSim.  It is hardware that has just two elements that send a message back and forth between them.  The message has no content, it simply triggers the other element, which then sends the same empty message back, repeating the cycle.
     9.8 
     9.9 Each element has one in-port and one out-port.  The out-port of the first element is connected to the in-port of the second and vice-versa.
    9.10 
    9.11 The code of the activity consists only of sending an empty message on the element's out-port.
    9.12 
    9.13 The trigger for the activity is registered on the in-port and message type 0.
    9.14 
    9.15 The activity timing is a constant.
    9.16 
    9.17 The port-to-port timing is a constant.
    9.18 
    9.19 Both elements are in the same time-domain.
    9.20 
    9.21 at_reset of one element is set to the ping-pong activity, the other element's at_reset is set to idle.
    9.22 
    9.23 And that is the entire hardware.
    9.24 
    9.25 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/HWSim__PingPong__HWDef/PingPongElem_Activities.c	Sat Feb 11 16:59:18 2012 -0800
    10.3 @@ -0,0 +1,44 @@
    10.4 +/*
    10.5 + *  Copyright 2011 OpenSourceStewardshipFoundation.org
    10.6 + *  Licensed under GNU General Public License version 2
    10.7 + *
    10.8 + * Author: seanhalle@yahoo.com
    10.9 + *
   10.10 + */
   10.11 +
   10.12 +#include "HWSim__PingPong__HWDef.h"
   10.13 +
   10.14 +
   10.15 +
   10.16 +//====================================================================
   10.17 +/*This is the ping-pong element for the Hello World hardware
   10.18 + *
   10.19 + *It has only one kind of activity, which only puts a communication on
   10.20 + * the element's one out-port.
   10.21 + * 
   10.22 + *The in-port has only one trigger registered on it, which fires that
   10.23 + * activity.
   10.24 + */
   10.25 +
   10.26 +#define NO_MSG NULL
   10.27 +#define PORT0 0
   10.28 +
   10.29 +/*
   10.30 + *Note, the returned value is passed to the timing function
   10.31 + */
   10.32 +void *
   10.33 +pingPongElem_PingActivity_behavior( void *_params, HWSimElem *elem )
   10.34 + {
   10.35 +   PingPongParams  *params;
   10.36 +   params    = (PingPongParams *)_params;
   10.37 +//         DEBUG( dbgHW, "ping pong activity\n", clone_PingPongParams(params) );
   10.38 +   
   10.39 +//   HWSim__send_on_port( NO_MSG, PORT0, elem );
   10.40 + }
   10.41 +
   10.42 +HWSimTimeSpan
   10.43 +pingPongElem_PingActivity_timing( void * dataFromBehaviorFn )
   10.44 + {
   10.45 +   return 10;
   10.46 + }
   10.47 +
    11.1 --- a/SimParams.h	Wed Feb 01 17:54:13 2012 +0100
    11.2 +++ b/SimParams.h	Sat Feb 11 16:59:18 2012 -0800
    11.3 @@ -10,7 +10,7 @@
    11.4  #include <unistd.h>
    11.5  #include <malloc.h>
    11.6  
    11.7 -#include "../HWSim_lib/VMS/VMS_primitive_data_types.h"
    11.8 +#include "../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
    11.9  #include "ParamHelper/Param.h"
   11.10  
   11.11  
    12.1 --- a/main.c	Wed Feb 01 17:54:13 2012 +0100
    12.2 +++ b/main.c	Sat Feb 11 16:59:18 2012 -0800
    12.3 @@ -9,7 +9,7 @@
    12.4  #include <stdlib.h>
    12.5  
    12.6  #include "SimParams.h"
    12.7 -#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h"
    12.8 +#include "HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h"
    12.9  
   12.10  char __ProgrammName[] = "HWSim Hello World";
   12.11  char __DataSet[255];