8b10b issues
This commit is contained in:
parent
67e30fa91e
commit
c8623eb4c6
24 changed files with 1105 additions and 968 deletions
65
common/8b10b_code_table.c
Normal file
65
common/8b10b_code_table.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "8b10b.h"
|
||||
|
||||
static const char * const rc_names[] = {
|
||||
[K28_0] = "K.28.0",
|
||||
[K28_1] = "K.28.1",
|
||||
[K28_2] = "K.28.2",
|
||||
[K28_3] = "K.28.3",
|
||||
[K28_4] = "K.28.4",
|
||||
[K28_5] = "K.28.5",
|
||||
[K28_6] = "K.28.6",
|
||||
[K28_7] = "K.28.7",
|
||||
[K23_7] = "K.23.7",
|
||||
[K27_7] = "K.27.7",
|
||||
[K29_7] = "K.29.7",
|
||||
[K30_7] = "K.30.7",
|
||||
};
|
||||
|
||||
int hex_to_uint(const char *s, size_t len) {
|
||||
if (len > 7)
|
||||
return -2;
|
||||
|
||||
int acc = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
int digit = s[i];
|
||||
if ('0' <= digit && digit <= '9')
|
||||
digit -= '0';
|
||||
else if ('a' <= digit && digit <= 'f')
|
||||
digit -= 'a' - 0xa;
|
||||
else if ('A' <= digit && digit <= 'F')
|
||||
digit -= 'A' - 0xA;
|
||||
else return -1;
|
||||
acc = acc << 4 | digit;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct state_8b10b_enc st;
|
||||
|
||||
printf("Comma symbols (RD -/+)\n");
|
||||
for (int i=1; i<K_CODES_LAST; i++) {
|
||||
st.rd = -1;
|
||||
int sym_neg = xfr_8b10b_encode(&st, -i);
|
||||
st.rd = +1;
|
||||
int sym_pos = xfr_8b10b_encode(&st, -i);
|
||||
printf("%s %010b %010b\n", rc_names[i], sym_neg, sym_pos);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("Data symbols (RD -/+)\n");
|
||||
for (int i=0; i<256; i++) {
|
||||
st.rd = -1;
|
||||
int sym_neg = xfr_8b10b_encode(&st, i);
|
||||
st.rd = +1;
|
||||
int sym_pos = xfr_8b10b_encode(&st, i);
|
||||
printf("%02x %010b %010b\n", i, sym_neg, sym_pos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue