diff CircuitNetlistCreator.c @ 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 df53f52ef49c 561d3a06ffc5
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