# HG changeset patch # User Me@portablequad # Date 1325721049 28800 # Node ID 3276b8621f96678eb27d2582f99ea47d2186d961 # Parent 648207f2e38fdd97d1c38d6a0fbfd446cca52b6f# Parent 55d3ca21bccda107ab4ea32d2ad44e9f32c570a2 Merged -- issues with line endings, tried adding .hgeol.. see what happens diff -r 648207f2e38f -r 3276b8621f96 src/Application/CircuitNetlistCreator.c --- a/src/Application/CircuitNetlistCreator.c Tue Dec 06 18:46:42 2011 +0100 +++ b/src/Application/CircuitNetlistCreator.c Wed Jan 04 15:50:49 2012 -0800 @@ -5,153 +5,95 @@ * Author: seanhalle@yahoo.com * */ - -#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" - -HWSimTimeline* createAPingPongTimeline (); - - + #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" + +/*'wire' is an expr resolves to an actual wire struct instance + */ +#define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\ +do{\ + wire.idxOfFromTimeline = fromTLIdx; \ + wire.idxOfFromOutPort = fromTLIdx; \ + wire.idxOfToTimeline = toTLIdx; \ + wire.idxOfToInPort = inPort; \ + wire.archSpecWireData = dataPtr; \ + }while(0); //macro magic for namespace + /*This file constructs the netlist for the Hello World circuit, which is * used during design and implementation of the HWSim language - * + * *It has two timelines, each with one input port and one output port, and * a single span-type. * *The timelines are cross-coupled, so output port of one connects to input * port of the other. The input port has a single trigger, which fires * the one span-type. - * + * *The span does nothing, except send a NULL message on the output port. - * *The span-sim-time and communication-sim-time are both constants. * *Note that timelines are generic. They are specialized by declaring * inports and outports, and by registering triggers that fire particular * span-types. */ -HWSimNetlist * -createPingPongNetlist() - { HWSimNetlist *netlist; - HWSimWire **wires; - HWSimTimeline **timelines; - +HWSimNetlist *createPingPongNetlist() + { HWSimNetlist *netlist; + NetlistWire *wires; + HWSimTimeline **timelines; int numTimelines; int numWires; - - int i; - + netlist = malloc( sizeof(HWSimNetlist) ); - - //declare timelines - numTimelines = 2; - timelines = malloc( numTimelines * sizeof(HWSimTimeline *) ); + //declare timelines numTimelines = 2; + timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); netlist->numTimelines = numTimelines; netlist->timelines = timelines; - - timelines[0] = createAPingPongTimeline(0); - timelines[1] = createAPingPongTimeline(1); - - //add a trigger to reset port of one of the timelines, to start things - HWSimSpanType *pingPongSpan; - pingPongSpan = malloc( sizeof(HWSimSpanType) ); - pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; - pingPongSpan->timingFn = (void *)&(timingOf_ping_pong_span); - - timelines[1]->triggers[0]->inPortNum = -1;//the reset port - timelines[1]->triggers[0]->spanType = pingPongSpan; - - //Connect timelines together - numWires = 2; - wires = malloc( numWires * sizeof(HWSimWire *) ); - for (i= 0; inumSpanTypes = 1; + netlist->spanTypes = malloc(netlist->numSpanTypes*sizeof(HWSimSpanType*)); + netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType(); + timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist + timelines[1] = createAPingPongTimeline( netlist ); + //on one of the timelines, make reset trigger an action + timelines[1]->inPorts[-1].triggeredSpanType = + netlist->spanTypes PING_PONG_TYPE]; //Connect timelines together + + /*OutPorts and InPorts may have many wires attached, but an inPort only + * has one kind of span that all incoming communications trigger. That + * span can be zero time and then switch on the type of message then + * end with a continuation, where the continuation span is chosen by the + * switch. + *So, a wire only connects an out port to an in port + *The format is: sending TL-index, out-port, dest TL-index, in-port + */ + numWires = 2; + wires = malloc( numWires * sizeof(NetlistWire) ); netlist->numWires = numWires; netlist->wires = wires; - - //TODO:For wires, have many design decisions to make -- driven by impl, so - // have to be delayed until get into guts of impl. - //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array - //TODO: decide if each wire transports only one kind of message or many - //TODO: decide if inports accept one wire or many (msg type set by inport) - //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 - wires[0]->idxOfFromTimeline= 0; - wires[0]->fromOutPort= 0; - wires[0]->idxOfToTimeline= 1; - wires[0]->toInPort= 0; - wires[0]->msgType= 0; - wires[1]->idxOfFromTimeline= 1; - wires[1]->fromOutPort= 0; - wires[1]->idxOfToTimeline= 0; - wires[1]->toInPort= 0; - wires[1]->msgType= 0; - - -/* For starters, not doing time-domains.. will add later (Nov 2011) - //Create time domains - numTimeDomains = 2; - timeDomains = malloc( numTimeDomains * sizeof(TimeDomain) ); - netlist->numTimeDomains = numTimeDomains; - netlist->timeDomains = timeDomains; - - timeDomains[0]->numDomains = 0; - timeDomains[0]->numTimelines = 1; - timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[] - - timeDomains[1]->numDomains = 0; - timeDomains[1]->numTimelines = 1; - timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[] - - //Create time domain connections -- must respect hierarchy - numDomainConnections = 2; - domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) ); - netlist->numDomainConns = numDomainConnections; - netlist->domainConns = domainConnects; - - domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1 - domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 0 - */ - - return netlist; + //TL 0, out-port 0 to TL 1, in-port 0 + setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into + setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create + //TODO: decide how do in-out bidirectional wires -- thinking make it two + // separate wires with guard between in-port and out-port + //TODO: decide how do guards between ports } - + + //Note: copy netlist struct with VMS malloc after VMS initialized HWSimTimeline * -createAPingPongTimeline(int timelineID) - { HWSimTimeline *tl; - int i; -// HWSimTrigger **triggers; - - tl = malloc( sizeof(HWSimTimeline) ); - - tl->timelineID= timelineID; - tl->numInPorts = 1; - tl->numOutPorts = 1; - tl->numTriggers = 2; - - tl->triggers = malloc( 2 * sizeof(HWSimTrigger *) ); //extra is reset trig - for (i= 0; inumTriggers; i++) { - tl->triggers[i]= malloc(sizeof(HWSimTrigger)); - } - - - // FIXME general IDLE_SPAN - HWSimSpanType *idleSpan; - idleSpan= malloc(sizeof(HWSimSpanType)); - idleSpan->behaviorFn= NULL; - idleSpan->timingFn= NULL; - - - tl->triggers[0]->inPortNum = -1; //reset trigger - tl->triggers[0]->spanType = idleSpan; - - HWSimSpanType *pingPongSpan; - pingPongSpan = malloc( sizeof(HWSimSpanType) ); - pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; - pingPongSpan->timingFn = (void *)&timingOf_ping_pong_span; - - tl->triggers[1]->inPortNum = 0; //TODO: Debug: verify whether . or -> - tl->triggers[1]->spanType = pingPongSpan; - - return tl; +createAPingPongTimeline( HWSimNetlist *netlist ) + { HWSimTimeline *TL; + TL = malloc( sizeof(HWSimTimeline) ); + TL->numInPorts = 1; + TL->numOutPorts = 1; + TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); + TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port + TL->inPorts[0].triggeredSpanType = netlist->spanTypes[PING_PONG_TYPE]; } - + +HWSimSpanType * +createPingPongSpanType( ) + { HWSimSpanType *pingPongSpanType; + pingPongSpanType = malloc( sizeof(HWSimSpanType) ); + pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; + pingPongSpanType->timingFn = &timingOf_ping_pong_span; + return pingPongSpanType; + } + \ No newline at end of file diff -r 648207f2e38f -r 3276b8621f96 src/Application/main.c --- a/src/Application/main.c Tue Dec 06 18:46:42 2011 +0100 +++ b/src/Application/main.c Wed Jan 04 15:50:49 2012 -0800 @@ -1,52 +1,52 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under BSD - * - * author seanhalle@yahoo.com - */ - -#include -#include - -#include "SimParams.h" -#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" - -char __ProgrammName[] = "HWSim Hello World"; -char __DataSet[255]; -char __Scheduler[]; - -/* - * - * - */ - -int main( int argc, char **argv ) - { ParamBag *simParams; - HWSimNetlist *netlist; - HWSimResults *simResults; - - printf( "param file name: %s\n", argv[1] ); - printf("Paraver trace file %s\n", argv[2]); - -#ifdef FAKE - simParams= NULL; -#else - simParams = makeParamBag(); - readParamFileIntoBag( argv[1], simParams ); -#endif - - netlist = createPingPongNetlist(); -#ifdef FAKE - simResults= create_simulation_results__fake(simParams,netlist); -#else - simResults = - HWSim__run_simulation( simParams, netlist ); -#endif - - //HWSim - HWSim__generate_paraver_output(argv[2], simResults, netlist); - //HWSim__generate_vcd_output( simResults ); - - exit(0); //cleans up - } - +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under BSD + * + * author seanhalle@yahoo.com + */ + +#include +#include + +#include "SimParams.h" +#include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" + +char __ProgrammName[] = "HWSim Hello World"; +char __DataSet[255]; +char __Scheduler[]; + +/* + * + * + */ + +int main( int argc, char **argv ) + { ParamBag *simParams; + HWSimNetlist *netlist; + HWSimResults *simResults; + + printf( "param file name: %s\n", argv[1] ); + printf("Paraver trace file %s\n", argv[2]); + +#ifdef FAKE + simParams= NULL; +#else + simParams = makeParamBag(); + readParamFileIntoBag( argv[1], simParams ); +#endif + + netlist = createPingPongNetlist(); +#ifdef FAKE + simResults= create_simulation_results__fake(simParams,netlist); +#else + simResults = + HWSim__run_simulation( simParams, netlist ); +#endif + + //HWSim + HWSim__generate_paraver_output(argv[2], simResults, netlist); + //HWSim__generate_vcd_output( simResults ); + + exit(0); //cleans up + } +