Changeset 2838
- Timestamp:
- 02/15/07 17:12:45 (6 years ago)
- Location:
- experimental/components/TimingSrc1/trunk/TimingSrc1
- Files:
-
- 2 modified
-
TimingSrc1.cpp (modified) (5 diffs)
-
TimingSrc1.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
experimental/components/TimingSrc1/trunk/TimingSrc1/TimingSrc1.cpp
r2808 r2838 27 27 #include <sys/time.h> 28 28 #include "TimingSrc1.h" 29 30 #define USE_RDTSC 31 //#define USE_GTOD 29 32 30 33 TimingSrc1_i::TimingSrc1_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition) … … 110 113 Q_out_0.length(packetLength); 111 114 112 struct timeval tv;113 114 115 std::ofstream outputFile; 115 116 outputFile.open("/media/hda1/sent.dat"); … … 122 123 */ 123 124 int length = 10000; 124 unsigned long timeStamp_I_sent[length];125 unsigned long timeStamp_Q_sent[length];125 unsigned long long timeStamp_I_sent[length]; 126 unsigned long long timeStamp_Q_sent[length]; 126 127 127 128 // Rough sample rate setting 128 129 unsigned int samplerate = 64000; 129 130 unsigned int timespacing = (unsigned int) (packetLength * 1e6 / samplerate); 131 132 #ifdef USE_GTOD 133 struct timeval tv; 130 134 131 135 int count = 0; … … 138 142 std::cerr << "error: gettimeofday()" << std::endl; 139 143 } 140 141 144 // Push random data 142 145 Class_instance_name->dataOut_0->pushPacket(I_out_0, Q_out_0); … … 150 153 usleep(timespacing); 151 154 } 155 #else 156 #ifdef USE_RDTSC 157 unsigned long long int tc; 152 158 159 int count = 0; 160 while (count < length) 161 { 162 if (Class_instance_name->isRunning) 163 { 164 // Mark timestamp 165 tc = Class_instance_name->get_rdtsc(); 166 167 // Push random data 168 Class_instance_name->dataOut_0->pushPacket(I_out_0, Q_out_0); 169 170 // Store timestamps 171 timeStamp_I_sent[count] = 0; 172 timeStamp_Q_sent[count] = tc; 173 174 count++; 175 } 176 usleep(timespacing); 177 } 178 #endif 179 #endif 153 180 // Rest when finished 154 181 sleep(5); -
experimental/components/TimingSrc1/trunk/TimingSrc1/TimingSrc1.h
r2468 r2838 69 69 //list components provides and uses ports 70 70 standardInterfaces_i::complexLong_u *dataOut_0; 71 71 72 __inline__ unsigned long long int get_rdtsc() 73 { 74 unsigned long long int tc; 75 __asm__ volatile (".byte 0x0f, 0x31" : "=A"(tc)); 76 return tc; 77 } 78 72 79 }; 73 80 #endif