# HG changeset patch # User Me@portablequad # Date 1325987110 28800 # Node ID a587ea56af8e653fb0c9ef73b9b352446a2593f8 # Parent aa78c6edf3b8b6d08ba1115ac3e92c58846a2dc0 changed directory structure -- thin project repository with this as sub-repo diff -r aa78c6edf3b8 -r a587ea56af8e .hgeol --- a/.hgeol Wed Jan 04 16:41:01 2012 -0800 +++ b/.hgeol Sat Jan 07 17:45:10 2012 -0800 @@ -6,6 +6,8 @@ **.h = native **.cpp = native **.java = native +**.class = bin +**.jar = bin **.sh = native **.pl = native **.jpg = bin diff -r aa78c6edf3b8 -r a587ea56af8e .hgsub --- a/.hgsub Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -src/HWSim_lib = ../HWSim_lib - diff -r aa78c6edf3b8 -r a587ea56af8e .hgsubstate --- a/.hgsubstate Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -6be14b09d97682a430fb90756b4a9644162c7be9 src/HWSim_lib diff -r aa78c6edf3b8 -r a587ea56af8e CircuitNetlistCreator.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CircuitNetlistCreator.c Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,99 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + #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; + NetlistWire *wires; + HWSimTimeline **timelines; + int numTimelines; + int numWires; + + netlist = malloc( sizeof(HWSimNetlist) ); + //declare timelines numTimelines = 2; + timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); + netlist->numTimelines = numTimelines; + netlist->timelines = timelines; + netlist->numSpanTypes = 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; + //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( 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 aa78c6edf3b8 -r a587ea56af8e HWSim__Hello_World_HW/FakeSim.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__Hello_World_HW/FakeSim.c Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,126 @@ +#include +#include "HWSim__Hello_World_HW.h" + +void checkMalloc (void *ptr) { + if (ptr == NULL) { + printf("Memory allocation failed!\n"); + exit(1); + } +} + +HWSimTimeline* malloc_timlines (int nrTimelines) { + HWSimTimeline *timelines; + int i; + + timelines= malloc(nrTimelines*(sizeof(HWSimTimeline))); + checkMalloc(timelines); + for (i= 0; inumTimelines= nrExecutions; + simResults->timelineTraces= + malloc(simResults->numTimelines*sizeof(HWSimTimelineTrace *)); + + for (i= 0; inumTimelines; i++) { + simResults->timelineTraces[i]= malloc(sizeof(HWSimTimelineTrace)); + checkMalloc(simResults->timelineTraces[i]); + simResults->timelineTraces[i]->spanRecs= malloc(sizeof(HWSimSpanRec)); + } + + simResults->numCommTraces= nrComms; + simResults->commTraces= + malloc(simResults->numCommTraces*sizeof(HWSimWireTrace *)); + checkMalloc(simResults->commTraces); + for (i= 0; inumCommTraces; i++) { + simResults->commTraces[i]= malloc(sizeof(HWSimWireTrace)); + checkMalloc(simResults->commTraces[i]); + // FRAGILE -> valgrind + simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec)); + checkMalloc(simResults->commTraces[i]->commRecs); + } + + return simResults; +} + +HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) { + HWSimResults *simResults; + + simResults= malloc_simResults(4,3); + + //--------------- timelineTraces ------------------------------------ + // 2 times a ping span + simResults->timelineTraces[0]->timeline= netlist->timelines[0]; + simResults->timelineTraces[0]->spanRecs->spanSeqNum= 0; // unique ??? + simResults->timelineTraces[0]->spanRecs->startTime= 1; + simResults->timelineTraces[0]->spanRecs->endTime=2; + + simResults->timelineTraces[1]->timeline= netlist->timelines[0]; + simResults->timelineTraces[1]->spanRecs->spanSeqNum= 1; + simResults->timelineTraces[1]->spanRecs->startTime= 5; + simResults->timelineTraces[1]->spanRecs->endTime=6; + + // 2 times a pong span + simResults->timelineTraces[2]->timeline= netlist->timelines[1]; + simResults->timelineTraces[2]->spanRecs->spanSeqNum= 2; // unique ??? + simResults->timelineTraces[2]->spanRecs->startTime= 3; + simResults->timelineTraces[2]->spanRecs->endTime=4; + + simResults->timelineTraces[3]->timeline= netlist->timelines[1]; + simResults->timelineTraces[3]->spanRecs->spanSeqNum= 3; + simResults->timelineTraces[3]->spanRecs->startTime= 7; + simResults->timelineTraces[3]->spanRecs->endTime=8; + + + // a HWSimTimeline does not contain any helpful additional information to + // identify or label a Timeline . + // But a unique Timeline identifier is disireable. Therefore at the moment the + // procrID of the anumating Procr ist used + + // Information about the Span is required, at least a ID.The current + // spanType doesn't provide it + + + //-------------------- Coomunication Trace --------------------- + + //ping to pong 2 - 3 + simResults->commTraces[0]->fromTimeline= netlist->timelines[0]; + simResults->commTraces[0]->toTimeline= netlist->timelines[1]; + simResults->commTraces[0]->numComms= 1; + simResults->commTraces[0]->commRecs->commID= 0; + simResults->commTraces[0]->commRecs->msgID= 0; + simResults->commTraces[0]->commRecs->startTime= 2; + simResults->commTraces[0]->commRecs->endTime= 3; + + //pong to ping 4 - 5 + simResults->commTraces[1]->fromTimeline= netlist->timelines[1]; + simResults->commTraces[1]->toTimeline= netlist->timelines[0]; + simResults->commTraces[1]->numComms= 1; + simResults->commTraces[1]->commRecs->commID= 1; + simResults->commTraces[1]->commRecs->msgID= 1; + simResults->commTraces[1]->commRecs->startTime= 4; + simResults->commTraces[1]->commRecs->endTime= 5; + + //ping to pong 6 - 7 + simResults->commTraces[2]->fromTimeline= netlist->timelines[0]; + simResults->commTraces[2]->toTimeline= netlist->timelines[1]; + simResults->commTraces[2]->numComms= 1; + simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec)); + simResults->commTraces[2]->commRecs->commID= 2; + simResults->commTraces[2]->commRecs->msgID= 0; + simResults->commTraces[2]->commRecs->startTime= 6; + simResults->commTraces[2]->commRecs->endTime= 7; + + return simResults; +} diff -r aa78c6edf3b8 -r a587ea56af8e HWSim__Hello_World_HW/HWSim__Hello_World_HW.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,45 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + */ + + +#ifndef _HWSim_TERAFLUX_H_ +#define _HWSim_TERAFLUX_H_ + +#include + +#include "../../HWSim_lib/HWSim.h" + + +//=============================== Defines ============================== + //Port 0 is unused, as a bug-catch +#define COMMUNICATOR_OUTPORT 1 + + +//============================== Structures ============================== +typedef struct + { + } +PingPongParams; + + +//============================= Span Functions ========================= +void * +behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeLine ); + +uint64 +timingOf_ping_pong_span( void * dataFromBehaviorFn ); + +//======================== Simulation Fake ================================== +#ifdef FAKE +HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist); +#endif + +//======================== Netlist creation ================================== + +HWSimNetlist* createPingPongNetlist (); + +#endif /**/ + + diff -r aa78c6edf3b8 -r a587ea56af8e HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,1 @@ +Implementing the hardware model This is the "hello world" for HWSim. It is hardware that has just two timelines that send a message back and forth between them. The message has no content, it simply triggers the other timeline, which then sends the same empty message back, repeating the cycle. Each timeline has one in-port and one out-port. The out-port of the first timeline is connected to the in-port of the second and vice-versa. The code of the span consists only of sending an empty message on the timeline's out-port. The trigger for the span is registered on the in-port and message type 0. The span timing is a constant. The port-to-port timing is a constant. Both timelines are in the same time-domain. at_reset of one timeline is set to the ping-pong span, the other timeline's at_reset is set to idle. And that is the entire hardware. \ No newline at end of file diff -r aa78c6edf3b8 -r a587ea56af8e HWSim__Hello_World_HW/PingPong_TimeLine.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__Hello_World_HW/PingPong_TimeLine.c Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,44 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#include "HWSim__Hello_World_HW.h" + + + +//==================================================================== +/*This is the ping-pong timeline for the Hello World hardware + * + *It has only one kind of span, which only puts a communication on + * the timeline's one out-port. + * + *The in-port has only one trigger registered on it, which fires that + * span. + */ + +#define NO_MSG NULL +#define PORT0 0 + +/* + *Note, the returned value is passed to the timing function + */ +void * +behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeline ) + { + PingPongParams *params; + params = (PingPongParams *)_params; +// DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) ); + + //HWSim__send_on_port( NO_MSG, PORT0, timeline ); + } + +uint64 +timingOf_ping_pong_span( void * dataFromBehaviorFn ) + { + return 10; + } + diff -r aa78c6edf3b8 -r a587ea56af8e SimParams.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SimParams.c Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,155 @@ +/* + + * Copyright 2009 OpenSourceStewardshipFoundation.org + + * Licensed under GNU General Public License version 2 + + * + + * Author: seanhalle@yahoo.com + + * + + * Created on November 15, 2009, 2:35 AM + + */ + + + +#include + +#include + + + +#include "SimParams.h" + +#include "ParamHelper/Param.h" + + + + + +uint8 * + +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); + + + + + +void + +fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) + + { char *guestAppFileName, *systemCodeFileName; + + int numBytesInGuestApp, numBytesInSystemCode; + + + + ParamStruc *param; + + //param = getParamFromBag( "GuestApplicationFileName", paramBag ); + + guestAppFileName = param->strValue; + + //param = getParamFromBag( "numBytesInGuestApp", paramBag ); + + numBytesInGuestApp = param->intValue; + + + + simParams->guestApp = + + read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); + + + + //param = getParamFromBag( "SystemCodeFileName", paramBag ); + + systemCodeFileName = param->strValue; + + //param = getParamFromBag( "numBytesInSystemCode", paramBag ); + + numBytesInSystemCode = param->intValue; + + + + simParams->systemCode = + + read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); + + + + + + //param = getParamFromBag( "numNodes", paramBag ); + + simParams->numNodes = param->intValue; + + + + } + + + + + + + +uint8 * + +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) + + { int byte; + + FILE *file; + + char *machineCode = malloc( numBytesInFile ); + + if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); + + + + file = fopen( machineCodeFileName, "r" ); + + if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} + + + + fseek( file, 0, SEEK_SET ); + + for( byte = 0; byte < numBytesInFile; byte++ ) + + { + + if( feof( file ) ) printf( "file ran out too soon" ); + +// machineCode[byte] = getchar( file ); + + + + } + + return machineCode; + + } + + + + + + //========================================================================== + +void + +printSimResults( SimulationResults simResults ) + + { + + } + + + + diff -r aa78c6edf3b8 -r a587ea56af8e SimParams.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SimParams.h Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +1,45 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef SIM_PARAMS_ +#define SIM_PARAMS_ + +#include +#include +#include + +#include "../HWSim_lib/VMS/VMS_primitive_data_types.h" +#include "ParamHelper/Param.h" + + +//============================== Structures ============================== +typedef struct + { uint8 *guestApp; + uint8 *systemCode; + int32 numNodes; + } +SimulationResults; + +typedef struct + { uint8 *guestApp; + uint8 *systemCode; + int32 numNodes; + SimulationResults *simResults; + } +SimulationParams; + +//============================== Functions ================================ +void +printSimResults( SimulationResults simResults ); + +void +fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ); + + +//=========================================================================== + +#endif /**/ + + diff -r aa78c6edf3b8 -r a587ea56af8e main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Sat Jan 07 17:45:10 2012 -0800 @@ -0,0 +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 + } + diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/CircuitNetlistCreator.c --- a/src/Application/CircuitNetlistCreator.c Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - #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; - NetlistWire *wires; - HWSimTimeline **timelines; - int numTimelines; - int numWires; - - netlist = malloc( sizeof(HWSimNetlist) ); - //declare timelines numTimelines = 2; - timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); - netlist->numTimelines = numTimelines; - netlist->timelines = timelines; - netlist->numSpanTypes = 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; - //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( 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 aa78c6edf3b8 -r a587ea56af8e src/Application/HWSim__Hello_World_HW/FakeSim.c --- a/src/Application/HWSim__Hello_World_HW/FakeSim.c Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -#include -#include "HWSim__Hello_World_HW.h" - -void checkMalloc (void *ptr) { - if (ptr == NULL) { - printf("Memory allocation failed!\n"); - exit(1); - } -} - -HWSimTimeline* malloc_timlines (int nrTimelines) { - HWSimTimeline *timelines; - int i; - - timelines= malloc(nrTimelines*(sizeof(HWSimTimeline))); - checkMalloc(timelines); - for (i= 0; inumTimelines= nrExecutions; - simResults->timelineTraces= - malloc(simResults->numTimelines*sizeof(HWSimTimelineTrace *)); - - for (i= 0; inumTimelines; i++) { - simResults->timelineTraces[i]= malloc(sizeof(HWSimTimelineTrace)); - checkMalloc(simResults->timelineTraces[i]); - simResults->timelineTraces[i]->spanRecs= malloc(sizeof(HWSimSpanRec)); - } - - simResults->numCommTraces= nrComms; - simResults->commTraces= - malloc(simResults->numCommTraces*sizeof(HWSimWireTrace *)); - checkMalloc(simResults->commTraces); - for (i= 0; inumCommTraces; i++) { - simResults->commTraces[i]= malloc(sizeof(HWSimWireTrace)); - checkMalloc(simResults->commTraces[i]); - // FRAGILE -> valgrind - simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec)); - checkMalloc(simResults->commTraces[i]->commRecs); - } - - return simResults; -} - -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) { - HWSimResults *simResults; - - simResults= malloc_simResults(4,3); - - //--------------- timelineTraces ------------------------------------ - // 2 times a ping span - simResults->timelineTraces[0]->timeline= netlist->timelines[0]; - simResults->timelineTraces[0]->spanRecs->spanSeqNum= 0; // unique ??? - simResults->timelineTraces[0]->spanRecs->startTime= 1; - simResults->timelineTraces[0]->spanRecs->endTime=2; - - simResults->timelineTraces[1]->timeline= netlist->timelines[0]; - simResults->timelineTraces[1]->spanRecs->spanSeqNum= 1; - simResults->timelineTraces[1]->spanRecs->startTime= 5; - simResults->timelineTraces[1]->spanRecs->endTime=6; - - // 2 times a pong span - simResults->timelineTraces[2]->timeline= netlist->timelines[1]; - simResults->timelineTraces[2]->spanRecs->spanSeqNum= 2; // unique ??? - simResults->timelineTraces[2]->spanRecs->startTime= 3; - simResults->timelineTraces[2]->spanRecs->endTime=4; - - simResults->timelineTraces[3]->timeline= netlist->timelines[1]; - simResults->timelineTraces[3]->spanRecs->spanSeqNum= 3; - simResults->timelineTraces[3]->spanRecs->startTime= 7; - simResults->timelineTraces[3]->spanRecs->endTime=8; - - - // a HWSimTimeline does not contain any helpful additional information to - // identify or label a Timeline . - // But a unique Timeline identifier is disireable. Therefore at the moment the - // procrID of the anumating Procr ist used - - // Information about the Span is required, at least a ID.The current - // spanType doesn't provide it - - - //-------------------- Coomunication Trace --------------------- - - //ping to pong 2 - 3 - simResults->commTraces[0]->fromTimeline= netlist->timelines[0]; - simResults->commTraces[0]->toTimeline= netlist->timelines[1]; - simResults->commTraces[0]->numComms= 1; - simResults->commTraces[0]->commRecs->commID= 0; - simResults->commTraces[0]->commRecs->msgID= 0; - simResults->commTraces[0]->commRecs->startTime= 2; - simResults->commTraces[0]->commRecs->endTime= 3; - - //pong to ping 4 - 5 - simResults->commTraces[1]->fromTimeline= netlist->timelines[1]; - simResults->commTraces[1]->toTimeline= netlist->timelines[0]; - simResults->commTraces[1]->numComms= 1; - simResults->commTraces[1]->commRecs->commID= 1; - simResults->commTraces[1]->commRecs->msgID= 1; - simResults->commTraces[1]->commRecs->startTime= 4; - simResults->commTraces[1]->commRecs->endTime= 5; - - //ping to pong 6 - 7 - simResults->commTraces[2]->fromTimeline= netlist->timelines[0]; - simResults->commTraces[2]->toTimeline= netlist->timelines[1]; - simResults->commTraces[2]->numComms= 1; - simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec)); - simResults->commTraces[2]->commRecs->commID= 2; - simResults->commTraces[2]->commRecs->msgID= 0; - simResults->commTraces[2]->commRecs->startTime= 6; - simResults->commTraces[2]->commRecs->endTime= 7; - - return simResults; -} diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h --- a/src/Application/HWSim__Hello_World_HW/HWSim__Hello_World_HW.h Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - */ - - -#ifndef _HWSim_TERAFLUX_H_ -#define _HWSim_TERAFLUX_H_ - -#include - -#include "../../HWSim_lib/HWSim.h" - - -//=============================== Defines ============================== - //Port 0 is unused, as a bug-catch -#define COMMUNICATOR_OUTPORT 1 - - -//============================== Structures ============================== -typedef struct - { - } -PingPongParams; - - -//============================= Span Functions ========================= -void * -behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeLine ); - -uint64 -timingOf_ping_pong_span( void * dataFromBehaviorFn ); - -//======================== Simulation Fake ================================== -#ifdef FAKE -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist); -#endif - -//======================== Netlist creation ================================== - -HWSimNetlist* createPingPongNetlist (); - -#endif /**/ - - diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt --- a/src/Application/HWSim__Hello_World_HW/HW_DESIGN_NOTES.txt Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Implementing the hardware model This is the "hello world" for HWSim. It is hardware that has just two timelines that send a message back and forth between them. The message has no content, it simply triggers the other timeline, which then sends the same empty message back, repeating the cycle. Each timeline has one in-port and one out-port. The out-port of the first timeline is connected to the in-port of the second and vice-versa. The code of the span consists only of sending an empty message on the timeline's out-port. The trigger for the span is registered on the in-port and message type 0. The span timing is a constant. The port-to-port timing is a constant. Both timelines are in the same time-domain. at_reset of one timeline is set to the ping-pong span, the other timeline's at_reset is set to idle. And that is the entire hardware. \ No newline at end of file diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c --- a/src/Application/HWSim__Hello_World_HW/PingPong_TimeLine.c Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#include "HWSim__Hello_World_HW.h" - - - -//==================================================================== -/*This is the ping-pong timeline for the Hello World hardware - * - *It has only one kind of span, which only puts a communication on - * the timeline's one out-port. - * - *The in-port has only one trigger registered on it, which fires that - * span. - */ - -#define NO_MSG NULL -#define PORT0 0 - -/* - *Note, the returned value is passed to the timing function - */ -void * -behaviorOf_ping_pong_span( void *_params, HWSimTimeline *timeline ) - { - PingPongParams *params; - params = (PingPongParams *)_params; -// DEBUG( dbgHW, "ping pong span\n", clone_PingPongParams(params) ); - - //HWSim__send_on_port( NO_MSG, PORT0, timeline ); - } - -uint64 -timingOf_ping_pong_span( void * dataFromBehaviorFn ) - { - return 10; - } - diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/SimParams.c --- a/src/Application/SimParams.c Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +0,0 @@ -/* - - * Copyright 2009 OpenSourceStewardshipFoundation.org - - * Licensed under GNU General Public License version 2 - - * - - * Author: seanhalle@yahoo.com - - * - - * Created on November 15, 2009, 2:35 AM - - */ - - - -#include - -#include - - - -#include "SimParams.h" - -#include "ParamHelper/Param.h" - - - - - -uint8 * - -read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); - - - - - -void - -fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) - - { char *guestAppFileName, *systemCodeFileName; - - int numBytesInGuestApp, numBytesInSystemCode; - - - - ParamStruc *param; - - //param = getParamFromBag( "GuestApplicationFileName", paramBag ); - - guestAppFileName = param->strValue; - - //param = getParamFromBag( "numBytesInGuestApp", paramBag ); - - numBytesInGuestApp = param->intValue; - - - - simParams->guestApp = - - read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); - - - - //param = getParamFromBag( "SystemCodeFileName", paramBag ); - - systemCodeFileName = param->strValue; - - //param = getParamFromBag( "numBytesInSystemCode", paramBag ); - - numBytesInSystemCode = param->intValue; - - - - simParams->systemCode = - - read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); - - - - - - //param = getParamFromBag( "numNodes", paramBag ); - - simParams->numNodes = param->intValue; - - - - } - - - - - - - -uint8 * - -read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) - - { int byte; - - FILE *file; - - char *machineCode = malloc( numBytesInFile ); - - if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); - - - - file = fopen( machineCodeFileName, "r" ); - - if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} - - - - fseek( file, 0, SEEK_SET ); - - for( byte = 0; byte < numBytesInFile; byte++ ) - - { - - if( feof( file ) ) printf( "file ran out too soon" ); - -// machineCode[byte] = getchar( file ); - - - - } - - return machineCode; - - } - - - - - - //========================================================================== - -void - -printSimResults( SimulationResults simResults ) - - { - - } - - - - diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/SimParams.h --- a/src/Application/SimParams.h Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - */ - -#ifndef SIM_PARAMS_ -#define SIM_PARAMS_ - -#include -#include -#include - -#include "../HWSim_lib/VMS/VMS_primitive_data_types.h" -#include "ParamHelper/Param.h" - - -//============================== Structures ============================== -typedef struct - { uint8 *guestApp; - uint8 *systemCode; - int32 numNodes; - } -SimulationResults; - -typedef struct - { uint8 *guestApp; - uint8 *systemCode; - int32 numNodes; - SimulationResults *simResults; - } -SimulationParams; - -//============================== Functions ================================ -void -printSimResults( SimulationResults simResults ); - -void -fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ); - - -//=========================================================================== - -#endif /**/ - - diff -r aa78c6edf3b8 -r a587ea56af8e src/Application/main.c --- a/src/Application/main.c Wed Jan 04 16:41:01 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * 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 - } -