00001
00005 #ifndef _NETWORK_H_
00006 #define _NETWORK_H_
00007
00008
00009 #include "csimlist.h"
00010 #include "spikingsynapse.h"
00011
00012 class Forceable;
00013 class Neuron;
00014 class Synapse;
00015 class Teacher;
00016 class csimRecorder;
00017 struct csimInputChannel;
00018
00020
00023 class Network {
00024
00025 public:
00026
00028 Network(void);
00029
00031 virtual ~Network();
00032
00034 virtual int addNewObject(Advancable *a);
00035
00037 Advancable *getObject(uint32 idx);
00038
00039
00041 int connect(uint32 destination, uint32 source);
00042 int connect(uint32 dst, uint32 *src, uint32 n);
00043 int connect(uint32 *dst, uint32 src, uint32 n);
00044 int connect(uint32 *dst, uint32 *src, uint32 n);
00045 int connect(uint32 recorderIdx, uint32 *objIdx, uint32 n, char *fieldName);
00046 int connect(uint32 *postIdx, uint32 *preIdx, uint32 *synIdx , uint32 n);
00047
00049 int reset(void);
00050
00052 int simulate(unsigned long nSteps, csimInputChannel *inputSignal, int ni, csimInputChannel *teacherSignal, int nt);
00053
00055 unsigned long totalSpikeCount(void);
00056
00058 void getSpikes(uint32 *idx, double *times);
00059
00061 int getNumOf(char *className);
00062
00064 int getNumObjects(void) {return objectList.n;}
00065
00067 int setParameter(uint32 *idx, int nIdx, char *paramName, double *value, int m, int n);
00068
00070 int getParameter(uint32 *idx, int n, char *paramName, double **value, int *m);
00071
00073 int updateObjects(void);
00074
00076
00077
00079 void ScheduleSpike(SpikingSynapse *s, pSpikeHandler h, double delay);
00080
00082 int listObjects(bool fields);
00083
00086
00087 int setField(char *fieldName, double v);
00088
00090 int getField(char *fieldName, double *v);
00091
00093 void printFields(void);
00094
00096 int getFieldArraySize(void);
00097
00099 double *getFieldArray(void);
00100
00102 void setFieldArray(double *p);
00104
00106 double dt;
00107
00109 int randSeed;
00110
00112 int verboseLevel;
00113
00115 int nThreads;
00116
00118 int spikeOutput;
00119
00121 double t;
00122
00124 unsigned long step;
00125
00126 private:
00127 friend class Teacher;
00128 friend class MexNetwork;
00129
00131 int moveToTeached(Forceable *f);
00132
00134 int assignInputs(csimInputChannel *input, int n);
00135
00137 int unAssignInputs(csimInputChannel *input, int n);
00138
00140 int connect(Advancable *destination, Advancable *source);
00141
00142
00144 int isReset;
00145
00147 bool dtChanged;
00148
00150 bool fieldsOfSomeObjectChanged;
00151
00153 csimList<Neuron,100> allNeuronList;
00154
00156 csimList<Forceable,100> notTeachedList;
00157
00159 csimList<Forceable,100> teachedList;
00160
00162 csimList<Synapse, 10000> synapseList;
00163
00164 csimList<Synapse, 10000> activeSyn;
00165
00167 csimList<Teacher,2> teacherList;
00168
00170 csimList<csimRecorder,2> recorderList;
00171
00173 csimList<Advancable,20000> objectList;
00174
00176 long DT_us;
00177
00179 long lastSyncTime;
00180
00182 struct event {
00184 SpikingSynapse *s;
00185
00187 pSpikeHandler h;
00188
00190 event *next;
00191 };
00192
00193 csimList<event, 20> allocList;
00194
00195 event *recycledEvent;
00196 event *freeList;
00197 int lfreeList;
00198 int freeIdx;
00199 unsigned allocIdx;
00200
00201 int ldelayList;
00202 event **delayList;
00203 int delayIdx;
00204
00205 protected:
00206
00207 unsigned nDst;
00208 unsigned lDst;
00209 uint32 *dst;
00210
00211 unsigned nSrc;
00212 unsigned lSrc;
00213 uint32 *src;
00214
00215 unsigned nRecMem;
00216 unsigned lRecMem;
00217 char *RecMem,*pRecMem;
00218 };
00219
00220 #endif