Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
changeset 5:648207f2e38f
Netlist creation runnable + creation of faked simulation results
author | hausers |
---|---|
date | Tue, 06 Dec 2011 18:46:42 +0100 |
parents | 2d3505958ca8 |
children | 3276b8621f96 |
files | .hgignore src/Application/CircuitNetlistCreator.c src/Application/HWSim__Hello_World_HW/FakeSim.c src/Application/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c src/Application/SimParams.c src/Application/SimParams.h src/Application/main.c |
diffstat | 8 files changed, 560 insertions(+), 77 deletions(-) [+] |
line diff
1.1 --- a/.hgignore Mon Dec 05 12:24:44 2011 +0100 1.2 +++ b/.hgignore Tue Dec 06 18:46:42 2011 +0100 1.3 @@ -3,4 +3,7 @@ 1.4 nbproject 1.5 build 1.6 dist 1.7 -*.o 1.8 \ No newline at end of file 1.9 +*.o 1.10 +.dep.inc 1.11 +Makefile 1.12 +notes
2.1 --- a/src/Application/CircuitNetlistCreator.c Mon Dec 05 12:24:44 2011 +0100 2.2 +++ b/src/Application/CircuitNetlistCreator.c Tue Dec 06 18:46:42 2011 +0100 2.3 @@ -1,1 +1,157 @@ 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/HWSim__Hello_World_HW.h" 2.13 2.14 2.15 /*This file constructs the netlist for the Hello World circuit, which is 2.16 * used during design and implementation of the HWSim language 2.17 * 2.18 *It has two timelines, each with one input port and one output port, and 2.19 * a single span-type. 2.20 * 2.21 *The timelines are cross-coupled, so output port of one connects to input 2.22 * port of the other. The input port has a single trigger, which fires 2.23 * the one span-type. 2.24 * 2.25 *The span does nothing, except send a NULL message on the output port. 2.26 * 2.27 *The span-sim-time and communication-sim-time are both constants. 2.28 * 2.29 *Note that timelines are generic. They are specialized by declaring 2.30 * inports and outports, and by registering triggers that fire particular 2.31 * span-types. 2.32 */ 2.33 HWSimNetlist * 2.34 createPingPongNetlist() 2.35 { HWSimNetlist *netlist; 2.36 HWSimWire **wires; 2.37 HWSimTimeline **timelines; 2.38 2.39 int numTimelines; 2.40 int numWires; 2.41 2.42 netlist = malloc( sizeof(HWSimNetlist) ); 2.43 2.44 //declare timelines 2.45 numTimelines = 2; 2.46 timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); 2.47 netlist->numTimelines = numTimelines; 2.48 netlist->timelines = timelines; 2.49 2.50 timelines[0] = createAPingPongTimeline(); 2.51 timelines[1] = createAPingPongTimeline(); 2.52 2.53 //add a trigger to reset port of one of the timelines, to start things 2.54 HWSimSpanType *pingPongSpan; 2.55 pingPongSpan = malloc( sizeof(HWSimSpanType) ); 2.56 pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 2.57 pingPongSpan->timingFn = &timingOf_ping_pong_span; 2.58 2.59 timelines[1]->triggers[0]->inPortNum = -1//the reset port 2.60 timelines[1]->triggers[0]->spanType = pingPongSpan; 2.61 2.62 //Connect timelines together 2.63 numWires = 2; 2.64 wires = malloc( numWires * sizeof(HWSimWire) ); 2.65 netlist->numWires = numWires; 2.66 netlist->wires = wires; 2.67 2.68 //TODO:For wires, have many design decisions to make -- driven by impl, so 2.69 // have to be delayed until get into guts of impl. 2.70 //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array 2.71 //TODO: decide if each wire transports only one kind of message or many 2.72 //TODO: decide if inports accept one wire or many (msg type set by inport) 2.73 //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 2.74 wires[0] = {0,0,1,0,0}; 2.75 wires[1] = {1,0,0,0,0}; 2.76 2.77 /* For starters, not doing time-domains.. will add later (Nov 2011) 2.78 //Create time domains 2.79 numTimeDomains = 2; 2.80 timeDomains = malloc( numTimeDomains * sizeof(TimeDomain) ); 2.81 netlist->numTimeDomains = numTimeDomains; 2.82 netlist->timeDomains = timeDomains; 2.83 2.84 timeDomains[0]->numDomains = 0; 2.85 timeDomains[0]->numTimelines = 1; 2.86 timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[] 2.87 2.88 timeDomains[1]->numDomains = 0; 2.89 timeDomains[1]->numTimelines = 1; 2.90 timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[] 2.91 2.92 //Create time domain connections -- must respect hierarchy 2.93 numDomainConnections = 2; 2.94 domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) ); 2.95 netlist->numDomainConns = numDomainConnections; 2.96 netlist->domainConns = domainConnects; 2.97 2.98 domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1 2.99 domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0 2.100 */ 2.101 } 2.102 2.103 HWSimTimeline * 2.104 createAPingPongTimeline() 2.105 { HWSimTimeline *tl; 2.106 HWSimTrigger **triggers; 2.107 2.108 tl = malloc( sizeof(HWSimTimeline) ); 2.109 2.110 tl->numInPorts = 1; 2.111 tl->numOutPorts = 1; 2.112 tl->numTriggers = 2; 2.113 2.114 triggers = malloc( 2 * sizeof(HWSimTrigger) ); //extra is reset trig 2.115 tl->triggers[0].inPortNum = -1; //reset trigger 2.116 tl->triggers[0].spanType = IDLE_SPAN; 2.117 2.118 HWSimSpanType *pingPongSpan; 2.119 pingPongSpan = malloc( sizeof(HWSimSpanType) ); 2.120 pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 2.121 pingPongSpan->timingFn = &timingOf_ping_pong_span; 2.122 2.123 tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or -> 2.124 tl->triggers[1].spanType = pingPongSpan; 2.125 } 2.126 \ No newline at end of file 2.127 +/* 2.128 + * Copyright 2011 OpenSourceStewardshipFoundation.org 2.129 + * Licensed under GNU General Public License version 2 2.130 + * 2.131 + * Author: seanhalle@yahoo.com 2.132 + * 2.133 + */ 2.134 + 2.135 +#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 2.136 + 2.137 +HWSimTimeline* createAPingPongTimeline (); 2.138 + 2.139 + 2.140 +/*This file constructs the netlist for the Hello World circuit, which is 2.141 + * used during design and implementation of the HWSim language 2.142 + * 2.143 + *It has two timelines, each with one input port and one output port, and 2.144 + * a single span-type. 2.145 + * 2.146 + *The timelines are cross-coupled, so output port of one connects to input 2.147 + * port of the other. The input port has a single trigger, which fires 2.148 + * the one span-type. 2.149 + * 2.150 + *The span does nothing, except send a NULL message on the output port. 2.151 + * 2.152 + *The span-sim-time and communication-sim-time are both constants. 2.153 + * 2.154 + *Note that timelines are generic. They are specialized by declaring 2.155 + * inports and outports, and by registering triggers that fire particular 2.156 + * span-types. 2.157 + */ 2.158 +HWSimNetlist * 2.159 +createPingPongNetlist() 2.160 + { HWSimNetlist *netlist; 2.161 + HWSimWire **wires; 2.162 + HWSimTimeline **timelines; 2.163 + 2.164 + int numTimelines; 2.165 + int numWires; 2.166 + 2.167 + int i; 2.168 + 2.169 + netlist = malloc( sizeof(HWSimNetlist) ); 2.170 + 2.171 + //declare timelines 2.172 + numTimelines = 2; 2.173 + timelines = malloc( numTimelines * sizeof(HWSimTimeline *) ); 2.174 + netlist->numTimelines = numTimelines; 2.175 + netlist->timelines = timelines; 2.176 + 2.177 + timelines[0] = createAPingPongTimeline(0); 2.178 + timelines[1] = createAPingPongTimeline(1); 2.179 + 2.180 + //add a trigger to reset port of one of the timelines, to start things 2.181 + HWSimSpanType *pingPongSpan; 2.182 + pingPongSpan = malloc( sizeof(HWSimSpanType) ); 2.183 + pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 2.184 + pingPongSpan->timingFn = (void *)&(timingOf_ping_pong_span); 2.185 + 2.186 + timelines[1]->triggers[0]->inPortNum = -1;//the reset port 2.187 + timelines[1]->triggers[0]->spanType = pingPongSpan; 2.188 + 2.189 + //Connect timelines together 2.190 + numWires = 2; 2.191 + wires = malloc( numWires * sizeof(HWSimWire *) ); 2.192 + for (i= 0; i<numWires; i++) { 2.193 + wires[i]= malloc(sizeof(HWSimWire)); 2.194 + } 2.195 + netlist->numWires = numWires; 2.196 + netlist->wires = wires; 2.197 + 2.198 + //TODO:For wires, have many design decisions to make -- driven by impl, so 2.199 + // have to be delayed until get into guts of impl. 2.200 + //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array 2.201 + //TODO: decide if each wire transports only one kind of message or many 2.202 + //TODO: decide if inports accept one wire or many (msg type set by inport) 2.203 + //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 2.204 + wires[0]->idxOfFromTimeline= 0; 2.205 + wires[0]->fromOutPort= 0; 2.206 + wires[0]->idxOfToTimeline= 1; 2.207 + wires[0]->toInPort= 0; 2.208 + wires[0]->msgType= 0; 2.209 + wires[1]->idxOfFromTimeline= 1; 2.210 + wires[1]->fromOutPort= 0; 2.211 + wires[1]->idxOfToTimeline= 0; 2.212 + wires[1]->toInPort= 0; 2.213 + wires[1]->msgType= 0; 2.214 + 2.215 + 2.216 +/* For starters, not doing time-domains.. will add later (Nov 2011) 2.217 + //Create time domains 2.218 + numTimeDomains = 2; 2.219 + timeDomains = malloc( numTimeDomains * sizeof(TimeDomain) ); 2.220 + netlist->numTimeDomains = numTimeDomains; 2.221 + netlist->timeDomains = timeDomains; 2.222 + 2.223 + timeDomains[0]->numDomains = 0; 2.224 + timeDomains[0]->numTimelines = 1; 2.225 + timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[] 2.226 + 2.227 + timeDomains[1]->numDomains = 0; 2.228 + timeDomains[1]->numTimelines = 1; 2.229 + timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[] 2.230 + 2.231 + //Create time domain connections -- must respect hierarchy 2.232 + numDomainConnections = 2; 2.233 + domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) ); 2.234 + netlist->numDomainConns = numDomainConnections; 2.235 + netlist->domainConns = domainConnects; 2.236 + 2.237 + domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1 2.238 + domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0 2.239 + */ 2.240 + 2.241 + return netlist; 2.242 + } 2.243 + 2.244 +HWSimTimeline * 2.245 +createAPingPongTimeline(int timelineID) 2.246 + { HWSimTimeline *tl; 2.247 + int i; 2.248 +// HWSimTrigger **triggers; 2.249 + 2.250 + tl = malloc( sizeof(HWSimTimeline) ); 2.251 + 2.252 + tl->timelineID= timelineID; 2.253 + tl->numInPorts = 1; 2.254 + tl->numOutPorts = 1; 2.255 + tl->numTriggers = 2; 2.256 + 2.257 + tl->triggers = malloc( 2 * sizeof(HWSimTrigger *) ); //extra is reset trig 2.258 + for (i= 0; i<tl->numTriggers; i++) { 2.259 + tl->triggers[i]= malloc(sizeof(HWSimTrigger)); 2.260 + } 2.261 + 2.262 + 2.263 + // FIXME general IDLE_SPAN 2.264 + HWSimSpanType *idleSpan; 2.265 + idleSpan= malloc(sizeof(HWSimSpanType)); 2.266 + idleSpan->behaviorFn= NULL; 2.267 + idleSpan->timingFn= NULL; 2.268 + 2.269 + 2.270 + tl->triggers[0]->inPortNum = -1; //reset trigger 2.271 + tl->triggers[0]->spanType = idleSpan; 2.272 + 2.273 + HWSimSpanType *pingPongSpan; 2.274 + pingPongSpan = malloc( sizeof(HWSimSpanType) ); 2.275 + pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; 2.276 + pingPongSpan->timingFn = (void *)&timingOf_ping_pong_span; 2.277 + 2.278 + tl->triggers[1]->inPortNum = 0; //TODO: Debug: verify whether . or -> 2.279 + tl->triggers[1]->spanType = pingPongSpan; 2.280 + 2.281 + return tl; 2.282 + } 2.283 +
3.1 --- a/src/Application/HWSim__Hello_World_HW/FakeSim.c Mon Dec 05 12:24:44 2011 +0100 3.2 +++ b/src/Application/HWSim__Hello_World_HW/FakeSim.c Tue Dec 06 18:46:42 2011 +0100 3.3 @@ -1,55 +1,86 @@ 3.4 +#include <stdlib.h> 3.5 #include "HWSim__Hello_World_HW.h" 3.6 3.7 +void checkMalloc (void *ptr) { 3.8 + if (ptr == NULL) { 3.9 + printf("Memory allocation failed!\n"); 3.10 + exit(1); 3.11 + } 3.12 +} 3.13 + 3.14 +HWSimTimeline* malloc_timlines (int nrTimelines) { 3.15 + HWSimTimeline *timelines; 3.16 + int i; 3.17 + 3.18 + timelines= malloc(nrTimelines*(sizeof(HWSimTimeline))); 3.19 + checkMalloc(timelines); 3.20 + for (i= 0; i<nrTimelines; i++) { 3.21 + timelines[i].animatingVP= malloc(sizeof(VirtProcr)); 3.22 + checkMalloc(timelines[i].animatingVP); 3.23 + } 3.24 + return timelines; 3.25 +} 3.26 + 3.27 +HWSimResults* malloc_simResults (int nrExecutions, int nrComms) { 3.28 + HWSimResults *simResults; 3.29 + int i; 3.30 + 3.31 + 3.32 + simResults= malloc(sizeof(HWSimResults)); 3.33 + checkMalloc(simResults); 3.34 + 3.35 + simResults->numTimelines= nrExecutions; 3.36 + simResults->timelineTraces= 3.37 + malloc(simResults->numTimelines*sizeof(HWSimTimelineTrace *)); 3.38 + 3.39 + for (i= 0; i<simResults->numTimelines; i++) { 3.40 + simResults->timelineTraces[i]= malloc(sizeof(HWSimTimelineTrace)); 3.41 + checkMalloc(simResults->timelineTraces[i]); 3.42 + simResults->timelineTraces[i]->spanRecs= malloc(sizeof(HWSimSpanRec)); 3.43 + } 3.44 + 3.45 + simResults->numCommTraces= nrComms; 3.46 + simResults->commTraces= 3.47 + malloc(simResults->numCommTraces*sizeof(HWSimWireTrace *)); 3.48 + checkMalloc(simResults->commTraces); 3.49 + for (i= 0; i<simResults->numCommTraces; i++) { 3.50 + simResults->commTraces[i]= malloc(sizeof(HWSimWireTrace)); 3.51 + checkMalloc(simResults->commTraces[i]); 3.52 + // FRAGILE -> valgrind 3.53 + simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec)); 3.54 + checkMalloc(simResults->commTraces[i]->commRecs); 3.55 + } 3.56 + 3.57 + return simResults; 3.58 +} 3.59 + 3.60 HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) { 3.61 HWSimResults *simResults; 3.62 - HWSimTimeline *pingTimeline,*pongTimeline; 3.63 3.64 - 3.65 - // 2 timelines 3.66 - pingTimeline= malloc(sizeof(HWSimTimeline)); 3.67 - pingTimeline->animatingVP= malloc(sizeof(VirtProcr)); 3.68 - pingTimeline->animatingVP->procrID= 0; 3.69 + simResults= malloc_simResults(4,3); 3.70 3.71 - pongTimeline= malloc(sizeof(HWSimTimeline)); 3.72 - pongTimeline->animatingVP= malloc(sizeof(VirtProcr)); 3.73 - pongTimeline->animatingVP->procrID= 1; 3.74 + //--------------- timelineTraces ------------------------------------ 3.75 + // 2 times a ping span 3.76 + simResults->timelineTraces[0]->timeline= netlist->timelines[0]; 3.77 + simResults->timelineTraces[0]->spanRecs->spanSeqNum= 0; // unique ??? 3.78 + simResults->timelineTraces[0]->spanRecs->startTime= 1; 3.79 + simResults->timelineTraces[0]->spanRecs->endTime=2; 3.80 3.81 - simResults= malloc(sizeof(HWSimResults)); 3.82 - 3.83 - //--------------- timelineTrace ------------------------------------ 3.84 - simResults->numTimelines= 2; 3.85 - simResults->timelineTraces= malloc(simResults->numTimelines*sizeof(HWSimTimelineTrace)); 3.86 - 3.87 - simResults->timelineTraces[0]->timeline= pingTimeline; 3.88 - simResults->timelineTraces[0]->numSpans= 2; 3.89 - simResults->timelineTraces[0]->spanRecs= malloc(simResults->timelineTraces[0]->numSpans*sizeof(HWSimSpanRec)); 3.90 - 3.91 - // 2 times a ping span 3.92 - // no idle spans included (not required ??) 3.93 - simResults->timelineTraces[0]->spanRecs[0]->spanSeqNum= 0; // unique ??? 3.94 - simResults->timelineTraces[0]->spanRecs[0]->spanType= NULL; 3.95 - simResults->timelineTraces[0]->spanRecs[0]->startTime= 1; 3.96 - simResults->timelineTraces[0]->spanRecs[0]->endTime=2; 3.97 - 3.98 - simResults->timelineTraces[0]->spanRecs[1]->spanSeqNum= 1; 3.99 - simResults->timelineTraces[0]->spanRecs[1]->spanType= NULL; 3.100 - simResults->timelineTraces[0]->spanRecs[1]->startTime= 5; 3.101 - simResults->timelineTraces[0]->spanRecs[1]->endTime=6; 3.102 - 3.103 - simResults->timelineTraces[1]->timeline= pongTimeline; 3.104 - simResults->timelineTraces[1]->numSpans= 2; 3.105 - simResults->timelineTraces[1]->spanRecs= malloc(simResults->timelineTraces[1]->numSpans*sizeof(HWSimSpanRec)); 3.106 + simResults->timelineTraces[1]->timeline= netlist->timelines[0]; 3.107 + simResults->timelineTraces[1]->spanRecs->spanSeqNum= 1; 3.108 + simResults->timelineTraces[1]->spanRecs->startTime= 5; 3.109 + simResults->timelineTraces[1]->spanRecs->endTime=6; 3.110 3.111 // 2 times a pong span 3.112 - simResults->timelineTraces[1]->spanRecs[0]->spanSeqNum= 2; // unique ??? 3.113 - simResults->timelineTraces[1]->spanRecs[0]->spanType= NULL; 3.114 - simResults->timelineTraces[1]->spanRecs[0]->startTime= 3; 3.115 - simResults->timelineTraces[1]->spanRecs[0]->endTime=4; 3.116 + simResults->timelineTraces[2]->timeline= netlist->timelines[1]; 3.117 + simResults->timelineTraces[2]->spanRecs->spanSeqNum= 2; // unique ??? 3.118 + simResults->timelineTraces[2]->spanRecs->startTime= 3; 3.119 + simResults->timelineTraces[2]->spanRecs->endTime=4; 3.120 3.121 - simResults->timelineTraces[1]->spanRecs[1]->spanSeqNum= 3; 3.122 - simResults->timelineTraces[1]->spanRecs[1]->spanType= NULL; 3.123 - simResults->timelineTraces[1]->spanRecs[1]->startTime= 7; 3.124 - simResults->timelineTraces[1]->spanRecs[1]->endTime=8; 3.125 + simResults->timelineTraces[3]->timeline= netlist->timelines[1]; 3.126 + simResults->timelineTraces[3]->spanRecs->spanSeqNum= 3; 3.127 + simResults->timelineTraces[3]->spanRecs->startTime= 7; 3.128 + simResults->timelineTraces[3]->spanRecs->endTime=8; 3.129 3.130 3.131 // a HWSimTimeline does not contain any helpful additional information to 3.132 @@ -62,39 +93,34 @@ 3.133 3.134 3.135 //-------------------- Coomunication Trace --------------------- 3.136 - simResults->numCommTraces= 3; 3.137 - simResults->commTrace= malloc(simResults->numCommTraces*sizeof(HWSimWireTrace)); 3.138 3.139 //ping to pong 2 - 3 3.140 - simResults->commTrace[0]->fromTimeline= pingTimeline; 3.141 - simResults->commTrace[0]->toTimeline= pongTimeline; 3.142 - simResults->commTrace[0]->numComms= 1; 3.143 - simResults->commTrace[0]->commRecs= malloc(sizeof(HWSimCommRec)); 3.144 - simResults->commTrace[0]->commRecs->commID= 0; 3.145 - simResults->commTrace[0]->commRecs->msgID= 0; 3.146 - simResults->commTrace[0]->commRecs->startTime= 2; 3.147 - simResults->commTrace[0]->commRecs->endTime= 3; 3.148 + simResults->commTraces[0]->fromTimeline= netlist->timelines[0]; 3.149 + simResults->commTraces[0]->toTimeline= netlist->timelines[1]; 3.150 + simResults->commTraces[0]->numComms= 1; 3.151 + simResults->commTraces[0]->commRecs->commID= 0; 3.152 + simResults->commTraces[0]->commRecs->msgID= 0; 3.153 + simResults->commTraces[0]->commRecs->startTime= 2; 3.154 + simResults->commTraces[0]->commRecs->endTime= 3; 3.155 3.156 //pong to ping 4 - 5 3.157 - simResults->commTrace[1]->fromTimeline= pongTimeline; 3.158 - simResults->commTrace[1]->toTimeline= pingTimeline; 3.159 - simResults->commTrace[1]->numComms= 1; 3.160 - simResults->commTrace[1]->commRecs= malloc(sizeof(HWSimCommRec)); 3.161 - simResults->commTrace[1]->commRecs->commID= 1; 3.162 - simResults->commTrace[1]->commRecs->msgID= 1; 3.163 - simResults->commTrace[1]->commRecs->startTime= 4; 3.164 - simResults->commTrace[1]->commRecs->endTime= 5; 3.165 + simResults->commTraces[1]->fromTimeline= netlist->timelines[1]; 3.166 + simResults->commTraces[1]->toTimeline= netlist->timelines[0]; 3.167 + simResults->commTraces[1]->numComms= 1; 3.168 + simResults->commTraces[1]->commRecs->commID= 1; 3.169 + simResults->commTraces[1]->commRecs->msgID= 1; 3.170 + simResults->commTraces[1]->commRecs->startTime= 4; 3.171 + simResults->commTraces[1]->commRecs->endTime= 5; 3.172 3.173 //ping to pong 6 - 7 3.174 - simResults->commTrace[2]->fromTimeline= pingTimeline; 3.175 - simResults->commTrace[2]->toTimeline= pongTimeline; 3.176 - simResults->commTrace[2]->numComms= 1; 3.177 - simResults->commTrace[2]->commRecs= malloc(sizeof(HWSimCommRec)); 3.178 - simResults->commTrace[2]->commRecs->commID= 2; 3.179 - simResults->commTrace[2]->commRecs->msgID= 0; 3.180 - simResults->commTrace[2]->commRecs->startTime= 6; 3.181 - simResults->commTrace[2]->commRecs->endTime= 7; 3.182 + simResults->commTraces[2]->fromTimeline= netlist->timelines[0]; 3.183 + simResults->commTraces[2]->toTimeline= netlist->timelines[1]; 3.184 + simResults->commTraces[2]->numComms= 1; 3.185 + simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec)); 3.186 + simResults->commTraces[2]->commRecs->commID= 2; 3.187 + simResults->commTraces[2]->commRecs->msgID= 0; 3.188 + simResults->commTraces[2]->commRecs->startTime= 6; 3.189 + simResults->commTraces[2]->commRecs->endTime= 7; 3.190 3.191 return simResults; 3.192 - 3.193 }
4.1 --- a/src/Application/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h Mon Dec 05 12:24:44 2011 +0100 4.2 +++ b/src/Application/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h Tue Dec 06 18:46:42 2011 +0100 4.3 @@ -1,1 +1,45 @@ 4.4 -/* 4.5 * Copyright 2011 OpenSourceStewardshipFoundation.org 4.6 * Licensed under GNU General Public License version 2 4.7 */ 4.8 4.9 4.10 #ifndef _HWSim_TERAFLUX_H_ 4.11 #define _HWSim_TERAFLUX_H_ 4.12 4.13 #include <stdio.h> 4.14 4.15 #include "../../HWSim_lib/HWSim.h" 4.16 4.17 4.18 //=============================== Defines ============================== 4.19 //Port 0 is unused, as a bug-catch 4.20 #define COMMUNICATOR_OUTPORT 1 4.21 4.22 4.23 //============================== Structures ============================== 4.24 typedef struct 4.25 { 4.26 } 4.27 PingPongParams; 4.28 4.29 4.30 //============================= Span Functions ========================= 4.31 void * 4.32 behaviorOf_ping_pong_span( void *_params, VirtProcr *timeLine ); 4.33 4.34 uint64 4.35 timingOf_ping_pong_span( void * dataFromBehaviorFn ); 4.36 4.37 4.38 #endif /**/ 4.39 4.40 \ No newline at end of file 4.41 +/* 4.42 + * Copyright 2011 OpenSourceStewardshipFoundation.org 4.43 + * Licensed under GNU General Public License version 2 4.44 + */ 4.45 + 4.46 + 4.47 +#ifndef _HWSim_TERAFLUX_H_ 4.48 +#define _HWSim_TERAFLUX_H_ 4.49 + 4.50 +#include <stdio.h> 4.51 + 4.52 +#include "../../HWSim_lib/HWSim.h" 4.53 + 4.54 + 4.55 +//=============================== Defines ============================== 4.56 + //Port 0 is unused, as a bug-catch 4.57 +#define COMMUNICATOR_OUTPORT 1 4.58 + 4.59 + 4.60 +//============================== Structures ============================== 4.61 +typedef struct 4.62 + { 4.63 + } 4.64 +PingPongParams; 4.65 + 4.66 + 4.67 +//============================= Span Functions ========================= 4.68 +void * 4.69 +behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeLine ); 4.70 + 4.71 +uint64 4.72 +timingOf_ping_pong_span( void * dataFromBehaviorFn ); 4.73 + 4.74 +//======================== Simulation Fake ================================== 4.75 +#ifdef FAKE 4.76 +HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist); 4.77 +#endif 4.78 + 4.79 +//======================== Netlist creation ================================== 4.80 + 4.81 +HWSimNetlist* createPingPongNetlist (); 4.82 + 4.83 +#endif /**/ 4.84 + 4.85 +
5.1 --- a/src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c Mon Dec 05 12:24:44 2011 +0100 5.2 +++ b/src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c Tue Dec 06 18:46:42 2011 +0100 5.3 @@ -1,1 +1,44 @@ 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 uint64 5.43 timingOf_ping_pong_span( void * dataFromBehaviorFn ) 5.44 { 5.45 return 10; 5.46 } 5.47 \ No newline at end of file 5.48 +/* 5.49 + * Copyright 2011 OpenSourceStewardshipFoundation.org 5.50 + * Licensed under GNU General Public License version 2 5.51 + * 5.52 + * Author: seanhalle@yahoo.com 5.53 + * 5.54 + */ 5.55 + 5.56 +#include "HWSim__Hello_World_HW.h" 5.57 + 5.58 + 5.59 + 5.60 +//==================================================================== 5.61 +/*This is the ping-pong timeline for the Hello World hardware 5.62 + * 5.63 + *It has only one kind of span, which only puts a communication on 5.64 + * the timeline's one out-port. 5.65 + * 5.66 + *The in-port has only one trigger registered on it, which fires that 5.67 + * span. 5.68 + */ 5.69 + 5.70 +#define NO_MSG NULL 5.71 +#define PORT0 0 5.72 + 5.73 +/* 5.74 + *Note, the returned value is passed to the timing function 5.75 + */ 5.76 +void * 5.77 +behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeline ) 5.78 + { 5.79 + PingPongParams *params; 5.80 + params = (PingPongParams *)_params; 5.81 +// DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) ); 5.82 + 5.83 + //HWSim__send_on_port( NO_MSG, PORT0, timeline ); 5.84 + } 5.85 + 5.86 +uint64 5.87 +timingOf_ping_pong_span( void * dataFromBehaviorFn ) 5.88 + { 5.89 + return 10; 5.90 + } 5.91 +
6.1 --- a/src/Application/SimParams.c Mon Dec 05 12:24:44 2011 +0100 6.2 +++ b/src/Application/SimParams.c Tue Dec 06 18:46:42 2011 +0100 6.3 @@ -1,1 +1,155 @@ 6.4 -/* 6.5 6.6 * Copyright 2009 OpenSourceStewardshipFoundation.org 6.7 6.8 * Licensed under GNU General Public License version 2 6.9 6.10 * 6.11 6.12 * Author: seanhalle@yahoo.com 6.13 6.14 * 6.15 6.16 * Created on November 15, 2009, 2:35 AM 6.17 6.18 */ 6.19 6.20 6.21 6.22 #include <malloc.h> 6.23 6.24 #include <stdlib.h> 6.25 6.26 6.27 6.28 #include "SimParams.h" 6.29 6.30 #include "ParamHelper/Param.h" 6.31 6.32 6.33 6.34 6.35 6.36 uint8 * 6.37 6.38 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); 6.39 6.40 6.41 6.42 6.43 6.44 void 6.45 6.46 fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) 6.47 6.48 { char *guestAppFileName, *systemCodeFileName; 6.49 6.50 int numBytesInGuestApp, numBytesInSystemCode; 6.51 6.52 6.53 6.54 ParamStruc *param; 6.55 6.56 param = getParamFromBag( "GuestApplicationFileName", paramBag ); 6.57 6.58 guestAppFileName = param->strValue; 6.59 6.60 param = getParamFromBag( "numBytesInGuestApp", paramBag ); 6.61 6.62 numBytesInGuestApp = param->intValue; 6.63 6.64 6.65 6.66 simParams->guestApp = 6.67 6.68 read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); 6.69 6.70 6.71 6.72 param = getParamFromBag( "SystemCodeFileName", paramBag ); 6.73 6.74 systemCodeFileName = param->strValue; 6.75 6.76 param = getParamFromBag( "numBytesInSystemCode", paramBag ); 6.77 6.78 numBytesInSystemCode = param->intValue; 6.79 6.80 6.81 6.82 simParams->systemCode = 6.83 6.84 read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); 6.85 6.86 6.87 6.88 6.89 6.90 param = getParamFromBag( "numNodes", paramBag ); 6.91 6.92 simParams->numNodes = param->intValue; 6.93 6.94 6.95 6.96 } 6.97 6.98 6.99 6.100 6.101 6.102 6.103 6.104 uint8 * 6.105 6.106 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) 6.107 6.108 { int byte; 6.109 6.110 FILE *file; 6.111 6.112 char *machineCode = malloc( numBytesInFile ); 6.113 6.114 if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); 6.115 6.116 6.117 6.118 file = fopen( machineCodeFileName, "r" ); 6.119 6.120 if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} 6.121 6.122 6.123 6.124 fseek( file, 0, SEEK_SET ); 6.125 6.126 for( byte = 0; byte < numBytesInFile; byte++ ) 6.127 6.128 { 6.129 6.130 if( feof( file ) ) printf( "file ran out too soon" ); 6.131 6.132 machineCode[byte] = getchar( file ); 6.133 6.134 6.135 6.136 } 6.137 6.138 return machineCode; 6.139 6.140 } 6.141 6.142 6.143 6.144 6.145 6.146 //========================================================================== 6.147 6.148 void 6.149 6.150 printSimResults( SimulationResults simResults ) 6.151 6.152 { 6.153 6.154 } 6.155 6.156 6.157 6.158 \ No newline at end of file 6.159 +/* 6.160 + 6.161 + * Copyright 2009 OpenSourceStewardshipFoundation.org 6.162 + 6.163 + * Licensed under GNU General Public License version 2 6.164 + 6.165 + * 6.166 + 6.167 + * Author: seanhalle@yahoo.com 6.168 + 6.169 + * 6.170 + 6.171 + * Created on November 15, 2009, 2:35 AM 6.172 + 6.173 + */ 6.174 + 6.175 + 6.176 + 6.177 +#include <malloc.h> 6.178 + 6.179 +#include <stdlib.h> 6.180 + 6.181 + 6.182 + 6.183 +#include "SimParams.h" 6.184 + 6.185 +#include "ParamHelper/Param.h" 6.186 + 6.187 + 6.188 + 6.189 + 6.190 + 6.191 +uint8 * 6.192 + 6.193 +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); 6.194 + 6.195 + 6.196 + 6.197 + 6.198 + 6.199 +void 6.200 + 6.201 +fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) 6.202 + 6.203 + { char *guestAppFileName, *systemCodeFileName; 6.204 + 6.205 + int numBytesInGuestApp, numBytesInSystemCode; 6.206 + 6.207 + 6.208 + 6.209 + ParamStruc *param; 6.210 + 6.211 + //param = getParamFromBag( "GuestApplicationFileName", paramBag ); 6.212 + 6.213 + guestAppFileName = param->strValue; 6.214 + 6.215 + //param = getParamFromBag( "numBytesInGuestApp", paramBag ); 6.216 + 6.217 + numBytesInGuestApp = param->intValue; 6.218 + 6.219 + 6.220 + 6.221 + simParams->guestApp = 6.222 + 6.223 + read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); 6.224 + 6.225 + 6.226 + 6.227 + //param = getParamFromBag( "SystemCodeFileName", paramBag ); 6.228 + 6.229 + systemCodeFileName = param->strValue; 6.230 + 6.231 + //param = getParamFromBag( "numBytesInSystemCode", paramBag ); 6.232 + 6.233 + numBytesInSystemCode = param->intValue; 6.234 + 6.235 + 6.236 + 6.237 + simParams->systemCode = 6.238 + 6.239 + read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); 6.240 + 6.241 + 6.242 + 6.243 + 6.244 + 6.245 + //param = getParamFromBag( "numNodes", paramBag ); 6.246 + 6.247 + simParams->numNodes = param->intValue; 6.248 + 6.249 + 6.250 + 6.251 + } 6.252 + 6.253 + 6.254 + 6.255 + 6.256 + 6.257 + 6.258 + 6.259 +uint8 * 6.260 + 6.261 +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) 6.262 + 6.263 + { int byte; 6.264 + 6.265 + FILE *file; 6.266 + 6.267 + char *machineCode = malloc( numBytesInFile ); 6.268 + 6.269 + if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); 6.270 + 6.271 + 6.272 + 6.273 + file = fopen( machineCodeFileName, "r" ); 6.274 + 6.275 + if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} 6.276 + 6.277 + 6.278 + 6.279 + fseek( file, 0, SEEK_SET ); 6.280 + 6.281 + for( byte = 0; byte < numBytesInFile; byte++ ) 6.282 + 6.283 + { 6.284 + 6.285 + if( feof( file ) ) printf( "file ran out too soon" ); 6.286 + 6.287 +// machineCode[byte] = getchar( file ); 6.288 + 6.289 + 6.290 + 6.291 + } 6.292 + 6.293 + return machineCode; 6.294 + 6.295 + } 6.296 + 6.297 + 6.298 + 6.299 + 6.300 + 6.301 + //========================================================================== 6.302 + 6.303 +void 6.304 + 6.305 +printSimResults( SimulationResults simResults ) 6.306 + 6.307 + { 6.308 + 6.309 + } 6.310 + 6.311 + 6.312 + 6.313 +
7.1 --- a/src/Application/SimParams.h Mon Dec 05 12:24:44 2011 +0100 7.2 +++ b/src/Application/SimParams.h Tue Dec 06 18:46:42 2011 +0100 7.3 @@ -1,1 +1,45 @@ 7.4 -/* 7.5 * Copyright 2011 OpenSourceStewardshipFoundation.org 7.6 * Licensed under GNU General Public License version 2 7.7 */ 7.8 7.9 #ifndef SIM_PARAMS_ 7.10 #define SIM_PARAMS_ 7.11 7.12 #include <stdio.h> 7.13 #include <unistd.h> 7.14 #include <malloc.h> 7.15 7.16 #include "../HWSim_lib/VMS/VMS_primitive_data_types.h" 7.17 #include "ParamHelper/Param.h" 7.18 7.19 7.20 //============================== Structures ============================== 7.21 typedef struct 7.22 { uint8 *guestApp; 7.23 uint8 *systemCode; 7.24 int32 numNodes; 7.25 } 7.26 SimulationResults; 7.27 7.28 typedef struct 7.29 { uint8 *guestApp; 7.30 uint8 *systemCode; 7.31 int32 numNodes; 7.32 SimulationResults *simResults; 7.33 } 7.34 SimulationParams; 7.35 7.36 //============================== Functions ================================ 7.37 void 7.38 printSimResults( SimulationResults simResults ); 7.39 7.40 void 7.41 fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ); 7.42 7.43 7.44 //=========================================================================== 7.45 7.46 #endif /**/ 7.47 7.48 \ No newline at end of file 7.49 +/* 7.50 + * Copyright 2011 OpenSourceStewardshipFoundation.org 7.51 + * Licensed under GNU General Public License version 2 7.52 + */ 7.53 + 7.54 +#ifndef SIM_PARAMS_ 7.55 +#define SIM_PARAMS_ 7.56 + 7.57 +#include <stdio.h> 7.58 +#include <unistd.h> 7.59 +#include <malloc.h> 7.60 + 7.61 +#include "../HWSim_lib/VMS/VMS_primitive_data_types.h" 7.62 +#include "ParamHelper/Param.h" 7.63 + 7.64 + 7.65 +//============================== Structures ============================== 7.66 +typedef struct 7.67 + { uint8 *guestApp; 7.68 + uint8 *systemCode; 7.69 + int32 numNodes; 7.70 + } 7.71 +SimulationResults; 7.72 + 7.73 +typedef struct 7.74 + { uint8 *guestApp; 7.75 + uint8 *systemCode; 7.76 + int32 numNodes; 7.77 + SimulationResults *simResults; 7.78 + } 7.79 +SimulationParams; 7.80 + 7.81 +//============================== Functions ================================ 7.82 +void 7.83 +printSimResults( SimulationResults simResults ); 7.84 + 7.85 +void 7.86 +fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ); 7.87 + 7.88 + 7.89 +//=========================================================================== 7.90 + 7.91 +#endif /**/ 7.92 + 7.93 +
8.1 --- a/src/Application/main.c Mon Dec 05 12:24:44 2011 +0100 8.2 +++ b/src/Application/main.c Tue Dec 06 18:46:42 2011 +0100 8.3 @@ -11,6 +11,10 @@ 8.4 #include "SimParams.h" 8.5 #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 8.6 8.7 +char __ProgrammName[] = "HWSim Hello World"; 8.8 +char __DataSet[255]; 8.9 +char __Scheduler[]; 8.10 + 8.11 /* 8.12 * 8.13 * 8.14 @@ -22,17 +26,26 @@ 8.15 HWSimResults *simResults; 8.16 8.17 printf( "param file name: %s\n", argv[1] ); 8.18 + printf("Paraver trace file %s\n", argv[2]); 8.19 8.20 +#ifdef FAKE 8.21 + simParams= NULL; 8.22 +#else 8.23 simParams = makeParamBag(); 8.24 readParamFileIntoBag( argv[1], simParams ); 8.25 +#endif 8.26 8.27 netlist = createPingPongNetlist(); 8.28 +#ifdef FAKE 8.29 + simResults= create_simulation_results__fake(simParams,netlist); 8.30 +#else 8.31 simResults = 8.32 HWSim__run_simulation( simParams, netlist ); 8.33 +#endif 8.34 8.35 //HWSim 8.36 - HWSim__generate_paraver_output( simResults ); 8.37 - HWSim__generate_vcd_output( simResults ); 8.38 + HWSim__generate_paraver_output(argv[2], simResults, netlist); 8.39 + //HWSim__generate_vcd_output( simResults ); 8.40 8.41 exit(0); //cleans up 8.42 }