Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
changeset 7:55d3ca21bccd
ready for co-programming with Stefan -- netlist chgs
author | Me@portablequad |
---|---|
date | Wed, 04 Jan 2012 08:04:00 -0800 |
parents | e6ee13464969 |
children | 3276b8621f96 |
files | src/Application/CircuitNetlistCreator.c |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line diff
1.1 --- a/src/Application/CircuitNetlistCreator.c Wed Dec 21 07:19:51 2011 -0800 1.2 +++ b/src/Application/CircuitNetlistCreator.c Wed Jan 04 08:04:00 2012 -0800 1.3 @@ -1,1 +1,1 @@ 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 1.12 #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 1.13 1.14 1.15 /*This file constructs the netlist for the Hello World circuit, which is 1.16 * used during design and implementation of the HWSim language 1.17 * 1.18 *It has two timelines, each with one input port and one output port, and 1.19 * a single span-type. 1.20 * 1.21 *The timelines are cross-coupled, so output port of one connects to input 1.22 * port of the other. The input port has a single trigger, which fires 1.23 * the one span-type. 1.24 * 1.25 *The span does nothing, except send a NULL message on the output port. 1.26 * 1.27 *The span-sim-time and communication-sim-time are both constants. 1.28 * 1.29 *Note that timelines are generic. They are specialized by declaring 1.30 * inports and outports, and by registering triggers that fire particular 1.31 * span-types. 1.32 */ 1.33 HWSimNetlist * 1.34 createPingPongNetlist() 1.35 { HWSimNetlist *netlist; 1.36 HWSimWire **wires; 1.37 HWSimTimeline **timelines; 1.38 1.39 int numTimelines; 1.40 int numWires; 1.41 1.42 netlist = malloc( sizeof(HWSimNetlist) ); 1.43 1.44 //declare timelines 1.45 numTimelines = 2; 1.46 timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); 1.47 netlist->numTimelines = numTimelines; 1.48 netlist->timelines = timelines; 1.49 1.50 timelines[0] = createAPingPongTimeline(); 1.51 timelines[1] = createAPingPongTimeline(); 1.52 1.53 //add a trigger to reset port of one of the timelines, to start things 1.54 HWSimSpanType *pingPongSpanType; 1.55 pingPongSpanType = malloc( sizeof(HWSimSpanType) ); 1.56 pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; 1.57 pingPongSpanType->timingFn = &timingOf_ping_pong_span; 1.58 1.59 timelines[1]->triggers[0]->inPortNum = -1//the reset port 1.60 timelines[1]->triggers[0]->spanType = pingPongSpanType; 1.61 1.62 //Connect timelines together 1.63 numWires = 2; 1.64 wires = malloc( numWires * sizeof(HWSimWire) ); 1.65 netlist->numWires = numWires; 1.66 netlist->wires = wires; 1.67 1.68 //TODO:For wires, have many design decisions to make -- driven by impl, so 1.69 // have to be delayed until get into guts of impl. 1.70 //TODO: maybe make HWSimWire a union with a 5 (or 6) elem array 1.71 //TODO: decide if each wire transports only one kind of message or many 1.72 //TODO: decide if inports accept one wire or many (msg type set by inport) 1.73 //tl 0, out-port 0 to tl 1, in-port 0, msg-type 0 1.74 wires[0] = {0,0,1,0,0}; 1.75 wires[1] = {1,0,0,0,0}; 1.76 1.77 } 1.78 1.79 HWSimTimeline * 1.80 createAPingPongTimeline() 1.81 { HWSimTimeline *tl; 1.82 HWSimTrigger **triggers; 1.83 1.84 tl = malloc( sizeof(HWSimTimeline) ); 1.85 1.86 tl->numInPorts = 1; 1.87 tl->numOutPorts = 1; 1.88 tl->numTriggers = 2; 1.89 1.90 triggers = malloc( 2 * sizeof(HWSimTrigger) ); //extra is reset trig 1.91 tl->triggers[0].inPortNum = -1; //reset trigger 1.92 tl->triggers[0].spanType = IDLE_SPAN; 1.93 1.94 HWSimSpanType *pingPongSpanType; 1.95 pingPongSpanType = malloc( sizeof(HWSimSpanType) ); 1.96 pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; 1.97 pingPongSpanType->timingFn = &timingOf_ping_pong_span; 1.98 1.99 tl->triggers[1].inPortNum = 0; //TODO: Debug: verify whether . or -> 1.100 tl->triggers[1].spanType = pingPongSpanType; 1.101 } 1.102 \ No newline at end of file 1.103 +/* 1.104 * Copyright 2011 OpenSourceStewardshipFoundation.org 1.105 * Licensed under GNU General Public License version 2 1.106 * 1.107 * Author: seanhalle@yahoo.com 1.108 * 1.109 */ 1.110 1.111 #include "HWSim__Hello_World_HW/HWSim__Hello_World_HW.h" 1.112 1.113 /*'wire' is an expr resolves to an actual wire struct instance */ 1.114 #define setWireValuesTo( wire, fromTLIdx, outPort, toTLIdx, inPort, dataPtr)\ 1.115 do{\ 1.116 wire.idxOfFromTimeline = fromTLIdx; \ 1.117 wire.idxOfFromOutPort = fromTLIdx; \ 1.118 wire.idxOfToTimeline = toTLIdx; \ 1.119 wire.idxOfToInPort = inPort; \ 1.120 wire.archSpecWireData = dataPtr; \ 1.121 }while(0); //macro magic for namespace 1.122 1.123 /*This file constructs the netlist for the Hello World circuit, which is 1.124 * used during design and implementation of the HWSim language 1.125 * 1.126 *It has two timelines, each with one input port and one output port, and 1.127 * a single span-type. 1.128 * 1.129 *The timelines are cross-coupled, so output port of one connects to input 1.130 * port of the other. The input port has a single trigger, which fires 1.131 * the one span-type. 1.132 * 1.133 *The span does nothing, except send a NULL message on the output port. 1.134 * 1.135 *The span-sim-time and communication-sim-time are both constants. 1.136 * 1.137 *Note that timelines are generic. They are specialized by declaring 1.138 * inports and outports, and by registering triggers that fire particular 1.139 * span-types. 1.140 */ 1.141 HWSimNetlist * 1.142 createPingPongNetlist() 1.143 { HWSimNetlist *netlist; 1.144 NetlistWire *wires; 1.145 HWSimTimeline **timelines; 1.146 1.147 int numTimelines; 1.148 int numWires; 1.149 1.150 netlist = malloc( sizeof(HWSimNetlist) ); 1.151 1.152 //declare timelines 1.153 numTimelines = 2; 1.154 timelines = malloc( numTimelines * sizeof(HWSimTimeline) ); 1.155 netlist->numTimelines = numTimelines; 1.156 netlist->timelines = timelines; 1.157 1.158 netlist->numSpanTypes = 1; 1.159 netlist->spanTypes = malloc(netlist->numSpanTypes*sizeof(HWSimSpanType*)); 1.160 netlist->spanTypes[PING_PONG_TYPE] = createPingPongSpanType(); 1.161 1.162 timelines[0] = createAPingPongTimeline( netlist ); //use info from netlist 1.163 timelines[1] = createAPingPongTimeline( netlist ); 1.164 1.165 //on one of the timelines, make reset trigger an action 1.166 timelines[1]->inPorts[-1].triggeredSpanType = 1.167 netlist->spanTypes[PING_PONG_TYPE]; 1.168 1.169 //Connect timelines together 1.170 1.171 /*OutPorts and InPorts may have many wires attached, but an inPort only 1.172 * has one kind of span that all incoming communications trigger. That 1.173 * span can be zero time and then switch on the type of message then 1.174 * end with a continuation, where the continuation span is chosen by the 1.175 * switch. 1.176 *So, a wire only connects an out port to an in port 1.177 *The format is: sending TL-index, out-port, dest TL-index, in-port 1.178 */ 1.179 numWires = 2; 1.180 wires = malloc( numWires * sizeof(NetlistWire) ); 1.181 netlist->numWires = numWires; 1.182 netlist->wires = wires; 1.183 1.184 //TL 0, out-port 0 to TL 1, in-port 0 1.185 setWireValuesTo(wires[0], 0,0,1,0, NULL); //These NetlistWires turned into 1.186 setWireValuesTo(wires[1], 1,0,0,0, NULL); // HWSimWires inside ckt create 1.187 1.188 //TODO: decide how do in-out bidirectional wires -- thinking make it two 1.189 // separate wires with guard between in-port and out-port 1.190 //TODO: decide how do guards between ports 1.191 } 1.192 1.193 //Note: copy netlist struct with VMS malloc after VMS initialized 1.194 HWSimTimeline * 1.195 createAPingPongTimeline( HWSimNetlist *netlist ) 1.196 { HWSimTimeline *TL; 1.197 1.198 TL = malloc( sizeof(HWSimTimeline) ); 1.199 1.200 TL->numInPorts = 1; 1.201 TL->numOutPorts = 1; 1.202 1.203 TL->inPorts = HWSim_ext__make_inPortsArray( TL->numInPorts ); 1.204 TL->inPorts[-1].triggeredSpanType = IDLE_SPAN; //reset port 1.205 TL->inPorts[0].triggeredSpanType = netlist->spanTypes[PING_PONG_TYPE]; 1.206 } 1.207 1.208 HWSimSpanType * 1.209 createPingPongSpanType( ) 1.210 { HWSimSpanType *pingPongSpanType; 1.211 1.212 pingPongSpanType = malloc( sizeof(HWSimSpanType) ); 1.213 pingPongSpanType->behaviorFn = &behaviorOf_ping_pong_span; 1.214 pingPongSpanType->timingFn = &timingOf_ping_pong_span; 1.215 1.216 return pingPongSpanType; 1.217 } 1.218 \ No newline at end of file