# HG changeset patch # User sohan # Date 1331137519 -3600 # Node ID 03de56d9aad5e210db27c0f83f33b93698e32ebd # Parent f068965d926930fbf3f59142d21e5dcfb33c009c Netlist for New GPU Arch diff -r f068965d9269 -r 03de56d9aad5 HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HWSim__LPGPU_Arch__HWDef/GpuArchitectureNetlistreator.c Wed Mar 07 17:25:19 2012 +0100 @@ -0,0 +1,114 @@ +/* + * 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; + } + +