# HG changeset patch # User Some Random Person # Date 1331160114 28800 # Node ID 4a758d3877d7fbb527f919edaa4c70c455db3083 # Parent e5dfca080b0fe5bbc8ead18918590463d4f1b9f4 Fixed way that state is kept in elem and cleaned up code diff -r e5dfca080b0f -r 4a758d3877d7 CircuitNetlistCreator.c --- a/CircuitNetlistCreator.c Wed Mar 07 17:26:23 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" - -/*'' is an expr resolves to an actual commPath struct instance - */ -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ - commTimeFnPtr, dataPtr)\ -do{\ - commPath->idxOfFromElem = fromElIdx; \ - commPath->idxOfFromOutPort = fromElIdx; \ - commPath->idxOfToElem = toElIdx; \ - commPath->idxOfToInPort = inPort; \ - commPath->commTimeFnPtr = commTimeFnPtr;\ - commPath->archSpecCommPathData = dataPtr; \ - }while(0); //macro magic for namespace - - -HWSimActivityType* createPingPongActivityType (); - -HWSimElem* createAPingPongElem (HWSimNetlist *netlist); - -/*This file constructs the netlist for the Hello World circuit, which is - * used during design and implementation of the HWSim language - * - *It has two elements, each with one input port and one output port, and - * a single activity-type. - * - *The elements 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 activity-type. - * - *The activity does nothing, except send a NULL message on the output port. - *The activity-sim-time and communication-sim-time are both constants. - * - *Note that elements are generic. They are specialized by declaring - * inports and outports, and by registering triggers that fire particular - * activity-types. - */ -HWSimNetlist *createPingPongNetlist() - { HWSimNetlist *netlist; - HWSimCommPath **commPaths; - HWSimElem **elems; - int32 numElems; - int32 numCommPaths; - HWSimActivityType *foo; - - netlist = malloc( sizeof(HWSimNetlist) ); - //declare elems numElems = 2; - elems = malloc( numElems * sizeof(HWSimElem) ); - netlist->numElems = numElems; - netlist->elems = elems; - netlist->numActivityTypes = 1; - netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); - netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType(); - elems[0] = createAPingPongElem( netlist ); //use info from netlist - elems[1] = createAPingPongElem( netlist ); - //on one of the elems, make reset trigger an action - elems[1]->inPorts[-1].triggeredActivityType = - netlist->activityTypes[PING_PONG_TYPE]; //Connect elems together - - /*OutPorts and InPorts may have many commPaths attached. - * but an inPort only - * has one kind of activity that all incoming communications trigger. That - * activity can be zero time and then switch on the type of message then - * end with a continuation, where the continuation activity is chosen by the - * switch. - *So, a commPath only connects an out port to an in port - *The format is: sending TL-index, out-port, dest TL-index, in-port - */ - numCommPaths = 2; - commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); - netlist->numCommPaths= numCommPaths; - netlist->commPaths= commPaths; - //TL 0, out-port 0 to TL 1, in-port 0 - setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); - //TL 1, out-port 0 to TL 0, in-port 0 - setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); - - //TODO: decide how do in-out bidirectional commPaths -- thinking make it two - // separate commPaths with guard between in-port and out-port - } - - //Stefan: copy netlist struct with VMS malloc after VMS initialized? -HWSimElem * -createAPingPongElem( HWSimNetlist *netlist ) - { HWSimElem *TL; - TL = malloc( sizeof(HWSimElem) ); - TL->numInPorts = 1; - TL->numOutPorts = 1; - TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); - TL->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port - TL->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_TYPE]; - } - -HWSimActivityType * -createPingPongActivityType( ) - { HWSimActivityType *pingPongActivityType; - pingPongActivityType = malloc( sizeof(HWSimActivityType) ); - pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior; - pingPongActivityType->timingFn = &pingPongElem_PingActivity_timing; - return pingPongActivityType; - } - diff -r e5dfca080b0f -r 4a758d3877d7 ContextUnitElem_Activities.c --- a/ContextUnitElem_Activities.c Wed Mar 07 17:26:23 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ - -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" -#include ¨contextUnitElem.h¨ - - -//==================================================================== -/*This is the ping-pong element for the Hello World hardware - * - *It has only one kind of activity, which only puts a communication on - * the element's one out-port. - * - *The in-port has only one trigger registered on it, which fires that - * activity. - */ - -#define NO_MSG NULL -#define PORT0 0 - -/* - *Note, the returned value is passed to the timing function - */ -void * -contextUnitElem_SchedulerActivity_behavior( void *_params, HWSimElem *elem ) - { - PingPongParams *params; - params = (PingPongParams *)_params; -// DEBUG( dbgHW, "ping pong activity\n", clone_PingPongParams(params) ); - -// HWSim__send_on_port( NO_MSG, PORT0, elem ); - ContextUnit currentContext; - - currentcontext=elem->state[0]; - - while (currentcontext->FS.PS.ReadyForPipe!=true) - currentcontext++; - /* This port contains Instr+PC+ContextId*/ - //Need to decide the structure of Signals - //Need to take care of boundaries conditions - outPorts[0].lastMsgSent=; - currentcontext++; - } - -HWSimTimeSpan -contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ) - { - return 10; - } \ No newline at end of file diff -r e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/ContextUnitElem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__LPGPU_Arch__HWDef/ContextUnitElem.h Wed Mar 07 14:41:54 2012 -0800 @@ -0,0 +1,68 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef CONTEXT_UNIT_ +#define CONTEXT_UNIT_ + +#include +//============================== Structures ============================== +typedef struct + { + bool ReadyForIF; + bool InIF; + bool DoneWithIF; + } +IFState; + +typedef struct + { + bool ReadyForPipe; + bool InPipe; + bool DoneWithPipe; + } +PipeState; + +typedef struct +{ + bool NotinLdSt; + bool InLdSt; +} +LdStState; + +typedef struct +{ + IFState IF; + PipeState PS; + LdStState LS; + +} +FsmState; + +typedef struct + { + int ctxtAddr; //this is the index of the ctxt in the array! + int PC; //go with just one PC for now --> means exceptions imprecise +// int NewPc; + int instr; + FsmState FSMState; + } +AnimatorContext; + +typedef struct + { + int32 lastScheduledContext; + int32 lastFetchedContext; + AnimatorContext *animatorContexts; + } +ContextUnitState; + +//============================== Functions ================================ + +//=========================================================================== + +#endif /**/ + + + diff -r e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/ContextUnitElem_Activities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__LPGPU_Arch__HWDef/ContextUnitElem_Activities.c Wed Mar 07 14:41:54 2012 -0800 @@ -0,0 +1,58 @@ + +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" +#include "ContextUnitElem.h" + + +//==================================================================== +/*This is the triggers of the context-unit element of the LPGPU architecture + * + */ + +#define NO_MSG NULL +#define PORT0 0 + +/* + *Note + */ +void +contextUnitElem_SchedulerActivity_behavior( void *triggeringMsg, void *elemState ) + { ScheduledInstrMsg msgToPipe; + + DEBUG( dbgHW, "Scheduler activity\n", elemState ); + + ContextUnitState *state; + AnimatorContext *currentCtxt; + int32 lastCtxtScheduled; + + state = (ContextUnitState *)elemState; + + + lastCtxtScheduled = state->lastScheduledContext; + currentCtxt = state->animatorContexts[lastCtxtScheduled]; + + numChecked = 0; + while( currentCtxt->FSMState.PS.ReadyForPipe != true && numChecked < NUM_CONTEXTS ) + { currentCtxt += 1; //Addr arithmetic advances entire struct + numChecked += 1; + } + + msgToPipe.instr = &(currentCtxt->instr); + msgToPipe.PC = &(currentCtxt->PC); + msgToPipe.ctxtAddr = &(currentCtxt->ctxtAddr); + //This HWSim command sends the message on the port, and also + HWSim__send_on_port_w_cont( msgToPipe, PORT_TO_PIPE, elemState ); + } + +HWSimTimeSpan +contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ) + { + return 10; + } \ No newline at end of file diff -r e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/FakeSim.c --- a/HWSim__LPGPU_Arch__HWDef/FakeSim.c Wed Mar 07 17:26:23 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -#include -#include "HWSim__LPGPU_Arch__HWDef.h" - -void checkMalloc (void *ptr) { - if (ptr == NULL) { - printf("Memory allocation failed!\n"); - exit(1); - } -} - -HWSimElem* malloc_timlines (int nrElems) { - HWSimElem *elems; - int i; - - elems= malloc(nrElems*(sizeof(HWSimElem))); - checkMalloc(elems); - for (i= 0; inumElems= nrExecutions; - simResults->elemTraces= - malloc(simResults->numElems*sizeof(HWSimElemTrace *)); - - for (i= 0; inumElems; i++) { - simResults->elemTraces[i]= malloc(sizeof(HWSimElemTrace)); - checkMalloc(simResults->elemTraces[i]); - simResults->elemTraces[i]->activityRecs= malloc(sizeof(HWSimActivityRec)); - } - - simResults->numCommTraces= nrComms; - simResults->commTraces= - malloc(simResults->numCommTraces*sizeof(HWSimCommPathTrace *)); - checkMalloc(simResults->commTraces); - for (i= 0; inumCommTraces; i++) { - simResults->commTraces[i]= malloc(sizeof(HWSimCommPathTrace)); - 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); - - //--------------- elemTraces ------------------------------------ - // 2 times a ping activity - simResults->elemTraces[0]->elem= netlist->elems[0]; - simResults->elemTraces[0]->activityRecs->activitySeqNum= 0; // unique ??? - simResults->elemTraces[0]->activityRecs->startTime= 1; - simResults->elemTraces[0]->activityRecs->endTime=2; - - simResults->elemTraces[1]->elem= netlist->elems[0]; - simResults->elemTraces[1]->activityRecs->activitySeqNum= 1; - simResults->elemTraces[1]->activityRecs->startTime= 5; - simResults->elemTraces[1]->activityRecs->endTime=6; - - // 2 times a pong activity - simResults->elemTraces[2]->elem= netlist->elems[1]; - simResults->elemTraces[2]->activityRecs->activitySeqNum= 2; // unique ??? - simResults->elemTraces[2]->activityRecs->startTime= 3; - simResults->elemTraces[2]->activityRecs->endTime=4; - - simResults->elemTraces[3]->elem= netlist->elems[1]; - simResults->elemTraces[3]->activityRecs->activitySeqNum= 3; - simResults->elemTraces[3]->activityRecs->startTime= 7; - simResults->elemTraces[3]->activityRecs->endTime=8; - - - // a HWSimElem does not contain any helpful additional information to - // identify or label a Element . - // But a unique Element identifier is disireable. Therefore at the moment the - // procrID of the anumating Procr ist used - - // Information about the Activity is required, at least a ID.The current - // activityType doesn't provide it - - - //-------------------- Coomunication Trace --------------------- - - //ping to pong 2 - 3 - simResults->commTraces[0]->fromElem= netlist->elems[0]; - simResults->commTraces[0]->toElem= netlist->elems[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]->fromElem= netlist->elems[1]; - simResults->commTraces[1]->toElem= netlist->elems[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]->fromElem= netlist->elems[0]; - simResults->commTraces[2]->toElem= netlist->elems[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 e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c --- a/HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c Wed Mar 07 17:26:23 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" - -/*'' is an expr resolves to an actual commPath struct instance - */ -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ - commTimeFnPtr, dataPtr)\ -do{\ - commPath->idxOfFromElem = fromElIdx; \ - commPath->idxOfFromOutPort = fromElIdx; \ - commPath->idxOfToElem = toElIdx; \ - commPath->idxOfToInPort = inPort; \ - commPath->commTimeFnPtr = commTimeFnPtr;\ - commPath->archSpecCommPathData = dataPtr; \ - }while(0); //macro magic for namespace - - -/*This file constructs the netlist for the New GPU Architecture. - * - * It has two elements, each with one input port and one output port, and - * a single activity-type. - * - *The elements 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 activity-type. - * - *The activity does nothing, except send a NULL message on the output port. - *The activity-sim-time and communication-sim-time are both constants. - * - *Note that elements are generic. They are specialized by declaring - * inports and outports, and by registering triggers that fire particular - * activity-types. - */ -HWSimNetlist *createGpuArchitectureNetlist() - { HWSimNetlist *netlist; - HWSimCommPath **commPaths; - HWSimElem **elems; - int32 numElems; - int32 numCommPaths; - HWSimActivityType *foo; - - netlist = malloc( sizeof(HWSimNetlist) ); - // numElems will change as we add more Elements - numElems = 1; - elems = malloc( numElems * sizeof(HWSimElem) ); - netlist->numElems = numElems; - netlist->elems = elems; - //numActivityTypes will change as we add more Elements - netlist->numActivityTypes = 3; - netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); - netlist->activityTypes[CONTEXT_SCHEDULER_TYPE] = createContextSchedulerActivityType(); - netlist->activityTypes[FSM_STATE_UPDATE_TYPE] = createFsmUpdateActivityType(); - netlist->activityTypes[INSTRUCTION_FETCH_TYPE] = createInstructionFetchActivityType(); - elems[0] = createContextUnitElem( netlist ); //use info from netlist - - //on one of the elems, make reset trigger an action - elems[1]->inPorts[-1].triggeredActivityType = - netlist->activityTypes[PING_PONG_TYPE]; //Connect elems together - - /*OutPorts and InPorts may have many commPaths attached. - * but an inPort only - * has one kind of activity that all incoming communications trigger. That - * activity can be zero time and then switch on the type of message then - * end with a continuation, where the continuation activity is chosen by the - * switch. - *So, a commPath only connects an out port to an in port - *The format is: sending TL-index, out-port, dest TL-index, in-port - */ - numCommPaths = 2; - commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); - netlist->numCommPaths= numCommPaths; - netlist->commPaths= commPaths; - //TL 0, out-port 0 to TL 1, in-port 0 - setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); - //TL 1, out-port 0 to TL 0, in-port 0 - setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); - - //TODO: decide how do in-out bidirectional commPaths -- thinking make it two - // separate commPaths with guard between in-port and out-port - } - - //Stefan: copy netlist struct with VMS malloc after VMS initialized? -HWSimElem * -createContextUnitElem( HWSimNetlist *netlist ) - { HWSimElem *CU; - CU = malloc( sizeof(HWSimElem) ); - //Sean: how do we define this state - CU->state=malloc(numContextUnit*sizeof(contextUnit)); - //numInPorts may change with change in Design - CU->numInPorts = 8; - CU->numOutPorts = 2; - CU->inPorts = HWSim_ext__make_inPortsArray( CU->numInPorts ); - CU->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port - CU->inPorts[0].triggeredActivityType = netlist->activityTypes[CONTEXT_SCHEDULER_TYPE]; - CU->inPorts[1].triggeredActivityType = netlist->activityTypes[FSM_STATE_UPDATE_TYPE]; - CU->inPorts[2].triggeredActivityType = netlist->activityTypes[INSTRUCTION_FETCH_TYPE]; - } - -HWSimActivityType * -createContextSchedulerActivityType() - { HWSimActivityType *contextSchedulerActivityType; - contextSchedulerActivityType = malloc( sizeof(HWSimActivityType) ); - contextSchedulerActivityType->behaviorFn = &contextUnitElem_SchedulerActivity_behavior; - contextSchedulerActivityType->timingFn = &contextUnitElem_SchedulerActivity_timing; - return contextSchedulerActivityType; - } - - diff -r e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h --- a/HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h Wed Mar 07 17:26:23 2012 +0100 +++ b/HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h Wed Mar 07 14:41:54 2012 -0800 @@ -9,7 +9,7 @@ #include -#include "../../VMS_Implementations/HWSim_impl/HWSim_lib.h" +#include "HWSim_impl/HWSim_lib.h" //=============================== Defines ============================== @@ -30,20 +30,15 @@ //============================= Activity Functions ========================= -void * -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *timeLine ); +void +contextUnitElem_SchedulerActivity_behavior( void *elemState ); -uint64 -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn ); - -//======================== Simulation Fake ================================== -#ifdef FAKE -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist); -#endif +HWSimTimeSpan +contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ); //======================== Netlist creation ================================== -HWSimNetlist* createPingPongNetlist (); +HWSimNetlist* createLPGpuArchitectureNetlist(); #endif /**/ diff -r e5dfca080b0f -r 4a758d3877d7 HWSim__LPGPU_Arch__HWDef/PingPongElem_Activities.c --- a/HWSim__LPGPU_Arch__HWDef/PingPongElem_Activities.c Wed Mar 07 17:26:23 2012 +0100 +++ /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__LPGPU_Arch__HWDef.h" - - - -//==================================================================== -/*This is the ping-pong element for the Hello World hardware - * - *It has only one kind of activity, which only puts a communication on - * the element's one out-port. - * - *The in-port has only one trigger registered on it, which fires that - * activity. - */ - -#define NO_MSG NULL -#define PORT0 0 - -/* - *Note, the returned value is passed to the timing function - */ -void * -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *elem ) - { - PingPongParams *params; - params = (PingPongParams *)_params; -// DEBUG( dbgHW, "ping pong activity\n", clone_PingPongParams(params) ); - -// HWSim__send_on_port( NO_MSG, PORT0, elem ); - } - -HWSimTimeSpan -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn ) - { - return 10; - } - diff -r e5dfca080b0f -r 4a758d3877d7 LPGPUArchitecture_Netlistcreator.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPGPUArchitecture_Netlistcreator.c Wed Mar 07 14:41:54 2012 -0800 @@ -0,0 +1,124 @@ +/* + * Copyright 2011 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ +#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" + +/* + */ +#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ + commTimeFnPtr, dataPtr)\ +do{\ + commPath->idxOfFromElem = fromElIdx; \ + commPath->idxOfFromOutPort = fromElIdx; \ + commPath->idxOfToElem = toElIdx; \ + commPath->idxOfToInPort = inPort; \ + commPath->commTimeFnPtr = commTimeFnPtr;\ + commPath->archSpecCommPathData = dataPtr; \ + }while(0); //macro magic for namespace + + +/*This file constructs the netlist for the New GPU Architecture. + * + *Note that elements are generic. They are specialized by declaring + * inports and outports, and by registering triggers that fire particular + * activity-types. + */ +HWSimNetlist *createLPGpuArchitectureNetlist() + { HWSimNetlist *netlist; + HWSimCommPath **commPaths; + HWSimElem **elems; + int32 numElems; + int32 numCommPaths; + + netlist = malloc( sizeof(HWSimNetlist) ); + // numElems will change as we add more Elements + numElems = 1; + elems = malloc( numElems * sizeof(HWSimElem) ); + netlist->numElems = numElems; + netlist->elems = elems; + //numActivityTypes will change as we add more Elements + netlist->numTriggerTypes = 3; + netlist->triggerTypes = malloc(netlist->numTriggerTypes*sizeof(HWSimTriggerType*)); + netlist->triggerTypes[CONTEXT_SCHEDULER_TYPE] = createContextSchedulerActivityType(); + netlist->triggerTypes[FSM_STATE_UPDATE_TYPE] = createFsmUpdateActivityType(); + netlist->triggerTypes[INSTRUCTION_FETCH_TYPE] = createInstructionFetchActivityType(); + elems[0] = createContextUnitElem( netlist ); //uses info from netlist + + //on one of the elems, make reset trigger an action + elems[1]->inPorts[-1].triggerType = + netlist->triggerTypes[RESET_CTXT_UNIT]; + + /*OutPorts and InPorts may have many commPaths attached. + *A commPath only connects an out port to an in port + *The format is: sending TL-index, out-port, dest TL-index, in-port + */ + numCommPaths = 2; + commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); + netlist->numCommPaths= numCommPaths; + netlist->commPaths= commPaths; + //TL 0, out-port 0 to TL 1, in-port 0 + setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); + //TL 1, out-port 0 to TL 0, in-port 0 + setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); + + //TODO: decide how do in-out bidirectional commPaths -- thinking make it two + // separate commPaths with guard between in-port and out-port + } + + +HWSimElem * +createContextUnitElem( HWSimNetlist *netlist ) + { HWSimElem *CU; + int32 numContexts = 32; + ContextUnitState elemState; + + CU = malloc( sizeof(HWSimElem) ); + + elemState = malloc( sizeof(ContextUnitState) ); + elemState->animatorContexts = malloc(numContexts * sizeof(AnimatorContext)); + CU->elemState = elemState; + CU->timingState = NULL; + + //numInPorts may change with change in Design + CU->numInPorts = 7; + CU->numOutPorts = 2; + CU->inPorts = HWSim_ext__make_inPortsArray( CU->numInPorts ); + //Sohan: there are now multiple kinds of triggers: activity, support_Fn, + // receive_signal, and so on. An activity has both behavior and timing, + // but a support_fn has only behavior, no timing, and receive_signal has + // neither behavior nor timing, it just updates the in-port to point to + // the new signal (msg). The support_Fn is used to do things like + // spawn multiple activities, or choose which activity to spawn. + //So, the reset_ctxt_unit is a support_Fn trigger. When reset arrives, + // this trigger runs, and spawns both the schedule_instr activity and the + // instr_fetch activity. Those two activities then continue themselves + // for the rest of the simulation. + //Please make a separate activity for each input, as I have asked. The + // reason is to stay true to the physical circuit. The code should have + // the same structure as the circuit. In the circuit, each input would + // have independent access to the FSM state-bits, and would + // independently update the state, using gates separate from the rest. + CU->inPorts[RESET].triggerType = netlist->triggerTypes[RESET_CTXT_UNIT]; //reset port + CU->inPorts[INSTR_FETCHED].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[NEWPC_1].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[NEWPC_2].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[IN_LDST].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[NEWPC_3].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[DONE_WITH_PIPE].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + CU->inPorts[LDST_DONE].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; + } + +HWSimTriggerType * +createContextSchedulerActivityType() + { HWSimTriggerType *contextSchedulerActivityType; + contextSchedulerActivityType = malloc( sizeof(HWSimTriggerType) ); + contextSchedulerActivityType->behaviorFn = &contextUnitElem_SchedulerActivity_behavior; + contextSchedulerActivityType->timingFn = &contextUnitElem_SchedulerActivity_timing; + return contextSchedulerActivityType; + } + + diff -r e5dfca080b0f -r 4a758d3877d7 __brch__default --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__brch__default Wed Mar 07 14:41:54 2012 -0800 @@ -0,0 +1,4 @@ +This is the default branch of: + +The LPGPU architecture definition code. It is written in terms of HWSim. + diff -r e5dfca080b0f -r 4a758d3877d7 contextUnitElem.h --- a/contextUnitElem.h Wed Mar 07 17:26:23 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright 2011 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - */ - -#ifndef CONTEXT_UNIT_ -#define CONTEXT_UNIT_ - -#include -//============================== Structures ============================== -struct - { - bool ReadyForIF; - bool InIF; - bool DoneWithIF; - } -IFState; - -struct - { - bool ReadyForPipe; - bool InPipe; - bool DoneWithPipe; - } -PipeState; - -struct -{ - bool NotinLdSt; - bool InLdSt; -} -LdStState; - -struct -{ - struct IFState IF; - struct PipeState PS; - struct LdStState LS; - -} -FsmState; - -typedef struct -{ - int ContextId; - int CurrentPc; - int NewPc; - int Instr; - struct FsmState FS; -} -ContextUnit; - -//============================== Functions ================================ - -//=========================================================================== - -#endif /**/ - - -