Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
changeset 8:3276b8621f96
Merged -- issues with line endings, tried adding .hgeol.. see what happens
author | Me@portablequad |
---|---|
date | Wed, 04 Jan 2012 15:50:49 -0800 |
parents | 648207f2e38f 55d3ca21bccd |
children | 272e1389c321 |
files | src/Application/CircuitNetlistCreator.c src/Application/main.c |
diffstat | 2 files changed, 119 insertions(+), 177 deletions(-) [+] |
line diff
1.1 --- a/src/Application/CircuitNetlistCreator.c Tue Dec 06 18:46:42 2011 +0100 1.2 +++ b/src/Application/CircuitNetlistCreator.c Wed Jan 04 15:50:49 2012 -0800 1.3 @@ -5,153 +5,95 @@ 1.4 * Author: seanhalle@yahoo.com 1.5 * 1.6 */ 1.7 - 1.8 -#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 1.9 - 1.10 -HWSimTimeline* createAPingPongTimeline (); 1.11 - 1.12 - 1.13 + #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 1.14 + 1.15 +/*'wire' is an expr resolves to an actual wire struct instance 1.16 + */ 1.17 +#define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\ 1.18 +do{\ 1.19 + wire.idxOfFromTimeline = fromTLIdx; \ 1.20 + wire.idxOfFromOutPort = fromTLIdx; \ 1.21 + wire.idxOfToTimeline = toTLIdx; \ 1.22 + wire.idxOfToInPort = inPort; \ 1.23 + wire.archSpecWireData = dataPtr; \ 1.24 + }while(0); //macro magic for namespace 1.25 + 1.26 /*This file constructs the netlist for the Hello World circuit, which is 1.27 * used during design and implementation of the HWSim language 1.28 - * 1.29 + * 1.30 *It has two timelines, each with one input port and one output port, and 1.31 * a single span-type. 1.32 * 1.33 *The timelines are cross-coupled, so output port of one connects to input 1.34 * port of the other. The input port has a single trigger, which fires 1.35 * the one span-type. 1.36 - * 1.37 + * 1.38 *The span does nothing, except send a NULL message on the output port. 1.39 - * 1.40 *The span-sim-time and communication-sim-time are both constants. 1.41 * 1.42 *Note that timelines are generic. They are specialized by declaring 1.43 * inports and outports, and by registering triggers that fire particular 1.44 * span-types. 1.45 */ 1.46 -HWSimNetlist * 1.47 -createPingPongNetlist() 1.48 - { HWSimNetlist *netlist; 1.49 - HWSimWire **wires; 1.50 - HWSimTimeline **timelines; 1.51 - 1.52 +HWSimNetlist *createPingPongNetlist() 1.53 + { HWSimNetlist *netlist; 1.54 + NetlistWire *wires; 1.55 + HWSimTimeline **timelines; 1.56 int numTimelines; 1.57 int numWires; 1.58 - 1.59 - int i; 1.60 - 1.61 + 1.62 netlist = malloc( sizeof(HWSimNetlist) ); 1.63 - 1.64 - //declare timelines 1.65 - numTimelines = 2; 1.66 - timelines = malloc( numTimelines * sizeof(HWSimTimeline *) ); 1.67 + //declare timelines numTimelines = 2; 1.68 + timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); 1.69 netlist->numTimelines = numTimelines; 1.70 netlist->timelines = timelines; 1.71 - 1.72 - timelines[0] = createAPingPongTimeline(0); 1.73 - timelines[1] = createAPingPongTimeline(1); 1.74 - 1.75 - //add a trigger to reset port of one of the timelines, to start things 1.76 - HWSimSpanType *pingPongSpan; 1.77 - pingPongSpan = malloc( sizeof(HWSimSpanType) ); 1.78 - pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 1.79 - pingPongSpan->timingFn = (void *)&(timingOf_ping_pong_span); 1.80 - 1.81 - timelines[1]->triggers[0]->inPortNum = -1;//the reset port 1.82 - timelines[1]->triggers[0]->spanType = pingPongSpan; 1.83 - 1.84 - //Connect timelines together 1.85 - numWires = 2; 1.86 - wires = malloc( numWires * sizeof(HWSimWire *) ); 1.87 - for (i= 0; i<numWires; i++) { 1.88 - wires[i]= malloc(sizeof(HWSimWire)); 1.89 - } 1.90 + netlist->numSpanTypes = 1; 1.91 + netlist->spanTypes = malloc(netlist->numSpanTypes*sizeof(HWSimSpanType*)); 1.92 + netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType(); 1.93 + timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist 1.94 + timelines[1] = createAPingPongTimeline( netlist ); 1.95 + //on one of the timelines, make reset trigger an action 1.96 + timelines[1]->inPorts[-1].triggeredSpanType = 1.97 + netlist->spanTypes PING_PONG_TYPE]; //Connect timelines together 1.98 + 1.99 + /*OutPorts and InPorts may have many wires attached, but an inPort only 1.100 + * has one kind of span that all incoming communications trigger. That 1.101 + * span can be zero time and then switch on the type of message then 1.102 + * end with a continuation, where the continuation span is chosen by the 1.103 + * switch. 1.104 + *So, a wire only connects an out port to an in port 1.105 + *The format is: sending TL-index, out-port, dest TL-index, in-port 1.106 + */ 1.107 + numWires = 2; 1.108 + wires = malloc( numWires * sizeof(NetlistWire) ); 1.109 netlist->numWires = numWires; 1.110 netlist->wires = wires; 1.111 - 1.112 - //TODO:For wires, have many design decisions to make -- driven by impl, so 1.113 - // have to be delayed until get into guts of impl. 1.114 - //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array 1.115 - //TODO: decide if each wire transports only one kind of message or many 1.116 - //TODO: decide if inports accept one wire or many (msg type set by inport) 1.117 - //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 1.118 - wires[0]->idxOfFromTimeline= 0; 1.119 - wires[0]->fromOutPort= 0; 1.120 - wires[0]->idxOfToTimeline= 1; 1.121 - wires[0]->toInPort= 0; 1.122 - wires[0]->msgType= 0; 1.123 - wires[1]->idxOfFromTimeline= 1; 1.124 - wires[1]->fromOutPort= 0; 1.125 - wires[1]->idxOfToTimeline= 0; 1.126 - wires[1]->toInPort= 0; 1.127 - wires[1]->msgType= 0; 1.128 - 1.129 - 1.130 -/* For starters, not doing time-domains.. will add later (Nov 2011) 1.131 - //Create time domains 1.132 - numTimeDomains = 2; 1.133 - timeDomains = malloc( numTimeDomains * sizeof(TimeDomain) ); 1.134 - netlist->numTimeDomains = numTimeDomains; 1.135 - netlist->timeDomains = timeDomains; 1.136 - 1.137 - timeDomains[0]->numDomains = 0; 1.138 - timeDomains[0]->numTimelines = 1; 1.139 - timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[] 1.140 - 1.141 - timeDomains[1]->numDomains = 0; 1.142 - timeDomains[1]->numTimelines = 1; 1.143 - timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[] 1.144 - 1.145 - //Create time domain connections -- must respect hierarchy 1.146 - numDomainConnections = 2; 1.147 - domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) ); 1.148 - netlist->numDomainConns = numDomainConnections; 1.149 - netlist->domainConns = domainConnects; 1.150 - 1.151 - domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1 1.152 - domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0 1.153 - */ 1.154 - 1.155 - return netlist; 1.156 + //TL 0, out-port 0 to TL 1, in-port 0 1.157 + setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into 1.158 + setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create 1.159 + //TODO: decide how do in-out bidirectional wires -- thinking make it two 1.160 + // separate wires with guard between in-port and out-port 1.161 + //TODO: decide how do guards between ports 1.162 } 1.163 - 1.164 + 1.165 + //Note: copy netlist struct with VMS malloc after VMS initialized 1.166 HWSimTimeline * 1.167 -createAPingPongTimeline(int timelineID) 1.168 - { HWSimTimeline *tl; 1.169 - int i; 1.170 -// HWSimTrigger **triggers; 1.171 - 1.172 - tl = malloc( sizeof(HWSimTimeline) ); 1.173 - 1.174 - tl->timelineID= timelineID; 1.175 - tl->numInPorts = 1; 1.176 - tl->numOutPorts = 1; 1.177 - tl->numTriggers = 2; 1.178 - 1.179 - tl->triggers = malloc( 2 * sizeof(HWSimTrigger *) ); //extra is reset trig 1.180 - for (i= 0; i<tl->numTriggers; i++) { 1.181 - tl->triggers[i]= malloc(sizeof(HWSimTrigger)); 1.182 - } 1.183 - 1.184 - 1.185 - // FIXME general IDLE_SPAN 1.186 - HWSimSpanType *idleSpan; 1.187 - idleSpan= malloc(sizeof(HWSimSpanType)); 1.188 - idleSpan->behaviorFn= NULL; 1.189 - idleSpan->timingFn= NULL; 1.190 - 1.191 - 1.192 - tl->triggers[0]->inPortNum = -1; //reset trigger 1.193 - tl->triggers[0]->spanType = idleSpan; 1.194 - 1.195 - HWSimSpanType *pingPongSpan; 1.196 - pingPongSpan = malloc( sizeof(HWSimSpanType) ); 1.197 - pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 1.198 - pingPongSpan->timingFn = (void *)&timingOf_ping_pong_span; 1.199 - 1.200 - tl->triggers[1]->inPortNum = 0; //TODO: Debug: verify whether . or -> 1.201 - tl->triggers[1]->spanType = pingPongSpan; 1.202 - 1.203 - return tl; 1.204 +createAPingPongTimeline( HWSimNetlist *netlist ) 1.205 + { HWSimTimeline *TL; 1.206 + TL = malloc( sizeof(HWSimTimeline) ); 1.207 + TL->numInPorts = 1; 1.208 + TL->numOutPorts = 1; 1.209 + TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); 1.210 + TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port 1.211 + TL->inPorts[0].triggeredSpanType = netlist->spanTypes[PING_PONG_TYPE]; 1.212 } 1.213 - 1.214 + 1.215 +HWSimSpanType * 1.216 +createPingPongSpanType( ) 1.217 + { HWSimSpanType *pingPongSpanType; 1.218 + pingPongSpanType = malloc( sizeof(HWSimSpanType) ); 1.219 + pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; 1.220 + pingPongSpanType->timingFn = &timingOf_ping_pong_span; 1.221 + return pingPongSpanType; 1.222 + } 1.223 + 1.224 \ No newline at end of file
2.1 --- a/src/Application/main.c Tue Dec 06 18:46:42 2011 +0100 2.2 +++ b/src/Application/main.c Wed Jan 04 15:50:49 2012 -0800 2.3 @@ -1,52 +1,52 @@ 2.4 -/* 2.5 - * Copyright 2011 OpenSourceStewardshipFoundation.org 2.6 - * Licensed under BSD 2.7 - * 2.8 - * author seanhalle@yahoo.com 2.9 - */ 2.10 - 2.11 -#include <malloc.h> 2.12 -#include <stdlib.h> 2.13 - 2.14 -#include "SimParams.h" 2.15 -#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 2.16 - 2.17 -char __ProgrammName[] = "HWSim Hello World"; 2.18 -char __DataSet[255]; 2.19 -char __Scheduler[]; 2.20 - 2.21 -/* 2.22 - * 2.23 - * 2.24 - */ 2.25 - 2.26 -int main( int argc, char **argv ) 2.27 - { ParamBag *simParams; 2.28 - HWSimNetlist *netlist; 2.29 - HWSimResults *simResults; 2.30 - 2.31 - printf( "param file name: %s\n", argv[1] ); 2.32 - printf("Paraver trace file %s\n", argv[2]); 2.33 - 2.34 -#ifdef FAKE 2.35 - simParams= NULL; 2.36 -#else 2.37 - simParams = makeParamBag(); 2.38 - readParamFileIntoBag( argv[1], simParams ); 2.39 -#endif 2.40 - 2.41 - netlist = createPingPongNetlist(); 2.42 -#ifdef FAKE 2.43 - simResults= create_simulation_results__fake(simParams,netlist); 2.44 -#else 2.45 - simResults = 2.46 - HWSim__run_simulation( simParams, netlist ); 2.47 -#endif 2.48 - 2.49 - //HWSim 2.50 - HWSim__generate_paraver_output(argv[2], simResults, netlist); 2.51 - //HWSim__generate_vcd_output( simResults ); 2.52 - 2.53 - exit(0); //cleans up 2.54 - } 2.55 - 2.56 +/* 2.57 + * Copyright 2011 OpenSourceStewardshipFoundation.org 2.58 + * Licensed under BSD 2.59 + * 2.60 + * author seanhalle@yahoo.com 2.61 + */ 2.62 + 2.63 +#include <malloc.h> 2.64 +#include <stdlib.h> 2.65 + 2.66 +#include "SimParams.h" 2.67 +#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 2.68 + 2.69 +char __ProgrammName[] = "HWSim Hello World"; 2.70 +char __DataSet[255]; 2.71 +char __Scheduler[]; 2.72 + 2.73 +/* 2.74 + * 2.75 + * 2.76 + */ 2.77 + 2.78 +int main( int argc, char **argv ) 2.79 + { ParamBag *simParams; 2.80 + HWSimNetlist *netlist; 2.81 + HWSimResults *simResults; 2.82 + 2.83 + printf( "param file name: %s\n", argv[1] ); 2.84 + printf("Paraver trace file %s\n", argv[2]); 2.85 + 2.86 +#ifdef FAKE 2.87 + simParams= NULL; 2.88 +#else 2.89 + simParams = makeParamBag(); 2.90 + readParamFileIntoBag( argv[1], simParams ); 2.91 +#endif 2.92 + 2.93 + netlist = createPingPongNetlist(); 2.94 +#ifdef FAKE 2.95 + simResults= create_simulation_results__fake(simParams,netlist); 2.96 +#else 2.97 + simResults = 2.98 + HWSim__run_simulation( simParams, netlist ); 2.99 +#endif 2.100 + 2.101 + //HWSim 2.102 + HWSim__generate_paraver_output(argv[2], simResults, netlist); 2.103 + //HWSim__generate_vcd_output( simResults ); 2.104 + 2.105 + exit(0); //cleans up 2.106 + } 2.107 +