changeset 2:d872169e58fa

Minor changes -- mostly renaming structs and vars
author Me@portablequad
date Wed, 30 Nov 2011 08:40:30 -0800
parents 7566745e812a
children 0ef08e9afd54
files src/Application/CircuitNetlistCreator.c src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c src/Application/main.c
diffstat 3 files changed, 3 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/Application/CircuitNetlistCreator.c	Sat Nov 19 17:58:21 2011 -0800
     1.2 +++ b/src/Application/CircuitNetlistCreator.c	Wed Nov 30 08:40:30 2011 -0800
     1.3 @@ -1,1 +1,1 @@
     1.4 -/*
     1.5  *  Copyright 2011 OpenSourceStewardshipFoundation.org
     1.6  *  Licensed under GNU General Public License version 2
     1.7  *
     1.8  * Author: seanhalle@yahoo.com
     1.9  *
    1.10  */
    1.11 
    1.12 #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h"
    1.13 
    1.14 
    1.15 /*This file constructs the netlist for the Hello World circuit, which is
    1.16  * used during design and implementation of the HWSim language
    1.17  * 
    1.18  *It has two timelines, each with one input port and one output port, and
    1.19  * a single span-type.
    1.20  *
    1.21  *The timelines are cross-coupled, so output port of one connects to input
    1.22  * port of the other.  The input port has a single trigger, which fires
    1.23  * the one span-type.
    1.24  * 
    1.25  *The span does nothing, except send a NULL message on the output port.
    1.26  * 
    1.27  *The span-sim-time and communication-sim-time are both constants.
    1.28  *
    1.29  *Note that timelines are generic.  They are specialized by declaring
    1.30  * inports and outports, and by registering triggers that fire particular
    1.31  * span-types.
    1.32  */
    1.33 HWSimNetlist *
    1.34 createPingPongNetlist()
    1.35  { HWSimNetlist *netlist;
    1.36    HWSimWire   **wires;
    1.37    TimeLine    **timelines;
    1.38    
    1.39    int numTimelines;
    1.40    int numWires;
    1.41  
    1.42    netlist = malloc( sizeof(HWSimNetlist) );
    1.43    
    1.44       //declare timelines
    1.45    numTimelines = 2;
    1.46    timelines = malloc( numTimelines * sizeof(TimeLine) );
    1.47    netlist->numTimelines = numTimelines;
    1.48    netlist->timelines    = timelines;
    1.49    
    1.50    timelines[0] = createAPingPongTimeline();
    1.51    timelines[1] = createAPingPongTimeline();
    1.52    
    1.53       //add a trigger to reset port of one of the timelines, to start things
    1.54    HWSimSpanType *pingPongSpan;
    1.55    pingPongSpan = malloc( sizeof(HWSimSpanType) );
    1.56    pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span;
    1.57    pingPongSpan->timingFn   = &timingOf_ping_pong_span;
    1.58    
    1.59    timelines[1]->triggers[0]->inPortNum = -1//the reset port
    1.60    timelines[1]->triggers[0]->spanType = pingPongSpan;
    1.61    
    1.62       //Connect timelines together
    1.63    numWires = 2;
    1.64    wires = malloc( numWires * sizeof(HWSimWire) );
    1.65    netlist->numWires = numWires;
    1.66    netlist->wires    = wires;
    1.67    
    1.68    wires[0] = {0,0,1,0,0}; //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0
    1.69    wires[1] = {1,0,0,0,0};
    1.70 
    1.71 /* For starters, not doing time-domains..  will add later (Nov 2011)
    1.72       //Create time domains
    1.73    numTimeDomains = 2;
    1.74    timeDomains    = malloc( numTimeDomains * sizeof(TimeDomain) );
    1.75    netlist->numTimeDomains = numTimeDomains;
    1.76    netlist->timeDomains    = timeDomains;
    1.77    
    1.78    timeDomains[0]->numDomains   = 0;
    1.79    timeDomains[0]->numTimelines = 1;
    1.80    timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[]
    1.81    
    1.82    timeDomains[1]->numDomains   = 0;
    1.83    timeDomains[1]->numTimelines = 1;
    1.84    timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[]
    1.85    
    1.86       //Create time domain connections -- must respect hierarchy
    1.87    numDomainConnections = 2;
    1.88    domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) );
    1.89    netlist->numDomainConns = numDomainConnections;
    1.90    netlist->domainConns    = domainConnects;
    1.91    
    1.92    domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1
    1.93    domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0
    1.94  */
    1.95  }
    1.96 
    1.97 TimeLine *
    1.98 createAPingPongTimeline()
    1.99  { TimeLine *tl;
   1.100    HWSimTrigger **triggers;
   1.101    
   1.102    tl = malloc( sizeof(TimeLine) );
   1.103     
   1.104    tl->numInPorts  = 1;
   1.105    tl->numOutPorts = 1;
   1.106    tl->numTriggers = 2;
   1.107    
   1.108    triggers = malloc( 2 * sizeof(HWSimTrigger) ); //extra is reset trig
   1.109    tl->triggers[0].inPortNum = -1; //reset trigger
   1.110    tl->triggers[0].spanType = IDLE_SPAN;
   1.111    
   1.112    HWSimSpanType *pingPongSpan;
   1.113    pingPongSpan = malloc( sizeof(HWSimSpanType) );
   1.114    pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span;
   1.115    pingPongSpan->timingFn   = &timingOf_ping_pong_span;
   1.116    
   1.117    tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or ->
   1.118    tl->triggers[1].spanType = pingPongSpan;
   1.119  }
   1.120 \ No newline at end of file
   1.121 +/*
   1.122  *  Copyright 2011 OpenSourceStewardshipFoundation.org
   1.123  *  Licensed under GNU General Public License version 2
   1.124  *
   1.125  * Author: seanhalle@yahoo.com
   1.126  *
   1.127  */
   1.128 
   1.129 #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h"
   1.130 
   1.131 
   1.132 /*This file constructs the netlist for the Hello World circuit, which is
   1.133  * used during design and implementation of the HWSim language
   1.134  * 
   1.135  *It has two timelines, each with one input port and one output port, and
   1.136  * a single span-type.
   1.137  *
   1.138  *The timelines are cross-coupled, so output port of one connects to input
   1.139  * port of the other.  The input port has a single trigger, which fires
   1.140  * the one span-type.
   1.141  * 
   1.142  *The span does nothing, except send a NULL message on the output port.
   1.143  * 
   1.144  *The span-sim-time and communication-sim-time are both constants.
   1.145  *
   1.146  *Note that timelines are generic.  They are specialized by declaring
   1.147  * inports and outports, and by registering triggers that fire particular
   1.148  * span-types.
   1.149  */
   1.150 HWSimNetlist *
   1.151 createPingPongNetlist()
   1.152  { HWSimNetlist *netlist;
   1.153    HWSimWire   **wires;
   1.154    HWSimTimeline    **timelines;
   1.155    
   1.156    int numTimelines;
   1.157    int numWires;
   1.158  
   1.159    netlist = malloc( sizeof(HWSimNetlist) );
   1.160    
   1.161       //declare timelines
   1.162    numTimelines = 2;
   1.163    timelines = malloc( numTimelines * sizeof(HWSimTimeline) );
   1.164    netlist->numTimelines = numTimelines;
   1.165    netlist->timelines    = timelines;
   1.166    
   1.167    timelines[0] = createAPingPongTimeline();
   1.168    timelines[1] = createAPingPongTimeline();
   1.169    
   1.170       //add a trigger to reset port of one of the timelines, to start things
   1.171    HWSimSpanType *pingPongSpan;
   1.172    pingPongSpan = malloc( sizeof(HWSimSpanType) );
   1.173    pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span;
   1.174    pingPongSpan->timingFn   = &timingOf_ping_pong_span;
   1.175    
   1.176    timelines[1]->triggers[0]->inPortNum = -1//the reset port
   1.177    timelines[1]->triggers[0]->spanType = pingPongSpan;
   1.178    
   1.179       //Connect timelines together
   1.180    numWires = 2;
   1.181    wires = malloc( numWires * sizeof(HWSimWire) );
   1.182    netlist->numWires = numWires;
   1.183    netlist->wires    = wires;
   1.184    
   1.185    //TODO:For wires, have many design decisions to make -- driven by impl, so
   1.186    // have to be delayed until get into guts of impl.
   1.187    //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array
   1.188    //TODO: decide if each wire transports only one kind of message or many
   1.189    //TODO: decide if inports accept one wire or many (msg type set by inport)
   1.190    //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0
   1.191    wires[0] = {0,0,1,0,0}; 
   1.192    wires[1] = {1,0,0,0,0};
   1.193 
   1.194 /* For starters, not doing time-domains..  will add later (Nov 2011)
   1.195       //Create time domains
   1.196    numTimeDomains = 2;
   1.197    timeDomains    = malloc( numTimeDomains * sizeof(TimeDomain) );
   1.198    netlist->numTimeDomains = numTimeDomains;
   1.199    netlist->timeDomains    = timeDomains;
   1.200    
   1.201    timeDomains[0]->numDomains   = 0;
   1.202    timeDomains[0]->numTimelines = 1;
   1.203    timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[]
   1.204    
   1.205    timeDomains[1]->numDomains   = 0;
   1.206    timeDomains[1]->numTimelines = 1;
   1.207    timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[]
   1.208    
   1.209       //Create time domain connections -- must respect hierarchy
   1.210    numDomainConnections = 2;
   1.211    domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) );
   1.212    netlist->numDomainConns = numDomainConnections;
   1.213    netlist->domainConns    = domainConnects;
   1.214    
   1.215    domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1
   1.216    domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0
   1.217  */
   1.218  }
   1.219 
   1.220 HWSimTimeline *
   1.221 createAPingPongTimeline()
   1.222  { HWSimTimeline *tl;
   1.223    HWSimTrigger **triggers;
   1.224    
   1.225    tl = malloc( sizeof(HWSimTimeline) );
   1.226     
   1.227    tl->numInPorts  = 1;
   1.228    tl->numOutPorts = 1;
   1.229    tl->numTriggers = 2;
   1.230    
   1.231    triggers = malloc( 2 * sizeof(HWSimTrigger) ); //extra is reset trig
   1.232    tl->triggers[0].inPortNum = -1; //reset trigger
   1.233    tl->triggers[0].spanType = IDLE_SPAN;
   1.234    
   1.235    HWSimSpanType *pingPongSpan;
   1.236    pingPongSpan = malloc( sizeof(HWSimSpanType) );
   1.237    pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span;
   1.238    pingPongSpan->timingFn   = &timingOf_ping_pong_span;
   1.239    
   1.240    tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or ->
   1.241    tl->triggers[1].spanType = pingPongSpan;
   1.242  }
   1.243 \ No newline at end of file
     2.1 --- a/src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c	Sat Nov 19 17:58:21 2011 -0800
     2.2 +++ b/src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c	Wed Nov 30 08:40:30 2011 -0800
     2.3 @@ -1,1 +1,1 @@
     2.4 -/*
     2.5  *  Copyright 2011 OpenSourceStewardshipFoundation.org
     2.6  *  Licensed under GNU General Public License version 2
     2.7  *
     2.8  * Author: seanhalle@yahoo.com
     2.9  *
    2.10  */
    2.11 
    2.12 #include "HWSim__Hello_World_HW.h"
    2.13 
    2.14 
    2.15 
    2.16 //====================================================================
    2.17 /*This is the ping-pong timeline for the Hello World hardware
    2.18  *
    2.19  *It has only one kind of span, which only puts a communication on
    2.20  * the timeline's one out-port.
    2.21  * 
    2.22  *The in-port has only one trigger registered on it, which fires that
    2.23  * span.
    2.24  */
    2.25 
    2.26 #define NO_MSG NULL
    2.27 #define PORT0 0
    2.28 
    2.29 /*
    2.30  *Note, the returned value is passed to the timing function
    2.31  */
    2.32 void *
    2.33 behaviorOf_ping_pong_span( void *_params, TimeLine *timeline )
    2.34  {
    2.35    PingPongParams  *params;
    2.36    params    = (PingPongParams *)_params;
    2.37          DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) );
    2.38    
    2.39    HWSim__send_on_port( NO_MSG, PORT0, timeline );
    2.40  }
    2.41 
    2.42 uint64
    2.43 timingOf_ping_pong_span( void * dataFromBehaviorFn )
    2.44  {
    2.45    return 10;
    2.46  }
    2.47 \ No newline at end of file
    2.48 +/*
    2.49  *  Copyright 2011 OpenSourceStewardshipFoundation.org
    2.50  *  Licensed under GNU General Public License version 2
    2.51  *
    2.52  * Author: seanhalle@yahoo.com
    2.53  *
    2.54  */
    2.55 
    2.56 #include "HWSim__Hello_World_HW.h"
    2.57 
    2.58 
    2.59 
    2.60 //====================================================================
    2.61 /*This is the ping-pong timeline for the Hello World hardware
    2.62  *
    2.63  *It has only one kind of span, which only puts a communication on
    2.64  * the timeline's one out-port.
    2.65  * 
    2.66  *The in-port has only one trigger registered on it, which fires that
    2.67  * span.
    2.68  */
    2.69 
    2.70 #define NO_MSG NULL
    2.71 #define PORT0 0
    2.72 
    2.73 /*
    2.74  *Note, the returned value is passed to the timing function
    2.75  */
    2.76 void *
    2.77 behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeline )
    2.78  {
    2.79    PingPongParams  *params;
    2.80    params    = (PingPongParams *)_params;
    2.81          DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) );
    2.82    
    2.83    HWSim__send_on_port( NO_MSG, PORT0, timeline );
    2.84  }
    2.85 
    2.86 uint64
    2.87 timingOf_ping_pong_span( void * dataFromBehaviorFn )
    2.88  {
    2.89    return 10;
    2.90  }
    2.91 \ No newline at end of file
     3.1 --- a/src/Application/main.c	Sat Nov 19 17:58:21 2011 -0800
     3.2 +++ b/src/Application/main.c	Wed Nov 30 08:40:30 2011 -0800
     3.3 @@ -19,6 +19,7 @@
     3.4  int main( int argc, char **argv )
     3.5   { ParamBag      *simParams;
     3.6     HWSimResults  *simResults;
     3.7 +   HWSimNetlist  *netlist;
     3.8  
     3.9     printf( "param file name: %s\n", argv[1] );
    3.10