Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
comparison CircuitNetlistCreator.c @ 20:3a4be4048a21
missing changes committed
author | hausers |
---|---|
date | Mon, 02 Apr 2012 14:06:11 +0200 |
parents | ba3883d39e62 |
children | fac65c465f98 |
comparison
equal
deleted
inserted
replaced
7:b8d2e8f62032 | 8:f5ac87ad9541 |
---|---|
50 int32 numElems; | 50 int32 numElems; |
51 int32 numCommPaths; | 51 int32 numCommPaths; |
52 | 52 |
53 netlist = malloc( sizeof(HWSimNetlist) ); | 53 netlist = malloc( sizeof(HWSimNetlist) ); |
54 numElems= 2; | 54 numElems= 2; |
55 elems = malloc( numElems * sizeof(HWSimElem) ); | 55 elems = malloc( numElems * sizeof(HWSimElem *) ); |
56 netlist->numElems = numElems; | 56 netlist->numElems = numElems; |
57 netlist->elems = elems; | 57 netlist->elems = elems; |
58 netlist->numActivityTypes = 1; | 58 netlist->numActivityTypes = 1; |
59 netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); | 59 netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); |
60 // Stefan: tocheck valgrind | |
60 netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType(); | 61 netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType(); |
62 | |
61 elems[0] = createAPingPongElem( netlist ); //use info from netlist | 63 elems[0] = createAPingPongElem( netlist ); //use info from netlist |
62 elems[1] = createAPingPongElem( netlist ); | 64 elems[1] = createAPingPongElem( netlist ); |
63 //on one of the elems, make reset trigger an action | 65 //on one of the elems, make reset trigger an action |
64 //Stefan: FIXME | 66 //Stefan: FIXME |
65 elems[1]->inPorts[-1].triggeredActivityType = | 67 elems[1]->inPorts[-1].triggeredActivityType = |
73 * switch. | 75 * switch. |
74 *So, a commPath only connects an out port to an in port | 76 *So, a commPath only connects an out port to an in port |
75 *The format is: sending TL-index, out-port, dest TL-index, in-port | 77 *The format is: sending TL-index, out-port, dest TL-index, in-port |
76 */ | 78 */ |
77 numCommPaths = 2; | 79 numCommPaths = 2; |
78 commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); | 80 commPaths = malloc( numCommPaths * sizeof(HWSimCommPath *) ); |
79 netlist->numCommPaths= numCommPaths; | 81 netlist->numCommPaths= numCommPaths; |
80 netlist->commPaths= commPaths; | 82 netlist->commPaths= commPaths; |
81 //TL 0, out-port 0 to TL 1, in-port 0 | 83 //TL 0, out-port 0 to TL 1, in-port 0 |
82 commPaths[0]= malloc(sizeof(HWSimCommPath)); | 84 commPaths[0]= malloc(sizeof(HWSimCommPath)); |
83 setCommPathValuesTo(commPaths[0],0,0,1,0, commPath_TimeSpanCalc, NULL); | 85 setCommPathValuesTo(commPaths[0],0,0,1,0, commPath_TimeSpanCalc, NULL); |
88 //TODO: decide how do in-out bidirectional commPaths -- thinking make it two | 90 //TODO: decide how do in-out bidirectional commPaths -- thinking make it two |
89 // separate commPaths with guard between in-port and out-port | 91 // separate commPaths with guard between in-port and out-port |
90 | 92 |
91 return netlist; | 93 return netlist; |
92 } | 94 } |
95 | |
96 void | |
97 freePingPongNetlist (HWSimNetlist *netlist) | |
98 { | |
99 int i; | |
100 for (i= 0; i<netlist->numCommPaths; i++) { | |
101 free(netlist->commPaths[i]); | |
102 } | |
103 free(netlist->commPaths); | |
104 for (i= 0; i<netlist->numElems; i++) { | |
105 free(&netlist->elems[i]->inPorts[-1]); | |
106 free(netlist->elems[i]); | |
107 } | |
108 | |
109 free(netlist->activityTypes); | |
110 free(netlist->elems); | |
111 free(netlist); | |
112 } | |
93 | 113 |
94 //Stefan: copy netlist struct with VMS malloc after VMS initialized? | 114 //Stefan: copy netlist struct with VMS malloc after VMS initialized? |
95 //ANSWER: yes, otherwise the user has to deal with VMS details. | 115 //ANSWER: yes, otherwise the user has to deal with VMS details. |
96 // So we should do this in HWSim__make_netlist_simulatable -> yes | 116 // So we should do this in HWSim__make_netlist_simulatable -> yes |
97 // If so, I can do this | 117 // If so, I can do this |