# HG changeset patch # User Me@portablequad # Date 1325693040 28800 # Node ID 55d3ca21bccda107ab4ea32d2ad44e9f32c570a2 # Parent e6ee134649694a1ee60a0d5ac1722ab1d4a85faf ready for co-programming with Stefan -- netlist chgs diff -r e6ee13464969 -r 55d3ca21bccd src/Application/CircuitNetlistCreator.c --- a/src/Application/CircuitNetlistCreator.c Wed Dec 21 07:19:51 2011 -0800 +++ b/src/Application/CircuitNetlistCreator.c Wed Jan 04 08:04:00 2012 -0800 @@ -1,1 +1,1 @@ -/* * 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" /*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; HWSimWire **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; timelines[0] = createAPingPongTimeline(); timelines[1] = createAPingPongTimeline(); //add a trigger to reset port of one of the timelines, to start things HWSimSpanType *pingPongSpanType; pingPongSpanType = malloc( sizeof(HWSimSpanType) ); pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; pingPongSpanType->timingFn = &timingOf_ping_pong_span; timelines[1]->triggers[0]->inPortNum = -1//the reset port timelines[1]->triggers[0]->spanType = pingPongSpanType; //Connect timelines together numWires = 2; wires = malloc( numWires * sizeof(HWSimWire) ); netlist->numWires = numWires; netlist->wires = wires; //TODO:For wires, have many design decisions to make -- driven by impl, so // have to be delayed until get into guts of impl. //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array //TODO: decide if each wire transports only one kind of message or many //TODO: decide if inports accept one wire or many (msg type set by inport) //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 wires[0] = {0,0,1,0,0}; wires[1] = {1,0,0,0,0}; } HWSimTimeline * createAPingPongTimeline() { HWSimTimeline *tl; HWSimTrigger **triggers; tl = malloc( sizeof(HWSimTimeline) ); tl->numInPorts = 1; tl->numOutPorts = 1; tl->numTriggers = 2; triggers = malloc( 2 * sizeof(HWSimTrigger) ); //extra is reset trig tl->triggers[0].inPortNum = -1; //reset trigger tl->triggers[0].spanType = IDLE_SPAN; HWSimSpanType *pingPongSpanType; pingPongSpanType = malloc( sizeof(HWSimSpanType) ); pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; pingPongSpanType->timingFn = &timingOf_ping_pong_span; tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or -> tl->triggers[1].spanType = pingPongSpanType; } \ No newline at end of file +/* * 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