aboutsummaryrefslogtreecommitdiff
path: root/fw/8b10b.h
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-12-20 22:42:17 +0900
committerjaseg <git@jaseg.net>2018-12-20 22:42:17 +0900
commit132fd4f9c0184be033533953cc2c7ae92da311d9 (patch)
tree634c961de6168237d915e459c53fb6d5f1aed8b3 /fw/8b10b.h
parent90038f4378b7cdbe98e32ed1e5e3055dbe4776f2 (diff)
download8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.tar.gz
8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.tar.bz2
8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.zip
8b10b encoder and decoder working
Tested on all 24-bit inputs after sync and on ~500M of random input with and without intermediate sync
Diffstat (limited to 'fw/8b10b.h')
-rw-r--r--fw/8b10b.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/fw/8b10b.h b/fw/8b10b.h
index 84763b1..090faaf 100644
--- a/fw/8b10b.h
+++ b/fw/8b10b.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <errno.h>
enum k_code {
K28_0=1, K28_1, K28_2, K28_3,
@@ -17,22 +18,24 @@ enum decoder_return_codes {
DECODING_IN_PROGRESS
};
-struct entry_3b4b {
- uint8_t rd_neg, rd_pos;
+struct entry {
+ uint8_t rd_neg, rd_pos, disp;
};
-struct entry_5b6b {
- uint8_t rd_neg, rd_pos;
-};
-
-struct state_8b10b {
+struct state_8b10b_dec {
uint32_t rx;
int bit_ctr;
};
+struct state_8b10b_enc {
+ int rd;
+};
+
+void xfr_8b10b_reset(struct state_8b10b_dec *st);
+int xfr_8b10b_feed_bit(struct state_8b10b_dec *st, int bit);
+bool xfr_8b10b_has_sync(struct state_8b10b_dec *st);
-void xfr_8b10b_reset(struct state_8b10b *st);
-int xfr_8b10b_feed_bit(struct state_8b10b *st, int bit);
-bool xfr_8b10b_has_sync(struct state_8b10b *st);
+void xfr_8b10b_encode_reset(struct state_8b10b_enc *st);
+int xfr_8b10b_encode(struct state_8b10b_enc *st, int data);
#endif