Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/bert.h @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * bert.h - Bit error rate tests. | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2004 Steve Underwood | |
9 * | |
10 * All rights reserved. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License version 2, as | |
14 * published by the Free Software Foundation. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: bert.h,v 1.13 2006/10/24 13:45:27 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_BERT_H_) | |
29 #define _BERT_H_ | |
30 | |
31 /*! \page bert_page The Bit Error Rate tester | |
32 \section bert_page_sec_1 What does it do? | |
33 The Bit Error Rate tester generates a pseudo random bit stream. It also accepts such | |
34 a pattern, synchronises to it, and checks the bit error rate in this stream. | |
35 | |
36 \section bert_page_sec_2 How does it work? | |
37 The Bit Error Rate tester generates a bit stream, with a repeating 2047 bit pseudo | |
38 random pattern, using an 11 stage polynomial generator. It also accepts such a pattern, | |
39 synchronises to it, and checks the bit error rate in this stream. If the error rate is | |
40 excessive the tester assumes synchronisation has been lost, and it attempts to | |
41 resynchronise with the stream. | |
42 | |
43 The bit error rate is continuously assessed against decadic ranges - | |
44 > 1 in 10^2 | |
45 > 1 in 10^3 | |
46 > 1 in 10^4 | |
47 > 1 in 10^5 | |
48 > 1 in 10^6 | |
49 > 1 in 10^7 | |
50 < 1 in 10^7 | |
51 To ensure fairly smooth results from this assessment, each decadic level is assessed | |
52 over 10/error rate bits. That is, to assess if the signal's BER is above or below 1 in 10^5 | |
53 the software looks over 10*10^5 => 10^6 bits. | |
54 */ | |
55 | |
56 enum | |
57 { | |
58 BERT_REPORT_SYNCED, | |
59 BERT_REPORT_UNSYNCED, | |
60 BERT_REPORT_REGULAR, | |
61 BERT_REPORT_GT_10_2, | |
62 BERT_REPORT_LT_10_2, | |
63 BERT_REPORT_LT_10_3, | |
64 BERT_REPORT_LT_10_4, | |
65 BERT_REPORT_LT_10_5, | |
66 BERT_REPORT_LT_10_6, | |
67 BERT_REPORT_LT_10_7 | |
68 }; | |
69 | |
70 /* The QBF strings should be: | |
71 "VoyeZ Le BricK GeanT QuE J'ExaminE PreS Du WharF 123 456 7890 + - * : = $ % ( )" | |
72 "ThE QuicK BrowN FoX JumpS OveR ThE LazY DoG 123 456 7890 + - * : = $ % ( )" | |
73 */ | |
74 | |
75 enum | |
76 { | |
77 BERT_PATTERN_ZEROS, | |
78 BERT_PATTERN_ONES, | |
79 BERT_PATTERN_7_TO_1, | |
80 BERT_PATTERN_3_TO_1, | |
81 BERT_PATTERN_1_TO_1, | |
82 BERT_PATTERN_1_TO_3, | |
83 BERT_PATTERN_1_TO_7, | |
84 BERT_PATTERN_QBF, | |
85 BERT_PATTERN_ITU_O151_23, | |
86 BERT_PATTERN_ITU_O151_20, | |
87 BERT_PATTERN_ITU_O151_15, | |
88 BERT_PATTERN_ITU_O152_11, | |
89 BERT_PATTERN_ITU_O153_9 | |
90 }; | |
91 | |
92 /*! | |
93 Bit error rate tester (BERT) results descriptor. This is used to report the | |
94 results of a BER test. | |
95 */ | |
96 typedef struct | |
97 { | |
98 int total_bits; | |
99 int bad_bits; | |
100 int resyncs; | |
101 } bert_results_t; | |
102 | |
103 typedef void (*bert_report_func_t)(void *user_data, int reason, bert_results_t *bert_results); | |
104 | |
105 /*! | |
106 Bit error rate tester (BERT) descriptor. This defines the working state for a | |
107 single instance of the BERT. | |
108 */ | |
109 typedef struct | |
110 { | |
111 int pattern; | |
112 int pattern_class; | |
113 bert_report_func_t reporter; | |
114 void *user_data; | |
115 int report_frequency; | |
116 int limit; | |
117 | |
118 uint32_t tx_reg; | |
119 int tx_step; | |
120 int tx_step_bit; | |
121 int tx_bits; | |
122 int tx_zeros; | |
123 | |
124 uint32_t rx_reg; | |
125 uint32_t ref_reg; | |
126 uint32_t master_reg; | |
127 int rx_step; | |
128 int rx_step_bit; | |
129 int resync; | |
130 int rx_bits; | |
131 int rx_zeros; | |
132 int resync_len; | |
133 int resync_percent; | |
134 int resync_bad_bits; | |
135 int resync_cnt; | |
136 | |
137 uint32_t mask; | |
138 int shift; | |
139 int shift2; | |
140 int max_zeros; | |
141 int invert; | |
142 int resync_time; | |
143 | |
144 int decade_ptr[8]; | |
145 int decade_bad[8][10]; | |
146 int step; | |
147 int error_rate; | |
148 | |
149 int bit_error_status; | |
150 int report_countdown; | |
151 | |
152 bert_results_t results; | |
153 | |
154 /*! \brief Error and flow logging control */ | |
155 logging_state_t logging; | |
156 } bert_state_t; | |
157 | |
158 #ifdef __cplusplus | |
159 extern "C" { | |
160 #endif | |
161 | |
162 /*! Initialise a BERT context. | |
163 \param s The BERT context. | |
164 \param limit The maximum test duration. | |
165 \param pattern One of the supported BERT signal patterns. | |
166 \param resync_len ??? | |
167 \param resync_percent The percentage of bad bits which will cause a resync. | |
168 \return The BERT context. */ | |
169 bert_state_t *bert_init(bert_state_t *s, int limit, int pattern, int resync_len, int resync_percent); | |
170 | |
171 /*! Get the next bit of the BERT sequence from the generator. | |
172 \param s The BERT context. | |
173 \return The bit. */ | |
174 int bert_get_bit(bert_state_t *s); | |
175 | |
176 /*! Put the next bit of the BERT sequence to the analyser. | |
177 \param s The BERT context. | |
178 \param bit The bit. */ | |
179 void bert_put_bit(bert_state_t *s, int bit); | |
180 | |
181 /*! Set the callback function for reporting the test status. | |
182 \param s The BERT context. | |
183 \param freq The required frequency of regular reports. | |
184 \param reporter The callback function. | |
185 \param user_data An opaque pointer passed to the reporter routine. */ | |
186 void bert_set_report(bert_state_t *s, int freq, bert_report_func_t reporter, void *user_data); | |
187 | |
188 /*! Get the results of the BERT. | |
189 \param s The BERT context. | |
190 \param results The results. | |
191 \return The size of the result structure. */ | |
192 int bert_result(bert_state_t *s, bert_results_t *results); | |
193 | |
194 #ifdef __cplusplus | |
195 } | |
196 #endif | |
197 | |
198 #endif | |
199 /*- End of file ------------------------------------------------------------*/ |