Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
comparison CircuitNetlistCreator.c @ 26:0deed3ee0b02
update comments for public viewing
| author | kshalle |
|---|---|
| date | Wed, 25 Feb 2015 15:20:16 -0800 |
| parents | b924d86f829e |
| children |
comparison
equal
deleted
inserted
replaced
| 12:268bf1aeef4a | 13:99af77b50888 |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 OpenSourceStewardshipFoundation.org | 2 * Copyright 2011 OpenSourceResearchInstitute.org |
| 3 * Licensed under GNU General Public License version 2 | 3 * Licensed under GNU General Public License version 2 |
| 4 * | 4 * |
| 5 * Author: seanhalle@yahoo.com | 5 * Author: seanhalle@yahoo.com |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 21 | 21 |
| 22 HWSimActivityType* createPingPongActivityType (); | 22 HWSimActivityType* createPingPongActivityType (); |
| 23 | 23 |
| 24 HWSimElem* createAPingPongElem (HWSimNetlist *netlist); | 24 HWSimElem* createAPingPongElem (HWSimNetlist *netlist); |
| 25 | 25 |
| 26 /*This file constructs the netlist for the Hello World circuit, which is | 26 /*This file constructs the netlist for the Hello World circuit |
| 27 * used during design and implementation of the HWSim language | |
| 28 * | 27 * |
| 29 *It has two elements, each with one input port and one output port, and | 28 *It has two elements, each with one input port and one output port, and |
| 30 * a single activity-type. | 29 * a single activity-type. |
| 31 * | 30 * |
| 32 *The elements are cross-coupled, so output port of one connects to input | 31 *The elements are cross-coupled, so output port of one connects to input |
| 115 free(netlist->activityTypes); | 114 free(netlist->activityTypes); |
| 116 free(netlist->elems); | 115 free(netlist->elems); |
| 117 free(netlist); | 116 free(netlist); |
| 118 } | 117 } |
| 119 | 118 |
| 119 /*This creates a simulation element. A simulation element is of the type | |
| 120 * HWSimElem. The HWSimElem data structure contains information about | |
| 121 * the input ports and output ports of the element. In particular, when | |
| 122 * a communication arrives on an input port, that triggers activity inside | |
| 123 * the element. It is here that the function is registerd, which implements | |
| 124 * the behavior of that activity. | |
| 125 *Triggered activities is the heart of HWSim. It is inside these functions | |
| 126 * that application defined behavior takes place. | |
| 127 */ | |
| 120 HWSimElem * | 128 HWSimElem * |
| 121 createAPingPongElem( HWSimNetlist *netlist ) | 129 createAPingPongElem( HWSimNetlist *netlist ) |
| 122 { HWSimElem *elem; | 130 { HWSimElem *elem; |
| 123 elem = malloc( sizeof(HWSimElem) ); | 131 elem = malloc( sizeof(HWSimElem) ); |
| 124 elem->numInPorts = 1; | 132 elem->numInPorts = 1; |
| 125 elem->numOutPorts = 1; | 133 elem->numOutPorts = 1; |
| 126 elem->inPorts = HWSim_ext__make_inPortsArray( elem->numInPorts ); | 134 elem->inPorts = HWSim_ext__make_inPortsArray( elem->numInPorts ); |
| 127 elem->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port | 135 elem->inPorts[-1].triggeredActivityType = IDLE_SPAN; //reset port |
| 136 //point the trigger at an activity that is already in the netlist. | |
| 137 // The function below creates one of such activities. | |
| 138 //The netlist creation function first creates the activities, then | |
| 139 // it calls this function, which grabs activities from the netlist | |
| 128 elem->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_ACTIVITY]; | 140 elem->inPorts[0].triggeredActivityType = netlist->activityTypes[PING_PONG_ACTIVITY]; |
| 129 return elem; | 141 return elem; |
| 130 } | 142 } |
| 131 | 143 |
| 144 /*Define a type of activity that is possible. The netlist creator | |
| 145 * first calls all of this kind of function, and fills the netlist | |
| 146 * with these data structures that implement activities. | |
| 147 *Then, the creator calls functions that create individual elements. | |
| 148 * Those element-creation functions grab the activity structures out | |
| 149 * of the netlist. | |
| 150 */ | |
| 132 HWSimActivityType * | 151 HWSimActivityType * |
| 133 createPingPongActivityType( ) | 152 createPingPongActivityType( ) |
| 134 { HWSimActivityType *pingPongActivityType; | 153 { HWSimActivityType *pingPongActivityType; |
| 135 pingPongActivityType = malloc( sizeof(HWSimActivityType) ); | 154 pingPongActivityType = malloc( sizeof(HWSimActivityType) ); |
| 136 | 155 |
| 156 //For execution speed, some special cases exist, such as activities | |
| 157 // that have no behavior, or ones that have a fixed time to complete | |
| 137 pingPongActivityType->hasBehavior = TRUE; | 158 pingPongActivityType->hasBehavior = TRUE; |
| 138 pingPongActivityType->hasTiming = TRUE; | 159 pingPongActivityType->hasTiming = TRUE; |
| 139 pingPongActivityType->timingIsFixed = TRUE; | 160 pingPongActivityType->timingIsFixed = TRUE; |
| 140 pingPongActivityType->fixedTime = 10; | 161 pingPongActivityType->fixedTime = 10; |
| 141 pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior; | 162 pingPongActivityType->behaviorFn = &pingPongElem_PingActivity_behavior; |
