Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__LPGPU_Arch__HWDef
changeset 6:4a758d3877d7
Fixed way that state is kept in elem and cleaned up code
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 07 Mar 2012 14:41:54 -0800 |
| parents | e5dfca080b0f |
| children | 29981612638f |
| files | CircuitNetlistCreator.c ContextUnitElem_Activities.c HWSim__LPGPU_Arch__HWDef/ContextUnitElem.h HWSim__LPGPU_Arch__HWDef/ContextUnitElem_Activities.c HWSim__LPGPU_Arch__HWDef/FakeSim.c HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h HWSim__LPGPU_Arch__HWDef/PingPongElem_Activities.c LPGPUArchitecture_Netlistcreator.c __brch__default contextUnitElem.h |
| diffstat | 11 files changed, 260 insertions(+), 519 deletions(-) [+] |
line diff
1.1 --- a/CircuitNetlistCreator.c Wed Mar 07 17:26:23 2012 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,109 +0,0 @@ 1.4 -/* 1.5 - * Copyright 2011 OpenSourceStewardshipFoundation.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Author: seanhalle@yahoo.com 1.9 - * 1.10 - */ 1.11 -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" 1.12 - 1.13 -/*'' is an expr resolves to an actual commPath struct instance 1.14 - */ 1.15 -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ 1.16 - commTimeFnPtr, dataPtr)\ 1.17 -do{\ 1.18 - commPath->idxOfFromElem = fromElIdx; \ 1.19 - commPath->idxOfFromOutPort = fromElIdx; \ 1.20 - commPath->idxOfToElem = toElIdx; \ 1.21 - commPath->idxOfToInPort = inPort; \ 1.22 - commPath->commTimeFnPtr = commTimeFnPtr;\ 1.23 - commPath->archSpecCommPathData = dataPtr; \ 1.24 - }while(0); //macro magic for namespace 1.25 - 1.26 - 1.27 -HWSimActivityType* createPingPongActivityType (); 1.28 - 1.29 -HWSimElem* createAPingPongElem (HWSimNetlist *netlist); 1.30 - 1.31 -/*This file constructs the netlist for the Hello World circuit, which is 1.32 - * used during design and implementation of the HWSim language 1.33 - * 1.34 - *It has two elements, each with one input port and one output port, and 1.35 - * a single activity-type. 1.36 - * 1.37 - *The elements are cross-coupled, so output port of one connects to input 1.38 - * port of the other. The input port has a single trigger, which fires 1.39 - * the one activity-type. 1.40 - * 1.41 - *The activity does nothing, except send a NULL message on the output port. 1.42 - *The activity-sim-time and communication-sim-time are both constants. 1.43 - * 1.44 - *Note that elements are generic. They are specialized by declaring 1.45 - * inports and outports, and by registering triggers that fire particular 1.46 - * activity-types. 1.47 - */ 1.48 -HWSimNetlist *createPingPongNetlist() 1.49 - { HWSimNetlist *netlist; 1.50 - HWSimCommPath **commPaths; 1.51 - HWSimElem **elems; 1.52 - int32 numElems; 1.53 - int32 numCommPaths; 1.54 - HWSimActivityType *foo; 1.55 - 1.56 - netlist = malloc( sizeof(HWSimNetlist) ); 1.57 - //declare elems numElems = 2; 1.58 - elems = malloc( numElems * sizeof(HWSimElem) ); 1.59 - netlist->numElems = numElems; 1.60 - netlist->elems = elems; 1.61 - netlist->numActivityTypes = 1; 1.62 - netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); 1.63 - netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType(); 1.64 - elems[0] = createAPingPongElem( netlist ); //use info from netlist 1.65 - elems[1] = createAPingPongElem( netlist ); 1.66 - //on one of the elems, make reset trigger an action 1.67 - elems[1]->inPorts[-1].triggeredActivityType = 1.68 - netlist->activityTypes[PING_PONG_TYPE]; //Connect elems together 1.69 - 1.70 - /*OutPorts and InPorts may have many commPaths attached. 1.71 - * but an inPort only 1.72 - * has one kind of activity that all incoming communications trigger. That 1.73 - * activity can be zero time and then switch on the type of message then 1.74 - * end with a continuation, where the continuation activity is chosen by the 1.75 - * switch. 1.76 - *So, a commPath only connects an out port to an in port 1.77 - *The format is: sending TL-index, out-port, dest TL-index, in-port 1.78 - */ 1.79 - numCommPaths = 2; 1.80 - commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); 1.81 - netlist->numCommPaths= numCommPaths; 1.82 - netlist->commPaths= commPaths; 1.83 - //TL 0, out-port 0 to TL 1, in-port 0 1.84 - setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); 1.85 - //TL 1, out-port 0 to TL 0, in-port 0 1.86 - setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); 1.87 - 1.88 - //TODO: decide how do in-out bidirectional commPaths -- thinking make it two 1.89 - // separate commPaths with guard between in-port and out-port 1.90 - } 1.91 - 1.92 - //Stefan: copy netlist struct with VMS malloc after VMS initialized? 1.93 -HWSimElem * 1.94 -createAPingPongElem( HWSimNetlist *netlist ) 1.95 - { HWSimElem *TL; 1.96 - TL = malloc( sizeof(HWSimElem) ); 1.97 - TL->numInPorts = 1; 1.98 - TL->numOutPorts = 1; 1.99 - TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); 1.100 - TL->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port 1.101 - TL->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_TYPE]; 1.102 - } 1.103 - 1.104 -HWSimActivityType * 1.105 -createPingPongActivityType( ) 1.106 - { HWSimActivityType *pingPongActivityType; 1.107 - pingPongActivityType = malloc( sizeof(HWSimActivityType) ); 1.108 - pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior; 1.109 - pingPongActivityType->timingFn = &pingPongElem_PingActivity_timing; 1.110 - return pingPongActivityType; 1.111 - } 1.112 -
2.1 --- a/ContextUnitElem_Activities.c Wed Mar 07 17:26:23 2012 +0100 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,55 +0,0 @@ 2.4 - 2.5 -/* 2.6 - * Copyright 2011 OpenSourceStewardshipFoundation.org 2.7 - * Licensed under GNU General Public License version 2 2.8 - * 2.9 - * Author: seanhalle@yahoo.com 2.10 - * 2.11 - */ 2.12 - 2.13 -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" 2.14 -#include ¨contextUnitElem.h¨ 2.15 - 2.16 - 2.17 -//==================================================================== 2.18 -/*This is the ping-pong element for the Hello World hardware 2.19 - * 2.20 - *It has only one kind of activity, which only puts a communication on 2.21 - * the element's one out-port. 2.22 - * 2.23 - *The in-port has only one trigger registered on it, which fires that 2.24 - * activity. 2.25 - */ 2.26 - 2.27 -#define NO_MSG NULL 2.28 -#define PORT0 0 2.29 - 2.30 -/* 2.31 - *Note, the returned value is passed to the timing function 2.32 - */ 2.33 -void * 2.34 -contextUnitElem_SchedulerActivity_behavior( void *_params, HWSimElem *elem ) 2.35 - { 2.36 - PingPongParams *params; 2.37 - params = (PingPongParams *)_params; 2.38 -// DEBUG( dbgHW, "ping pong activity\n", clone_PingPongParams(params) ); 2.39 - 2.40 -// HWSim__send_on_port( NO_MSG, PORT0, elem ); 2.41 - ContextUnit currentContext; 2.42 - 2.43 - currentcontext=elem->state[0]; 2.44 - 2.45 - while (currentcontext->FS.PS.ReadyForPipe!=true) 2.46 - currentcontext++; 2.47 - /* This port contains Instr+PC+ContextId*/ 2.48 - //Need to decide the structure of Signals 2.49 - //Need to take care of boundaries conditions 2.50 - outPorts[0].lastMsgSent=; 2.51 - currentcontext++; 2.52 - } 2.53 - 2.54 -HWSimTimeSpan 2.55 -contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ) 2.56 - { 2.57 - return 10; 2.58 - } 2.59 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/HWSim__LPGPU_Arch__HWDef/ContextUnitElem.h Wed Mar 07 14:41:54 2012 -0800 3.3 @@ -0,0 +1,68 @@ 3.4 +/* 3.5 + * Copyright 2011 OpenSourceStewardshipFoundation.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + */ 3.8 + 3.9 +#ifndef CONTEXT_UNIT_ 3.10 +#define CONTEXT_UNIT_ 3.11 + 3.12 +#include<stdbool.h> 3.13 +//============================== Structures ============================== 3.14 +typedef struct 3.15 + { 3.16 + bool ReadyForIF; 3.17 + bool InIF; 3.18 + bool DoneWithIF; 3.19 + } 3.20 +IFState; 3.21 + 3.22 +typedef struct 3.23 + { 3.24 + bool ReadyForPipe; 3.25 + bool InPipe; 3.26 + bool DoneWithPipe; 3.27 + } 3.28 +PipeState; 3.29 + 3.30 +typedef struct 3.31 +{ 3.32 + bool NotinLdSt; 3.33 + bool InLdSt; 3.34 +} 3.35 +LdStState; 3.36 + 3.37 +typedef struct 3.38 +{ 3.39 + IFState IF; 3.40 + PipeState PS; 3.41 + LdStState LS; 3.42 + 3.43 +} 3.44 +FsmState; 3.45 + 3.46 +typedef struct 3.47 + { 3.48 + int ctxtAddr; //this is the index of the ctxt in the array! 3.49 + int PC; //go with just one PC for now --> means exceptions imprecise 3.50 +// int NewPc; 3.51 + int instr; 3.52 + FsmState FSMState; 3.53 + } 3.54 +AnimatorContext; 3.55 + 3.56 +typedef struct 3.57 + { 3.58 + int32 lastScheduledContext; 3.59 + int32 lastFetchedContext; 3.60 + AnimatorContext *animatorContexts; 3.61 + } 3.62 +ContextUnitState; 3.63 + 3.64 +//============================== Functions ================================ 3.65 + 3.66 +//=========================================================================== 3.67 + 3.68 +#endif /**/ 3.69 + 3.70 + 3.71 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/HWSim__LPGPU_Arch__HWDef/ContextUnitElem_Activities.c Wed Mar 07 14:41:54 2012 -0800 4.3 @@ -0,0 +1,58 @@ 4.4 + 4.5 +/* 4.6 + * Copyright 2011 OpenSourceStewardshipFoundation.org 4.7 + * Licensed under GNU General Public License version 2 4.8 + * 4.9 + * Author: seanhalle@yahoo.com 4.10 + * 4.11 + */ 4.12 + 4.13 +#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" 4.14 +#include "ContextUnitElem.h" 4.15 + 4.16 + 4.17 +//==================================================================== 4.18 +/*This is the triggers of the context-unit element of the LPGPU architecture 4.19 + * 4.20 + */ 4.21 + 4.22 +#define NO_MSG NULL 4.23 +#define PORT0 0 4.24 + 4.25 +/* 4.26 + *Note 4.27 + */ 4.28 +void 4.29 +contextUnitElem_SchedulerActivity_behavior( void *triggeringMsg, void *elemState ) 4.30 + { ScheduledInstrMsg msgToPipe; 4.31 + 4.32 + DEBUG( dbgHW, "Scheduler activity\n", elemState ); 4.33 + 4.34 + ContextUnitState *state; 4.35 + AnimatorContext *currentCtxt; 4.36 + int32 lastCtxtScheduled; 4.37 + 4.38 + state = (ContextUnitState *)elemState; 4.39 + 4.40 + 4.41 + lastCtxtScheduled = state->lastScheduledContext; 4.42 + currentCtxt = state->animatorContexts[lastCtxtScheduled]; 4.43 + 4.44 + numChecked = 0; 4.45 + while( currentCtxt->FSMState.PS.ReadyForPipe != true && numChecked < NUM_CONTEXTS ) 4.46 + { currentCtxt += 1; //Addr arithmetic advances entire struct 4.47 + numChecked += 1; 4.48 + } 4.49 + 4.50 + msgToPipe.instr = &(currentCtxt->instr); 4.51 + msgToPipe.PC = &(currentCtxt->PC); 4.52 + msgToPipe.ctxtAddr = &(currentCtxt->ctxtAddr); 4.53 + //This HWSim command sends the message on the port, and also 4.54 + HWSim__send_on_port_w_cont( msgToPipe, PORT_TO_PIPE, elemState ); 4.55 + } 4.56 + 4.57 +HWSimTimeSpan 4.58 +contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ) 4.59 + { 4.60 + return 10; 4.61 + } 4.62 \ No newline at end of file
5.1 --- a/HWSim__LPGPU_Arch__HWDef/FakeSim.c Wed Mar 07 17:26:23 2012 +0100 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,126 +0,0 @@ 5.4 -#include <stdlib.h> 5.5 -#include "HWSim__LPGPU_Arch__HWDef.h" 5.6 - 5.7 -void checkMalloc (void *ptr) { 5.8 - if (ptr == NULL) { 5.9 - printf("Memory allocation failed!\n"); 5.10 - exit(1); 5.11 - } 5.12 -} 5.13 - 5.14 -HWSimElem* malloc_timlines (int nrElems) { 5.15 - HWSimElem *elems; 5.16 - int i; 5.17 - 5.18 - elems= malloc(nrElems*(sizeof(HWSimElem))); 5.19 - checkMalloc(elems); 5.20 - for (i= 0; i<nrElems; i++) { 5.21 - elems[i].animatingVP= malloc(sizeof(SlaveVP)); 5.22 - checkMalloc(elems[i].animatingVP); 5.23 - } 5.24 - return elems; 5.25 -} 5.26 - 5.27 -HWSimResults* malloc_simResults (int nrExecutions, int nrComms) { 5.28 - HWSimResults *simResults; 5.29 - int i; 5.30 - 5.31 - 5.32 - simResults= malloc(sizeof(HWSimResults)); 5.33 - checkMalloc(simResults); 5.34 - 5.35 - simResults->numElems= nrExecutions; 5.36 - simResults->elemTraces= 5.37 - malloc(simResults->numElems*sizeof(HWSimElemTrace *)); 5.38 - 5.39 - for (i= 0; i<simResults->numElems; i++) { 5.40 - simResults->elemTraces[i]= malloc(sizeof(HWSimElemTrace)); 5.41 - checkMalloc(simResults->elemTraces[i]); 5.42 - simResults->elemTraces[i]->activityRecs= malloc(sizeof(HWSimActivityRec)); 5.43 - } 5.44 - 5.45 - simResults->numCommTraces= nrComms; 5.46 - simResults->commTraces= 5.47 - malloc(simResults->numCommTraces*sizeof(HWSimCommPathTrace *)); 5.48 - checkMalloc(simResults->commTraces); 5.49 - for (i= 0; i<simResults->numCommTraces; i++) { 5.50 - simResults->commTraces[i]= malloc(sizeof(HWSimCommPathTrace)); 5.51 - checkMalloc(simResults->commTraces[i]); 5.52 - // FRAGILE -> valgrind 5.53 - simResults->commTraces[i]->commRecs= malloc(sizeof(HWSimCommRec)); 5.54 - checkMalloc(simResults->commTraces[i]->commRecs); 5.55 - } 5.56 - 5.57 - return simResults; 5.58 -} 5.59 - 5.60 -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist) { 5.61 - HWSimResults *simResults; 5.62 - 5.63 - simResults= malloc_simResults(4,3); 5.64 - 5.65 - //--------------- elemTraces ------------------------------------ 5.66 - // 2 times a ping activity 5.67 - simResults->elemTraces[0]->elem= netlist->elems[0]; 5.68 - simResults->elemTraces[0]->activityRecs->activitySeqNum= 0; // unique ??? 5.69 - simResults->elemTraces[0]->activityRecs->startTime= 1; 5.70 - simResults->elemTraces[0]->activityRecs->endTime=2; 5.71 - 5.72 - simResults->elemTraces[1]->elem= netlist->elems[0]; 5.73 - simResults->elemTraces[1]->activityRecs->activitySeqNum= 1; 5.74 - simResults->elemTraces[1]->activityRecs->startTime= 5; 5.75 - simResults->elemTraces[1]->activityRecs->endTime=6; 5.76 - 5.77 - // 2 times a pong activity 5.78 - simResults->elemTraces[2]->elem= netlist->elems[1]; 5.79 - simResults->elemTraces[2]->activityRecs->activitySeqNum= 2; // unique ??? 5.80 - simResults->elemTraces[2]->activityRecs->startTime= 3; 5.81 - simResults->elemTraces[2]->activityRecs->endTime=4; 5.82 - 5.83 - simResults->elemTraces[3]->elem= netlist->elems[1]; 5.84 - simResults->elemTraces[3]->activityRecs->activitySeqNum= 3; 5.85 - simResults->elemTraces[3]->activityRecs->startTime= 7; 5.86 - simResults->elemTraces[3]->activityRecs->endTime=8; 5.87 - 5.88 - 5.89 - // a HWSimElem does not contain any helpful additional information to 5.90 - // identify or label a Element . 5.91 - // But a unique Element identifier is disireable. Therefore at the moment the 5.92 - // procrID of the anumating Procr ist used 5.93 - 5.94 - // Information about the Activity is required, at least a ID.The current 5.95 - // activityType doesn't provide it 5.96 - 5.97 - 5.98 - //-------------------- Coomunication Trace --------------------- 5.99 - 5.100 - //ping to pong 2 - 3 5.101 - simResults->commTraces[0]->fromElem= netlist->elems[0]; 5.102 - simResults->commTraces[0]->toElem= netlist->elems[1]; 5.103 - simResults->commTraces[0]->numComms= 1; 5.104 - simResults->commTraces[0]->commRecs->commID= 0; 5.105 - simResults->commTraces[0]->commRecs->msgID= 0; 5.106 - simResults->commTraces[0]->commRecs->startTime= 2; 5.107 - simResults->commTraces[0]->commRecs->endTime= 3; 5.108 - 5.109 - //pong to ping 4 - 5 5.110 - simResults->commTraces[1]->fromElem= netlist->elems[1]; 5.111 - simResults->commTraces[1]->toElem= netlist->elems[0]; 5.112 - simResults->commTraces[1]->numComms= 1; 5.113 - simResults->commTraces[1]->commRecs->commID= 1; 5.114 - simResults->commTraces[1]->commRecs->msgID= 1; 5.115 - simResults->commTraces[1]->commRecs->startTime= 4; 5.116 - simResults->commTraces[1]->commRecs->endTime= 5; 5.117 - 5.118 - //ping to pong 6 - 7 5.119 - simResults->commTraces[2]->fromElem= netlist->elems[0]; 5.120 - simResults->commTraces[2]->toElem= netlist->elems[1]; 5.121 - simResults->commTraces[2]->numComms= 1; 5.122 - simResults->commTraces[2]->commRecs= malloc(sizeof(HWSimCommRec)); 5.123 - simResults->commTraces[2]->commRecs->commID= 2; 5.124 - simResults->commTraces[2]->commRecs->msgID= 0; 5.125 - simResults->commTraces[2]->commRecs->startTime= 6; 5.126 - simResults->commTraces[2]->commRecs->endTime= 7; 5.127 - 5.128 - return simResults; 5.129 -}
6.1 --- a/HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c Wed Mar 07 17:26:23 2012 +0100 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,114 +0,0 @@ 6.4 -/* 6.5 - * Copyright 2011 OpenSourceStewardshipFoundation.org 6.6 - * Licensed under GNU General Public License version 2 6.7 - * 6.8 - * Author: seanhalle@yahoo.com 6.9 - * 6.10 - */ 6.11 -#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" 6.12 - 6.13 -/*'' is an expr resolves to an actual commPath struct instance 6.14 - */ 6.15 -#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ 6.16 - commTimeFnPtr, dataPtr)\ 6.17 -do{\ 6.18 - commPath->idxOfFromElem = fromElIdx; \ 6.19 - commPath->idxOfFromOutPort = fromElIdx; \ 6.20 - commPath->idxOfToElem = toElIdx; \ 6.21 - commPath->idxOfToInPort = inPort; \ 6.22 - commPath->commTimeFnPtr = commTimeFnPtr;\ 6.23 - commPath->archSpecCommPathData = dataPtr; \ 6.24 - }while(0); //macro magic for namespace 6.25 - 6.26 - 6.27 -/*This file constructs the netlist for the New GPU Architecture. 6.28 - * 6.29 - * It has two elements, each with one input port and one output port, and 6.30 - * a single activity-type. 6.31 - * 6.32 - *The elements are cross-coupled, so output port of one connects to input 6.33 - * port of the other. The input port has a single trigger, which fires 6.34 - * the one activity-type. 6.35 - * 6.36 - *The activity does nothing, except send a NULL message on the output port. 6.37 - *The activity-sim-time and communication-sim-time are both constants. 6.38 - * 6.39 - *Note that elements are generic. They are specialized by declaring 6.40 - * inports and outports, and by registering triggers that fire particular 6.41 - * activity-types. 6.42 - */ 6.43 -HWSimNetlist *createGpuArchitectureNetlist() 6.44 - { HWSimNetlist *netlist; 6.45 - HWSimCommPath **commPaths; 6.46 - HWSimElem **elems; 6.47 - int32 numElems; 6.48 - int32 numCommPaths; 6.49 - HWSimActivityType *foo; 6.50 - 6.51 - netlist = malloc( sizeof(HWSimNetlist) ); 6.52 - // numElems will change as we add more Elements 6.53 - numElems = 1; 6.54 - elems = malloc( numElems * sizeof(HWSimElem) ); 6.55 - netlist->numElems = numElems; 6.56 - netlist->elems = elems; 6.57 - //numActivityTypes will change as we add more Elements 6.58 - netlist->numActivityTypes = 3; 6.59 - netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); 6.60 - netlist->activityTypes[CONTEXT_SCHEDULER_TYPE] = createContextSchedulerActivityType(); 6.61 - netlist->activityTypes[FSM_STATE_UPDATE_TYPE] = createFsmUpdateActivityType(); 6.62 - netlist->activityTypes[INSTRUCTION_FETCH_TYPE] = createInstructionFetchActivityType(); 6.63 - elems[0] = createContextUnitElem( netlist ); //use info from netlist 6.64 - 6.65 - //on one of the elems, make reset trigger an action 6.66 - elems[1]->inPorts[-1].triggeredActivityType = 6.67 - netlist->activityTypes[PING_PONG_TYPE]; //Connect elems together 6.68 - 6.69 - /*OutPorts and InPorts may have many commPaths attached. 6.70 - * but an inPort only 6.71 - * has one kind of activity that all incoming communications trigger. That 6.72 - * activity can be zero time and then switch on the type of message then 6.73 - * end with a continuation, where the continuation activity is chosen by the 6.74 - * switch. 6.75 - *So, a commPath only connects an out port to an in port 6.76 - *The format is: sending TL-index, out-port, dest TL-index, in-port 6.77 - */ 6.78 - numCommPaths = 2; 6.79 - commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); 6.80 - netlist->numCommPaths= numCommPaths; 6.81 - netlist->commPaths= commPaths; 6.82 - //TL 0, out-port 0 to TL 1, in-port 0 6.83 - setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); 6.84 - //TL 1, out-port 0 to TL 0, in-port 0 6.85 - setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); 6.86 - 6.87 - //TODO: decide how do in-out bidirectional commPaths -- thinking make it two 6.88 - // separate commPaths with guard between in-port and out-port 6.89 - } 6.90 - 6.91 - //Stefan: copy netlist struct with VMS malloc after VMS initialized? 6.92 -HWSimElem * 6.93 -createContextUnitElem( HWSimNetlist *netlist ) 6.94 - { HWSimElem *CU; 6.95 - CU = malloc( sizeof(HWSimElem) ); 6.96 - //Sean: how do we define this state 6.97 - CU->state=malloc(numContextUnit*sizeof(contextUnit)); 6.98 - //numInPorts may change with change in Design 6.99 - CU->numInPorts = 8; 6.100 - CU->numOutPorts = 2; 6.101 - CU->inPorts = HWSim_ext__make_inPortsArray( CU->numInPorts ); 6.102 - CU->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port 6.103 - CU->inPorts[0].triggeredActivityType = netlist->activityTypes[CONTEXT_SCHEDULER_TYPE]; 6.104 - CU->inPorts[1].triggeredActivityType = netlist->activityTypes[FSM_STATE_UPDATE_TYPE]; 6.105 - CU->inPorts[2].triggeredActivityType = netlist->activityTypes[INSTRUCTION_FETCH_TYPE]; 6.106 - } 6.107 - 6.108 -HWSimActivityType * 6.109 -createContextSchedulerActivityType() 6.110 - { HWSimActivityType *contextSchedulerActivityType; 6.111 - contextSchedulerActivityType = malloc( sizeof(HWSimActivityType) ); 6.112 - contextSchedulerActivityType->behaviorFn = &contextUnitElem_SchedulerActivity_behavior; 6.113 - contextSchedulerActivityType->timingFn = &contextUnitElem_SchedulerActivity_timing; 6.114 - return contextSchedulerActivityType; 6.115 - } 6.116 - 6.117 -
7.1 --- a/HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h Wed Mar 07 17:26:23 2012 +0100 7.2 +++ b/HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h Wed Mar 07 14:41:54 2012 -0800 7.3 @@ -9,7 +9,7 @@ 7.4 7.5 #include <stdio.h> 7.6 7.7 -#include "../../VMS_Implementations/HWSim_impl/HWSim_lib.h" 7.8 +#include "HWSim_impl/HWSim_lib.h" 7.9 7.10 7.11 //=============================== Defines ============================== 7.12 @@ -30,20 +30,15 @@ 7.13 7.14 7.15 //============================= Activity Functions ========================= 7.16 -void * 7.17 -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *timeLine ); 7.18 +void 7.19 +contextUnitElem_SchedulerActivity_behavior( void *elemState ); 7.20 7.21 -uint64 7.22 -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn ); 7.23 - 7.24 -//======================== Simulation Fake ================================== 7.25 -#ifdef FAKE 7.26 -HWSimResults* create_simulation_results__fake(void *simParams,HWSimNetlist *netlist); 7.27 -#endif 7.28 +HWSimTimeSpan 7.29 +contextUnitElem_SchedulerActivity_timing( void * dataFromBehaviorFn ); 7.30 7.31 //======================== Netlist creation ================================== 7.32 7.33 -HWSimNetlist* createPingPongNetlist (); 7.34 +HWSimNetlist* createLPGpuArchitectureNetlist(); 7.35 7.36 #endif /**/ 7.37
8.1 --- a/HWSim__LPGPU_Arch__HWDef/PingPongElem_Activities.c Wed Mar 07 17:26:23 2012 +0100 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,44 +0,0 @@ 8.4 -/* 8.5 - * Copyright 2011 OpenSourceStewardshipFoundation.org 8.6 - * Licensed under GNU General Public License version 2 8.7 - * 8.8 - * Author: seanhalle@yahoo.com 8.9 - * 8.10 - */ 8.11 - 8.12 -#include "HWSim__LPGPU_Arch__HWDef.h" 8.13 - 8.14 - 8.15 - 8.16 -//==================================================================== 8.17 -/*This is the ping-pong element for the Hello World hardware 8.18 - * 8.19 - *It has only one kind of activity, which only puts a communication on 8.20 - * the element's one out-port. 8.21 - * 8.22 - *The in-port has only one trigger registered on it, which fires that 8.23 - * activity. 8.24 - */ 8.25 - 8.26 -#define NO_MSG NULL 8.27 -#define PORT0 0 8.28 - 8.29 -/* 8.30 - *Note, the returned value is passed to the timing function 8.31 - */ 8.32 -void * 8.33 -pingPongElem_PingActivity_behavior( void *_params, HWSimElem *elem ) 8.34 - { 8.35 - PingPongParams *params; 8.36 - params = (PingPongParams *)_params; 8.37 -// DEBUG( dbgHW, "ping pong activity\n", clone_PingPongParams(params) ); 8.38 - 8.39 -// HWSim__send_on_port( NO_MSG, PORT0, elem ); 8.40 - } 8.41 - 8.42 -HWSimTimeSpan 8.43 -pingPongElem_PingActivity_timing( void * dataFromBehaviorFn ) 8.44 - { 8.45 - return 10; 8.46 - } 8.47 -
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/LPGPUArchitecture_Netlistcreator.c Wed Mar 07 14:41:54 2012 -0800 9.3 @@ -0,0 +1,124 @@ 9.4 +/* 9.5 + * Copyright 2011 OpenSourceStewardshipFoundation.org 9.6 + * Licensed under GNU General Public License version 2 9.7 + * 9.8 + * Author: seanhalle@yahoo.com 9.9 + * 9.10 + */ 9.11 +#include "HWSim__LPGPU_Arch__HWDef/HWSim__LPGPU_Arch__HWDef.h" 9.12 + 9.13 +/* 9.14 + */ 9.15 +#define setCommPathValuesTo( commPath, fromElIdx, outPort, toElIdx, inPort,\ 9.16 + commTimeFnPtr, dataPtr)\ 9.17 +do{\ 9.18 + commPath->idxOfFromElem = fromElIdx; \ 9.19 + commPath->idxOfFromOutPort = fromElIdx; \ 9.20 + commPath->idxOfToElem = toElIdx; \ 9.21 + commPath->idxOfToInPort = inPort; \ 9.22 + commPath->commTimeFnPtr = commTimeFnPtr;\ 9.23 + commPath->archSpecCommPathData = dataPtr; \ 9.24 + }while(0); //macro magic for namespace 9.25 + 9.26 + 9.27 +/*This file constructs the netlist for the New GPU Architecture. 9.28 + * 9.29 + *Note that elements are generic. They are specialized by declaring 9.30 + * inports and outports, and by registering triggers that fire particular 9.31 + * activity-types. 9.32 + */ 9.33 +HWSimNetlist *createLPGpuArchitectureNetlist() 9.34 + { HWSimNetlist *netlist; 9.35 + HWSimCommPath **commPaths; 9.36 + HWSimElem **elems; 9.37 + int32 numElems; 9.38 + int32 numCommPaths; 9.39 + 9.40 + netlist = malloc( sizeof(HWSimNetlist) ); 9.41 + // numElems will change as we add more Elements 9.42 + numElems = 1; 9.43 + elems = malloc( numElems * sizeof(HWSimElem) ); 9.44 + netlist->numElems = numElems; 9.45 + netlist->elems = elems; 9.46 + //numActivityTypes will change as we add more Elements 9.47 + netlist->numTriggerTypes = 3; 9.48 + netlist->triggerTypes = malloc(netlist->numTriggerTypes*sizeof(HWSimTriggerType*)); 9.49 + netlist->triggerTypes[CONTEXT_SCHEDULER_TYPE] = createContextSchedulerActivityType(); 9.50 + netlist->triggerTypes[FSM_STATE_UPDATE_TYPE] = createFsmUpdateActivityType(); 9.51 + netlist->triggerTypes[INSTRUCTION_FETCH_TYPE] = createInstructionFetchActivityType(); 9.52 + elems[0] = createContextUnitElem( netlist ); //uses info from netlist 9.53 + 9.54 + //on one of the elems, make reset trigger an action 9.55 + elems[1]->inPorts[-1].triggerType = 9.56 + netlist->triggerTypes[RESET_CTXT_UNIT]; 9.57 + 9.58 + /*OutPorts and InPorts may have many commPaths attached. 9.59 + *A commPath only connects an out port to an in port 9.60 + *The format is: sending TL-index, out-port, dest TL-index, in-port 9.61 + */ 9.62 + numCommPaths = 2; 9.63 + commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); 9.64 + netlist->numCommPaths= numCommPaths; 9.65 + netlist->commPaths= commPaths; 9.66 + //TL 0, out-port 0 to TL 1, in-port 0 9.67 + setCommPathValuesTo(commPaths[0], 0,0,1,0, &commPath_TimeSpanCalc, NULL); 9.68 + //TL 1, out-port 0 to TL 0, in-port 0 9.69 + setCommPathValuesTo(commPaths[1], 1,0,0,0, &commPath_TimeSpanCalc, NULL); 9.70 + 9.71 + //TODO: decide how do in-out bidirectional commPaths -- thinking make it two 9.72 + // separate commPaths with guard between in-port and out-port 9.73 + } 9.74 + 9.75 + 9.76 +HWSimElem * 9.77 +createContextUnitElem( HWSimNetlist *netlist ) 9.78 + { HWSimElem *CU; 9.79 + int32 numContexts = 32; 9.80 + ContextUnitState elemState; 9.81 + 9.82 + CU = malloc( sizeof(HWSimElem) ); 9.83 + 9.84 + elemState = malloc( sizeof(ContextUnitState) ); 9.85 + elemState->animatorContexts = malloc(numContexts * sizeof(AnimatorContext)); 9.86 + CU->elemState = elemState; 9.87 + CU->timingState = NULL; 9.88 + 9.89 + //numInPorts may change with change in Design 9.90 + CU->numInPorts = 7; 9.91 + CU->numOutPorts = 2; 9.92 + CU->inPorts = HWSim_ext__make_inPortsArray( CU->numInPorts ); 9.93 + //Sohan: there are now multiple kinds of triggers: activity, support_Fn, 9.94 + // receive_signal, and so on. An activity has both behavior and timing, 9.95 + // but a support_fn has only behavior, no timing, and receive_signal has 9.96 + // neither behavior nor timing, it just updates the in-port to point to 9.97 + // the new signal (msg). The support_Fn is used to do things like 9.98 + // spawn multiple activities, or choose which activity to spawn. 9.99 + //So, the reset_ctxt_unit is a support_Fn trigger. When reset arrives, 9.100 + // this trigger runs, and spawns both the schedule_instr activity and the 9.101 + // instr_fetch activity. Those two activities then continue themselves 9.102 + // for the rest of the simulation. 9.103 + //Please make a separate activity for each input, as I have asked. The 9.104 + // reason is to stay true to the physical circuit. The code should have 9.105 + // the same structure as the circuit. In the circuit, each input would 9.106 + // have independent access to the FSM state-bits, and would 9.107 + // independently update the state, using gates separate from the rest. 9.108 + CU->inPorts[RESET].triggerType = netlist->triggerTypes[RESET_CTXT_UNIT]; //reset port 9.109 + CU->inPorts[INSTR_FETCHED].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.110 + CU->inPorts[NEWPC_1].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.111 + CU->inPorts[NEWPC_2].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.112 + CU->inPorts[IN_LDST].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.113 + CU->inPorts[NEWPC_3].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.114 + CU->inPorts[DONE_WITH_PIPE].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.115 + CU->inPorts[LDST_DONE].triggerType = netlist->triggerTypes[FSM_STATE_UPDATE_TYPE]; 9.116 + } 9.117 + 9.118 +HWSimTriggerType * 9.119 +createContextSchedulerActivityType() 9.120 + { HWSimTriggerType *contextSchedulerActivityType; 9.121 + contextSchedulerActivityType = malloc( sizeof(HWSimTriggerType) ); 9.122 + contextSchedulerActivityType->behaviorFn = &contextUnitElem_SchedulerActivity_behavior; 9.123 + contextSchedulerActivityType->timingFn = &contextUnitElem_SchedulerActivity_timing; 9.124 + return contextSchedulerActivityType; 9.125 + } 9.126 + 9.127 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/__brch__default Wed Mar 07 14:41:54 2012 -0800 10.3 @@ -0,0 +1,4 @@ 10.4 +This is the default branch of: 10.5 + 10.6 +The LPGPU architecture definition code. It is written in terms of HWSim. 10.7 +
11.1 --- a/contextUnitElem.h Wed Mar 07 17:26:23 2012 +0100 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,60 +0,0 @@ 11.4 -/* 11.5 - * Copyright 2011 OpenSourceStewardshipFoundation.org 11.6 - * Licensed under GNU General Public License version 2 11.7 - */ 11.8 - 11.9 -#ifndef CONTEXT_UNIT_ 11.10 -#define CONTEXT_UNIT_ 11.11 - 11.12 -#include<stdbool.h> 11.13 -//============================== Structures ============================== 11.14 -struct 11.15 - { 11.16 - bool ReadyForIF; 11.17 - bool InIF; 11.18 - bool DoneWithIF; 11.19 - } 11.20 -IFState; 11.21 - 11.22 -struct 11.23 - { 11.24 - bool ReadyForPipe; 11.25 - bool InPipe; 11.26 - bool DoneWithPipe; 11.27 - } 11.28 -PipeState; 11.29 - 11.30 -struct 11.31 -{ 11.32 - bool NotinLdSt; 11.33 - bool InLdSt; 11.34 -} 11.35 -LdStState; 11.36 - 11.37 -struct 11.38 -{ 11.39 - struct IFState IF; 11.40 - struct PipeState PS; 11.41 - struct LdStState LS; 11.42 - 11.43 -} 11.44 -FsmState; 11.45 - 11.46 -typedef struct 11.47 -{ 11.48 - int ContextId; 11.49 - int CurrentPc; 11.50 - int NewPc; 11.51 - int Instr; 11.52 - struct FsmState FS; 11.53 -} 11.54 -ContextUnit; 11.55 - 11.56 -//============================== Functions ================================ 11.57 - 11.58 -//=========================================================================== 11.59 - 11.60 -#endif /**/ 11.61 - 11.62 - 11.63 -
