From 132fd4f9c0184be033533953cc2c7ae92da311d9 Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 20 Dec 2018 22:42:17 +0900 Subject: 8b10b encoder and decoder working Tested on all 24-bit inputs after sync and on ~500M of random input with and without intermediate sync --- fw/8b10b_test_encode.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 fw/8b10b_test_encode.c (limited to 'fw/8b10b_test_encode.c') diff --git a/fw/8b10b_test_encode.c b/fw/8b10b_test_encode.c new file mode 100644 index 0000000..2ba75d9 --- /dev/null +++ b/fw/8b10b_test_encode.c @@ -0,0 +1,108 @@ + +#include +#include + +#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