# HG changeset patch # User Me@portablequad # Date 1324480791 28800 # Node ID e6ee134649694a1ee60a0d5ac1722ab1d4a85faf # Parent 0ef08e9afd54c61b5510bc47718e2434799c51aa small syntax fixups diff -r 0ef08e9afd54 -r e6ee13464969 src/Application/CircuitNetlistCreator.c --- a/src/Application/CircuitNetlistCreator.c Wed Nov 30 11:10:38 2011 -0800 +++ b/src/Application/CircuitNetlistCreator.c Wed Dec 21 07:19:51 2011 -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 *pingPongSpan; pingPongSpan = malloc( sizeof(HWSimSpanType) ); pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; pingPongSpan->timingFn = &timingOf_ping_pong_span; timelines[1]->triggers[0]->inPortNum = -1//the reset port timelines[1]->triggers[0]->spanType = pingPongSpan; //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}; /* For starters, not doing time-domains.. will add later (Nov 2011) //Create time domains numTimeDomains = 2; timeDomains = malloc( numTimeDomains * sizeof(TimeDomain) ); netlist->numTimeDomains = numTimeDomains; netlist->timeDomains = timeDomains; timeDomains[0]->numDomains = 0; timeDomains[0]->numTimelines = 1; timeDomains[0]->timelines[0] = 0;//is index into netlist->timelines[] timeDomains[1]->numDomains = 0; timeDomains[1]->numTimelines = 1; timeDomains[1]->timelines[0] = 1;//index into netlist->timelines[] //Create time domain connections -- must respect hierarchy numDomainConnections = 2; domainConnects = malloc( numDomainConnections * sizeof(HWSimDomainConn) ); netlist->numDomainConns = numDomainConnections; netlist->domainConns = domainConnects; domainConnects[0] = {0,1}; //domain 0 sends sim-time updates to domain 1 domainConnects[1] = {1,0}; //domain 1 sends sim-time updates to domain 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 *pingPongSpan; pingPongSpan = malloc( sizeof(HWSimSpanType) ); pingPongSpan->behaviorFn = &behaviorOf_ping_pong_span; pingPongSpan->timingFn = &timingOf_ping_pong_span; tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or -> tl->triggers[1].spanType = pingPongSpan; } \ 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" /*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