Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
comparison CircuitNetlistCreator.c @ 12:4862640793b6
small changes to the netlist creation
| author | hausers |
|---|---|
| date | Tue, 31 Jan 2012 17:10:29 +0100 |
| parents | a587ea56af8e |
| children | abe3db0025d5 |
comparison
equal
deleted
inserted
replaced
| 0:34f1e4a633b1 | 1:151ab2a08c86 |
|---|---|
| 9 | 9 |
| 10 /*'wire' is an expr resolves to an actual wire struct instance | 10 /*'wire' is an expr resolves to an actual wire struct instance |
| 11 */ | 11 */ |
| 12 #define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\ | 12 #define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\ |
| 13 do{\ | 13 do{\ |
| 14 wire.idxOfFromTimeline = fromTLIdx; \ | 14 wire->idxOfFromTimeline = fromTLIdx; \ |
| 15 wire.idxOfFromOutPort = fromTLIdx; \ | 15 wire->idxOfFromOutPort = fromTLIdx; \ |
| 16 wire.idxOfToTimeline = toTLIdx; \ | 16 wire->idxOfToTimeline = toTLIdx; \ |
| 17 wire.idxOfToInPort = inPort; \ | 17 wire->idxOfToInPort = inPort; \ |
| 18 wire.archSpecWireData = dataPtr; \ | 18 wire->archSpecCommPathData = dataPtr; \ |
| 19 }while(0); //macro magic for namespace | 19 }while(0); //macro magic for namespace |
| 20 | 20 |
| 21 | |
| 22 HWSimSpanType* createPingPongSpanType (); | |
| 23 | |
| 24 HWSimTimeline* createAPingPongTimeline (HWSimNetlist *netlist); | |
| 25 | |
| 21 /*This file constructs the netlist for the Hello World circuit, which is | 26 /*This file constructs the netlist for the Hello World circuit, which is |
| 22 * used during design and implementation of the HWSim language | 27 * used during design and implementation of the HWSim language |
| 23 * | 28 * |
| 24 *It has two timelines, each with one input port and one output port, and | 29 *It has two timelines, each with one input port and one output port, and |
| 25 * a single span-type. | 30 * a single span-type. |
| 35 * inports and outports, and by registering triggers that fire particular | 40 * inports and outports, and by registering triggers that fire particular |
| 36 * span-types. | 41 * span-types. |
| 37 */ | 42 */ |
| 38 HWSimNetlist *createPingPongNetlist() | 43 HWSimNetlist *createPingPongNetlist() |
| 39 { HWSimNetlist *netlist; | 44 { HWSimNetlist *netlist; |
| 40 NetlistWire *wires; | 45 HWSimCommPath **wires; |
| 41 HWSimTimeline **timelines; | 46 HWSimTimeline **timelines; |
| 42 int numTimelines; | 47 int32 numTimelines; |
| 43 int numWires; | 48 int32 numWires; |
| 49 HWSimSpanType *foo; | |
| 44 | 50 |
| 45 netlist = malloc( sizeof(HWSimNetlist) ); | 51 netlist = malloc( sizeof(HWSimNetlist) ); |
| 46 //declare timelines numTimelines = 2; | 52 //declare timelines numTimelines = 2; |
| 47 timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); | 53 timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); |
| 48 netlist->numTimelines = numTimelines; | 54 netlist->numTimelines = numTimelines; |
| 52 netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType(); | 58 netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType(); |
| 53 timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist | 59 timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist |
| 54 timelines[1] = createAPingPongTimeline( netlist ); | 60 timelines[1] = createAPingPongTimeline( netlist ); |
| 55 //on one of the timelines, make reset trigger an action | 61 //on one of the timelines, make reset trigger an action |
| 56 timelines[1]->inPorts[-1].triggeredSpanType = | 62 timelines[1]->inPorts[-1].triggeredSpanType = |
| 57 netlist->spanTypes PING_PONG_TYPE]; //Connect timelines together | 63 netlist->spanTypes[PING_PONG_TYPE]; //Connect timelines together |
| 58 | 64 |
| 59 /*OutPorts and InPorts may have many wires attached, but an inPort only | 65 /*OutPorts and InPorts may have many wires attached, but an inPort only |
| 60 * has one kind of span that all incoming communications trigger. That | 66 * has one kind of span that all incoming communications trigger. That |
| 61 * span can be zero time and then switch on the type of message then | 67 * span can be zero time and then switch on the type of message then |
| 62 * end with a continuation, where the continuation span is chosen by the | 68 * end with a continuation, where the continuation span is chosen by the |
| 63 * switch. | 69 * switch. |
| 64 *So, a wire only connects an out port to an in port | 70 *So, a wire only connects an out port to an in port |
| 65 *The format is: sending TL-index, out-port, dest TL-index, in-port | 71 *The format is: sending TL-index, out-port, dest TL-index, in-port |
| 66 */ | 72 */ |
| 67 numWires = 2; | 73 numWires = 2; |
| 68 wires = malloc( numWires * sizeof(NetlistWire) ); | 74 wires = malloc( numWires * sizeof(HWSimCommPath) ); |
| 69 netlist->numWires = numWires; | 75 netlist->numCommPaths= numWires; |
| 70 netlist->wires = wires; | 76 netlist->commPaths= wires; |
| 71 //TL 0, out-port 0 to TL 1, in-port 0 | 77 //TL 0, out-port 0 to TL 1, in-port 0 |
| 72 setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into | 78 setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into |
| 73 setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create | 79 setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create |
| 74 //TODO: decide how do in-out bidirectional wires -- thinking make it two | 80 //TODO: decide how do in-out bidirectional wires -- thinking make it two |
| 75 // separate wires with guard between in-port and out-port | 81 // separate wires with guard between in-port and out-port |
| 81 createAPingPongTimeline( HWSimNetlist *netlist ) | 87 createAPingPongTimeline( HWSimNetlist *netlist ) |
| 82 { HWSimTimeline *TL; | 88 { HWSimTimeline *TL; |
| 83 TL = malloc( sizeof(HWSimTimeline) ); | 89 TL = malloc( sizeof(HWSimTimeline) ); |
| 84 TL->numInPorts = 1; | 90 TL->numInPorts = 1; |
| 85 TL->numOutPorts = 1; | 91 TL->numOutPorts = 1; |
| 92 //Sean: here we create only inPorts -> outPorts will be created be HWSim ? | |
| 86 TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); | 93 TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); |
| 87 TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port | 94 TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port |
| 88 TL->inPorts[0].triggeredSpanType = netlist->spanTypes[PING_PONG_TYPE]; | 95 TL->inPorts[0].triggeredSpanType = netlist->spanTypes[PING_PONG_TYPE]; |
| 89 } | 96 } |
| 90 | 97 |
