init
This commit is contained in:
52
lib_adat/lib_adat/api/adat_rx.h
Normal file
52
lib_adat/lib_adat/api/adat_rx.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#include <xccompat.h>
|
||||
|
||||
/**
|
||||
* \addtogroup lib_adat_rx
|
||||
*
|
||||
* The public API for using the lib_adat rx.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** ADAT Receive Thread (48kHz sample rate).
|
||||
*
|
||||
* When a data rame is received, samples will be output onto the streaming channel
|
||||
* At first a word 0x000000Z1 will be output, where ``Z`` are the user data; after
|
||||
* that eight words 0x0ZZZZZZ0 will be output where ``ZZZZZZ`` is a 24-bit sample value.
|
||||
* The eight words may refer to sample values on eight channels, or on fewer channels if
|
||||
* muxing is used.
|
||||
*
|
||||
* The function will return if it cannot lock onto a 48,000 Hz
|
||||
* signal. Normally the 48000 function is called in a while(1) loop. If
|
||||
* both 44,100 and 48,000 need to be supported, they should be called in
|
||||
* sequence in a while(1) loop. Note that the functions are large, and
|
||||
* that 44,100 should not be called if 44.1 KHz does not need to be supported.
|
||||
*
|
||||
* \param p ADAT port - should be 1-bit, 32-bit buffered, and clocked at 100MHz
|
||||
* \param oChan channel on which decoded samples are output
|
||||
**/
|
||||
void adatReceiver48000(in_buffered_port_32_t p, streaming_chanend_t oChan);
|
||||
|
||||
/** ADAT Receive Thread (44.1kHz sample rate).
|
||||
*
|
||||
* When a data rame is received, samples will be output onto the streaming channel
|
||||
* At first a word 0x000000Z1 will be output, where ``Z`` are the user data; after
|
||||
* that eight words 0x0ZZZZZZ0 will be output where ``ZZZZZZ`` is a 24-bit sample value.
|
||||
* The eight words may refer to sample values on eight channels, or on fewer channels if
|
||||
* muxing is used.
|
||||
*
|
||||
* The function will return if it cannot lock onto a 44,100 Hz
|
||||
* signal. Normally the 44,100 function is called in a while(1) loop. If
|
||||
* both 44,100 and 48,000 need to be supported, they should be called in
|
||||
* sequence in a while(1) loop. Note that the functions are large, and
|
||||
* that 48,000 should not be called if 48 Khz does not need to be supported.
|
||||
*
|
||||
* \param p ADAT port - should be 1-bit 32-bit buffered, and clocked at 100MHz
|
||||
* \param oChan channel on which decoded samples are output
|
||||
**/
|
||||
void adatReceiver44100(in_buffered_port_32_t p, streaming_chanend_t oChan);
|
||||
|
||||
/**@}*/ // END: addtogroup lib_adat_rx
|
||||
|
||||
52
lib_adat/lib_adat/api/adat_tx.h
Normal file
52
lib_adat/lib_adat/api/adat_tx.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#include <xccompat.h>
|
||||
|
||||
/**
|
||||
* \addtogroup lib_adat_tx
|
||||
*
|
||||
* The public API for using the lib_adat tx.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function that takes data over a channel end, and that outputs this in
|
||||
* ADAT format onto a 1-bit port. The 1-bit port should be clocked by the
|
||||
* master-clock, and an external flop should be used to precisely align the
|
||||
* edge of the signal to the master-clock.
|
||||
*
|
||||
* Data should be send onto c_data using outuint only, the first two values
|
||||
* should be The multiplier and the smux values, after that output any
|
||||
* number of eight samples (24-bit, right aligned), and if the process is
|
||||
* to be terminated send it an control token 1.
|
||||
*
|
||||
* The data is output onto a channel, which a separate process should
|
||||
* output to a port. This process should byte-reverse every word read over
|
||||
* the channel, and then output the reversed word to a buffered 1-bit port.
|
||||
*
|
||||
* \param c_data Channel over which to send sample values to the transmitter
|
||||
*
|
||||
* \param c_port Channel on which to generate the ADAT stream
|
||||
*/
|
||||
void adat_tx(chanend c_data, chanend c_port);
|
||||
|
||||
/**
|
||||
* Function that takes data over a channel end, and that outputs this in
|
||||
* ADAT format onto a 1-bit port. The 1-bit port should be clocked by the
|
||||
* master-clock, and an external flop should be used to precisely align the
|
||||
* edge of the signal to the master-clock.
|
||||
*
|
||||
* Data should be send onto c_data using outuint only, the first two values
|
||||
* should be The multiplier and the smux values, after that output any
|
||||
* number of eight samples (24-bit, right aligned), and if the process is
|
||||
* to be terminated send it an control token 1.
|
||||
*
|
||||
* \param c_data Channel over which to send sample values to the transmitter
|
||||
*
|
||||
* \param p_data 1-bit, 32-bit buffered, port on which to generate the ADAT stream
|
||||
*/
|
||||
void adat_tx_port(chanend c_data, out_buffered_port_32_t p_data);
|
||||
|
||||
/**@}*/ // END: addtogroup lib_adat_rx
|
||||
|
||||
7
lib_adat/lib_adat/lib_build_info.cmake
Normal file
7
lib_adat/lib_adat/lib_build_info.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
set(LIB_NAME lib_adat)
|
||||
set(LIB_VERSION 2.0.1)
|
||||
set(LIB_INCLUDES api)
|
||||
set(LIB_DEPENDENT_MODULES "")
|
||||
set(LIB_COMPILER_FLAGS -O3)
|
||||
|
||||
XMOS_REGISTER_MODULE()
|
||||
13
lib_adat/lib_adat/module_build_info
Normal file
13
lib_adat/lib_adat/module_build_info
Normal file
@@ -0,0 +1,13 @@
|
||||
VERSION = 2.0.1
|
||||
|
||||
# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
|
||||
# variable. So the following
|
||||
#
|
||||
# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
|
||||
#
|
||||
# specifies that everything in the modules should have the application
|
||||
# build flags with -O3 appended (so the files will build at
|
||||
# optimization level -O3).
|
||||
#
|
||||
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
|
||||
MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
|
||||
955
lib_adat/lib_adat/src/adatReceiver-100.h
Normal file
955
lib_adat/lib_adat/src/adatReceiver-100.h
Normal file
@@ -0,0 +1,955 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
// GENERATED CODE - DO NOT EDIT
|
||||
// Comments are in the generator
|
||||
// Generated for devices with a reference clock of 100.000000 Mhz
|
||||
// If both 48000 and 44100 are to be supported, then
|
||||
// call adatReceiver48000 and 44100 in a while(1) loop
|
||||
#include <xs1.h>
|
||||
#include <stdio.h>
|
||||
#pragma unsafe arrays
|
||||
void adatReceiver48000(buffered in port:32 p, streaming chanend oChan) {
|
||||
const unsigned int mask = 0x80808080;
|
||||
unsigned compressed;
|
||||
unsigned nibble, word = 1, fourBits, data;
|
||||
int old, violation;
|
||||
unsigned int lookupCrcF[16] = {8, 9, 12, 13, 7, 6, 3, 2, 10, 11, 14, 15, 5, 4, 1, 0};
|
||||
unsigned int lookupNRTZ[32] = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 15, 7, 5, 13, 9, 1,
|
||||
1, 9, 13, 5, 7, 15, 11, 3, 2, 10, 14, 6, 4, 12, 8, 0};
|
||||
for(int i = 0; i < 32; i++) { lookupNRTZ[i] <<= 4; }
|
||||
do {
|
||||
old = word; p :> word;
|
||||
} while (word != old || (word != 0 && word+1 != 0));
|
||||
while(1) {
|
||||
violation = word;
|
||||
p when pinsneq(violation) :> int _;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
oChan <: nibble << 4 | 1;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
if (word != 0 && word+1 != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
// GENERATED CODE - DO NOT EDIT
|
||||
// Comments are in the generator
|
||||
// Generated for devices with a reference clock of 100.000000 Mhz
|
||||
// If both 48000 and 44100 are to be supported, then
|
||||
// call adatReceiver48000 and 44100 in a while(1) loop
|
||||
#include <xs1.h>
|
||||
#include <stdio.h>
|
||||
#pragma unsafe arrays
|
||||
void adatReceiver44100(buffered in port:32 p, streaming chanend oChan) {
|
||||
const unsigned int mask = 0x80402010;
|
||||
unsigned compressed;
|
||||
unsigned nibble, word = 1, fourBits, data;
|
||||
int old, violation;
|
||||
unsigned int lookupCrcF[16] = {8, 12, 10, 14, 9, 13, 11, 15, 7, 3, 5, 1, 6, 2, 4, 0};
|
||||
unsigned int lookupNRTZ[32] = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 15, 7, 5, 13, 9, 1,
|
||||
1, 9, 13, 5, 7, 15, 11, 3, 2, 10, 14, 6, 4, 12, 8, 0};
|
||||
for(int i = 0; i < 32; i++) { lookupNRTZ[i] <<= 4; }
|
||||
do {
|
||||
old = word; p :> word;
|
||||
} while (word != old || (word != 0 && word+1 != 0));
|
||||
while(1) {
|
||||
violation = word;
|
||||
p when pinsneq(violation) :> int _;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
oChan <: nibble << 4 | 1;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
oChan <: data;
|
||||
p :> word;
|
||||
if (word != 0 && word+1 != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
955
lib_adat/lib_adat/src/adatReceiver-99-9375.h
Normal file
955
lib_adat/lib_adat/src/adatReceiver-99-9375.h
Normal file
@@ -0,0 +1,955 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
// GENERATED CODE - DO NOT EDIT
|
||||
// Comments are in the generator
|
||||
// Generated for devices with a reference clock of 99.937500 Mhz
|
||||
// If both 48000 and 44100 are to be supported, then
|
||||
// call adatReceiver48000 and 44100 in a while(1) loop
|
||||
#include <xs1.h>
|
||||
#include <stdio.h>
|
||||
#pragma unsafe arrays
|
||||
void adatReceiver48000(buffered in port:32 p, chanend oChan) {
|
||||
const unsigned int mask = 0x80808080;
|
||||
unsigned compressed;
|
||||
unsigned nibble, word = 1, fourBits, data;
|
||||
int old, violation;
|
||||
unsigned int lookupCrcF[16] = {8, 9, 12, 13, 7, 6, 3, 2, 10, 11, 14, 15, 5, 4, 1, 0};
|
||||
unsigned int lookupNRTZ[32] = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 15, 7, 5, 13, 9, 1,
|
||||
1, 9, 13, 5, 7, 15, 11, 3, 2, 10, 14, 6, 4, 12, 8, 0};
|
||||
for(int i = 0; i < 32; i++) { lookupNRTZ[i] <<= 4; }
|
||||
do {
|
||||
old = word; p :> word;
|
||||
} while (word != old || (word != 0 && word+1 != 0));
|
||||
while(1) {
|
||||
violation = word;
|
||||
p when pinsneq(violation) :> int _;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
outuint(oChan, nibble << 4 | 1);
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
if (word != 0 && word+1 != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
// GENERATED CODE - DO NOT EDIT
|
||||
// Comments are in the generator
|
||||
// Generated for devices with a reference clock of 99.937500 Mhz
|
||||
// If both 48000 and 44100 are to be supported, then
|
||||
// call adatReceiver48000 and 44100 in a while(1) loop
|
||||
#include <xs1.h>
|
||||
#include <stdio.h>
|
||||
#pragma unsafe arrays
|
||||
void adatReceiver44100(buffered in port:32 p, chanend oChan) {
|
||||
const unsigned int mask = 0x80402010;
|
||||
unsigned compressed;
|
||||
unsigned nibble, word = 1, fourBits, data;
|
||||
int old, violation;
|
||||
unsigned int lookupCrcF[16] = {8, 12, 10, 14, 9, 13, 11, 15, 7, 3, 5, 1, 6, 2, 4, 0};
|
||||
unsigned int lookupNRTZ[32] = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 15, 7, 5, 13, 9, 1,
|
||||
1, 9, 13, 5, 7, 15, 11, 3, 2, 10, 14, 6, 4, 12, 8, 0};
|
||||
for(int i = 0; i < 32; i++) { lookupNRTZ[i] <<= 4; }
|
||||
do {
|
||||
old = word; p :> word;
|
||||
} while (word != old || (word != 0 && word+1 != 0));
|
||||
while(1) {
|
||||
violation = word;
|
||||
p when pinsneq(violation) :> int _;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
outuint(oChan, nibble << 4 | 1);
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 0) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
fourBits = (word << 1) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = nibble << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 5) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
old = old | compressed << 1;
|
||||
p :> word;
|
||||
fourBits = (word << 3) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 7) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 3)) & 31];
|
||||
old = compressed >> 2;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 1)) & 31];
|
||||
old = compressed >> 4;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 2) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
old = compressed;
|
||||
p :> word;
|
||||
fourBits = (word << 6) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
compressed = compressed >> 1;
|
||||
nibble = lookupNRTZ[(old | (compressed << 4)) & 31];
|
||||
old = compressed >> 1;
|
||||
data = (data | nibble) << 4;
|
||||
p :> word;
|
||||
fourBits = (word << 4) & mask;
|
||||
crc32(fourBits, 0xf, 0xf);
|
||||
compressed = lookupCrcF[fourBits];
|
||||
nibble = lookupNRTZ[(old | (compressed << 2)) & 31];
|
||||
old = compressed >> 3;
|
||||
data = (data | nibble) << 4;
|
||||
outuint(oChan, data);
|
||||
p :> word;
|
||||
if (word != 0 && word+1 != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
5
lib_adat/lib_adat/src/adat_lookups.h
Normal file
5
lib_adat/lib_adat/src/adat_lookups.h
Normal file
@@ -0,0 +1,5 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
extern unsigned int lookup40w[256];
|
||||
extern unsigned char lookup40b[256];
|
||||
extern unsigned lookup20[256];
|
||||
98
lib_adat/lib_adat/src/adat_lookups.xc
Normal file
98
lib_adat/lib_adat/src/adat_lookups.xc
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include "adat_lookups.h"
|
||||
|
||||
unsigned int lookup40w[256] = {
|
||||
0xFFFF,0xFFFF,0xFF0F,0xFF0F,0xFF00,0xFF00,0xFFF0,0xFFF0,0xF00,0xF00,0xFF0,0xFF0,0xFFF,0xFFF,0xF0F,0xF0F,
|
||||
0xF00000,0xF00000,0xF000F0,0xF000F0,0xF000FF,0xF000FF,0xF0000F,0xF0000F,0xF0F0FF,0xF0F0FF,0xF0F00F,0xF0F00F,
|
||||
0xF0F000,0xF0F000,0xF0F0F0,0xF0F0F0,0xFF0000,0xFF0000,0xFF00F0,0xFF00F0,0xFF00FF,0xFF00FF,0xFF000F,0xFF000F,
|
||||
0xFFF0FF,0xFFF0FF,0xFFF00F,0xFFF00F,0xFFF000,0xFFF000,0xFFF0F0,0xFFF0F0,0xFFFFF,0xFFFFF,0xFFF0F,0xFFF0F,0xFFF00,
|
||||
0xFFF00,0xFFFF0,0xFFFF0,0xF0F00,0xF0F00,0xF0FF0,0xF0FF0,0xF0FFF,0xF0FFF,0xF0F0F,0xF0F0F,0xF0FF0000,0xF0FF0000,
|
||||
0xF0FF00F0,0xF0FF00F0,0xF0FF00FF,0xF0FF00FF,0xF0FF000F,0xF0FF000F,0xF0FFF0FF,0xF0FFF0FF,0xF0FFF00F,0xF0FFF00F,
|
||||
0xF0FFF000,0xF0FFF000,0xF0FFF0F0,0xF0FFF0F0,0xF00FFFFF,0xF00FFFFF,0xF00FFF0F,0xF00FFF0F,0xF00FFF00,0xF00FFF00,
|
||||
0xF00FFFF0,0xF00FFFF0,0xF00F0F00,0xF00F0F00,0xF00F0FF0,0xF00F0FF0,0xF00F0FFF,0xF00F0FFF,0xF00F0F0F,0xF00F0F0F,
|
||||
0xF000FFFF,0xF000FFFF,0xF000FF0F,0xF000FF0F,0xF000FF00,0xF000FF00,0xF000FFF0,0xF000FFF0,0xF0000F00,0xF0000F00,
|
||||
0xF0000FF0,0xF0000FF0,0xF0000FFF,0xF0000FFF,0xF0000F0F,0xF0000F0F,0xF0F00000,0xF0F00000,0xF0F000F0,0xF0F000F0,
|
||||
0xF0F000FF,0xF0F000FF,0xF0F0000F,0xF0F0000F,0xF0F0F0FF,0xF0F0F0FF,0xF0F0F00F,0xF0F0F00F,0xF0F0F000,0xF0F0F000,
|
||||
0xF0F0F0F0,0xF0F0F0F0,0xFFFF0000,0xFFFF0000,0xFFFF00F0,0xFFFF00F0,0xFFFF00FF,0xFFFF00FF,0xFFFF000F,0xFFFF000F,
|
||||
0xFFFFF0FF,0xFFFFF0FF,0xFFFFF00F,0xFFFFF00F,0xFFFFF000,0xFFFFF000,0xFFFFF0F0,0xFFFFF0F0,0xFF0FFFFF,0xFF0FFFFF,
|
||||
0xFF0FFF0F,0xFF0FFF0F,0xFF0FFF00,0xFF0FFF00,0xFF0FFFF0,0xFF0FFFF0,0xFF0F0F00,0xFF0F0F00,0xFF0F0FF0,0xFF0F0FF0,
|
||||
0xFF0F0FFF,0xFF0F0FFF,0xFF0F0F0F,0xFF0F0F0F,0xFF00FFFF,0xFF00FFFF,0xFF00FF0F,0xFF00FF0F,0xFF00FF00,0xFF00FF00,
|
||||
0xFF00FFF0,0xFF00FFF0,0xFF000F00,0xFF000F00,0xFF000FF0,0xFF000FF0,0xFF000FFF,0xFF000FFF,0xFF000F0F,0xFF000F0F,
|
||||
0xFFF00000,0xFFF00000,0xFFF000F0,0xFFF000F0,0xFFF000FF,0xFFF000FF,0xFFF0000F,0xFFF0000F,0xFFF0F0FF,0xFFF0F0FF,
|
||||
0xFFF0F00F,0xFFF0F00F,0xFFF0F000,0xFFF0F000,0xFFF0F0F0,0xFFF0F0F0,0xF00FFFF,0xF00FFFF,0xF00FF0F,0xF00FF0F,
|
||||
0xF00FF00,0xF00FF00,0xF00FFF0,0xF00FFF0,0xF000F00,0xF000F00,0xF000FF0,0xF000FF0,0xF000FFF,0xF000FFF,0xF000F0F,
|
||||
0xF000F0F,0xFF00000,0xFF00000,0xFF000F0,0xFF000F0,0xFF000FF,0xFF000FF,0xFF0000F,0xFF0000F,0xFF0F0FF,0xFF0F0FF,
|
||||
0xFF0F00F,0xFF0F00F,0xFF0F000,0xFF0F000,0xFF0F0F0,0xFF0F0F0,0xFFF0000,0xFFF0000,0xFFF00F0,0xFFF00F0,0xFFF00FF,
|
||||
0xFFF00FF,0xFFF000F,0xFFF000F,0xFFFF0FF,0xFFFF0FF,0xFFFF00F,0xFFFF00F,0xFFFF000,0xFFFF000,0xFFFF0F0,0xFFFF0F0,
|
||||
0xF0FFFFF,0xF0FFFFF,0xF0FFF0F,0xF0FFF0F,0xF0FFF00,0xF0FFF00,0xF0FFFF0,0xF0FFFF0,0xF0F0F00,0xF0F0F00,0xF0F0FF0,
|
||||
0xF0F0FF0,0xF0F0FFF,0xF0F0FFF,0xF0F0F0F,0xF0F0F0F
|
||||
};
|
||||
|
||||
unsigned char lookup40b[256] = {
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,
|
||||
0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,
|
||||
0xF,0xF0,0xF0,0xF,0xF0,0xF,0xF,0xF0,0xF0,0xF,0xF,0xF0,0xF,0xF0,0xF0,0xF
|
||||
};
|
||||
|
||||
/* generated with:
|
||||
int byte_value;
|
||||
for (byte_value = 0; byte_value < 256; byte_value++) {
|
||||
int last_symbol = 0;
|
||||
unsigned nrzi = 0;
|
||||
int nibble;
|
||||
for (nibble = 1; nibble >= 0; nibble--) {
|
||||
int bit;
|
||||
for (bit = 3; bit >= 0; bit--) {
|
||||
int next_symbol = (byte_value >> ((nibble * 4) + bit)) & 1;
|
||||
last_symbol = next_symbol ^ last_symbol;
|
||||
nrzi = (last_symbol << 31) | (last_symbol << 30) | (nrzi >> 2);
|
||||
}
|
||||
last_symbol = !last_symbol;
|
||||
nrzi = (last_symbol << 31) | (last_symbol << 30) | (nrzi >> 2);
|
||||
}
|
||||
nrzi >>= 12;
|
||||
printf("%02X %05X\n", byte_value, nrzi);
|
||||
*/
|
||||
unsigned lookup20[256] = {
|
||||
0x3FF00, 0xCFF00, 0xC3F00, 0x33F00, 0xC0F00, 0x30F00, 0x3CF00, 0xCCF00,
|
||||
0xC0300, 0x30300, 0x3C300, 0xCC300, 0x3F300, 0xCF300, 0xC3300, 0x33300,
|
||||
0xC00C0, 0x300C0, 0x3C0C0, 0xCC0C0, 0x3F0C0, 0xCF0C0, 0xC30C0, 0x330C0,
|
||||
0x3FCC0, 0xCFCC0, 0xC3CC0, 0x33CC0, 0xC0CC0, 0x30CC0, 0x3CCC0, 0xCCCC0,
|
||||
0xC00F0, 0x300F0, 0x3C0F0, 0xCC0F0, 0x3F0F0, 0xCF0F0, 0xC30F0, 0x330F0,
|
||||
0x3FCF0, 0xCFCF0, 0xC3CF0, 0x33CF0, 0xC0CF0, 0x30CF0, 0x3CCF0, 0xCCCF0,
|
||||
0x3FF30, 0xCFF30, 0xC3F30, 0x33F30, 0xC0F30, 0x30F30, 0x3CF30, 0xCCF30,
|
||||
0xC0330, 0x30330, 0x3C330, 0xCC330, 0x3F330, 0xCF330, 0xC3330, 0x33330,
|
||||
0xC00FC, 0x300FC, 0x3C0FC, 0xCC0FC, 0x3F0FC, 0xCF0FC, 0xC30FC, 0x330FC,
|
||||
0x3FCFC, 0xCFCFC, 0xC3CFC, 0x33CFC, 0xC0CFC, 0x30CFC, 0x3CCFC, 0xCCCFC,
|
||||
0x3FF3C, 0xCFF3C, 0xC3F3C, 0x33F3C, 0xC0F3C, 0x30F3C, 0x3CF3C, 0xCCF3C,
|
||||
0xC033C, 0x3033C, 0x3C33C, 0xCC33C, 0x3F33C, 0xCF33C, 0xC333C, 0x3333C,
|
||||
0x3FF0C, 0xCFF0C, 0xC3F0C, 0x33F0C, 0xC0F0C, 0x30F0C, 0x3CF0C, 0xCCF0C,
|
||||
0xC030C, 0x3030C, 0x3C30C, 0xCC30C, 0x3F30C, 0xCF30C, 0xC330C, 0x3330C,
|
||||
0xC00CC, 0x300CC, 0x3C0CC, 0xCC0CC, 0x3F0CC, 0xCF0CC, 0xC30CC, 0x330CC,
|
||||
0x3FCCC, 0xCFCCC, 0xC3CCC, 0x33CCC, 0xC0CCC, 0x30CCC, 0x3CCCC, 0xCCCCC,
|
||||
0xC00FF, 0x300FF, 0x3C0FF, 0xCC0FF, 0x3F0FF, 0xCF0FF, 0xC30FF, 0x330FF,
|
||||
0x3FCFF, 0xCFCFF, 0xC3CFF, 0x33CFF, 0xC0CFF, 0x30CFF, 0x3CCFF, 0xCCCFF,
|
||||
0x3FF3F, 0xCFF3F, 0xC3F3F, 0x33F3F, 0xC0F3F, 0x30F3F, 0x3CF3F, 0xCCF3F,
|
||||
0xC033F, 0x3033F, 0x3C33F, 0xCC33F, 0x3F33F, 0xCF33F, 0xC333F, 0x3333F,
|
||||
0x3FF0F, 0xCFF0F, 0xC3F0F, 0x33F0F, 0xC0F0F, 0x30F0F, 0x3CF0F, 0xCCF0F,
|
||||
0xC030F, 0x3030F, 0x3C30F, 0xCC30F, 0x3F30F, 0xCF30F, 0xC330F, 0x3330F,
|
||||
0xC00CF, 0x300CF, 0x3C0CF, 0xCC0CF, 0x3F0CF, 0xCF0CF, 0xC30CF, 0x330CF,
|
||||
0x3FCCF, 0xCFCCF, 0xC3CCF, 0x33CCF, 0xC0CCF, 0x30CCF, 0x3CCCF, 0xCCCCF,
|
||||
0x3FF03, 0xCFF03, 0xC3F03, 0x33F03, 0xC0F03, 0x30F03, 0x3CF03, 0xCCF03,
|
||||
0xC0303, 0x30303, 0x3C303, 0xCC303, 0x3F303, 0xCF303, 0xC3303, 0x33303,
|
||||
0xC00C3, 0x300C3, 0x3C0C3, 0xCC0C3, 0x3F0C3, 0xCF0C3, 0xC30C3, 0x330C3,
|
||||
0x3FCC3, 0xCFCC3, 0xC3CC3, 0x33CC3, 0xC0CC3, 0x30CC3, 0x3CCC3, 0xCCCC3,
|
||||
0xC00F3, 0x300F3, 0x3C0F3, 0xCC0F3, 0x3F0F3, 0xCF0F3, 0xC30F3, 0x330F3,
|
||||
0x3FCF3, 0xCFCF3, 0xC3CF3, 0x33CF3, 0xC0CF3, 0x30CF3, 0x3CCF3, 0xCCCF3,
|
||||
0x3FF33, 0xCFF33, 0xC3F33, 0x33F33, 0xC0F33, 0x30F33, 0x3CF33, 0xCCF33,
|
||||
0xC0333, 0x30333, 0x3C333, 0xCC333, 0x3F333, 0xCF333, 0xC3333, 0x33333,
|
||||
};
|
||||
15
lib_adat/lib_adat/src/adat_rx.xc
Normal file
15
lib_adat/lib_adat/src/adat_rx.xc
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#ifndef ADAT_REF
|
||||
#define ADAT_REF 100
|
||||
//#warning "Assuming 100 MHz reference clock"
|
||||
#endif
|
||||
|
||||
#if (ADAT_REF == 100)
|
||||
#include "adatReceiver-100.h"
|
||||
#elif (ADAT_REF == 999375)
|
||||
#include "adatReceiver-99-9375.h"
|
||||
#else
|
||||
#error "Unknown ADAT reference specified - only 100 and 999375 are supported"
|
||||
#endif
|
||||
216
lib_adat/lib_adat/src/adat_tx.xc
Normal file
216
lib_adat/lib_adat/src/adat_tx.xc
Normal file
@@ -0,0 +1,216 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
// history:
|
||||
// 08 Jun 2010 forked from swc_usb/module_usb_audio_shared/src/adat_tx.xc tag ADAT_FORK
|
||||
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
#include <xclib.h>
|
||||
#include <print.h>
|
||||
#include "adat_lookups.h"
|
||||
|
||||
#define outuintb(c, x) outuint(c, byterev(x))
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_until_ct_4x(chanend c_data, chanend c_port, int smux)
|
||||
{
|
||||
// note: byte reverse is necessary in order to output 40 bits as unint+uchar (rather than 5 uchars)
|
||||
unsigned last_lookup = 0;
|
||||
unsigned start;
|
||||
switch (smux) {
|
||||
case 0: start = 0b00001111111111111111111100000000; break;
|
||||
case 2: start = 0b11110000000000001111111100000000; break;
|
||||
case 4: break; // TODO
|
||||
}
|
||||
while (!testct(c_data)) {
|
||||
unsigned w[8];
|
||||
w[0] = inuint(c_data);
|
||||
w[1] = inuint(c_data);
|
||||
|
||||
// sync and user bits - 16 bits output as 64 bits (4x oversampling)
|
||||
/* smux 2:
|
||||
11110000000000001111111100000000
|
||||
1 0 0 0 1 1 0 0
|
||||
00110001
|
||||
00101001
|
||||
uuuu
|
||||
no smux:
|
||||
00001111111111111111111100000000
|
||||
0 1 1 1 1 1 0 0
|
||||
00111110
|
||||
00100001
|
||||
uuuu
|
||||
*/
|
||||
if (last_lookup & 0x80) {
|
||||
outuintb(c_port, ~0);
|
||||
outuintb(c_port, ~start);
|
||||
last_lookup = ((~start >> 31) & 1) << 7;
|
||||
}
|
||||
else {
|
||||
outuintb(c_port, 0);
|
||||
outuintb(c_port, start);
|
||||
last_lookup = ((start >> 31) & 1) << 7;
|
||||
}
|
||||
|
||||
// output 8 times three 10-bit chunks - each lookup is 40 bits (4x oversampling)
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i == 2 || i == 4 || i == 6) {
|
||||
if (testct(c_data)) {
|
||||
return;
|
||||
}
|
||||
w[i] = inuint(c_data);
|
||||
w[i + 1] = inuint(c_data);
|
||||
}
|
||||
#pragma loop unroll(3)
|
||||
for (int j = 24; j >= 8; j -= 8) {
|
||||
if (last_lookup & 0x80) {
|
||||
outuint(c_port, ~lookup40w[(w[i] >> j) & 0xFF]);
|
||||
last_lookup = ~lookup40b[(w[i] >> j) & 0xFF];
|
||||
outuchar(c_port, last_lookup);
|
||||
}
|
||||
else {
|
||||
outuint(c_port, lookup40w[(w[i] >> j) & 0xFF]);
|
||||
last_lookup = lookup40b[(w[i] >> j) & 0xFF];
|
||||
outuchar(c_port, last_lookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const int sinewave[100];
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_until_ct_2x(chanend c_data, chanend c_port, int smux)
|
||||
{
|
||||
#ifdef ADAT_TX_SINEWAVE
|
||||
int sinewave_i = 0;
|
||||
#endif
|
||||
unsigned last_lookup = 0;
|
||||
unsigned start;
|
||||
switch (smux)
|
||||
{
|
||||
case 0: start = 0b00111111111100000000000000000000; break;
|
||||
case 2: start = 0b11000000111100000000000000000000; break;
|
||||
case 4: break; // TODO
|
||||
}
|
||||
while (!testct(c_data)) {
|
||||
unsigned w[8];
|
||||
w[0] = inuint(c_data);
|
||||
w[1] = inuint(c_data);
|
||||
#ifdef ADAT_TX_SINEWAVE
|
||||
w[0] = sinewave[sinewave_i];
|
||||
w[1] = sinewave[sinewave_i];
|
||||
if (++sinewave_i == 100) {
|
||||
sinewave_i = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// sync and user bits - 16 bits output as 32 bits (2x oversampling)
|
||||
/* smux 2:
|
||||
11000000111100000000000000000000
|
||||
1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
|
||||
0000000000110001
|
||||
0000000000101001
|
||||
uuuu
|
||||
no smux:
|
||||
00111111111100000000000000000000
|
||||
0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
|
||||
0000000000111110
|
||||
0000000000100001
|
||||
uuuu
|
||||
*/
|
||||
if (last_lookup & 0x80000) {
|
||||
outuintb(c_port, ~start);
|
||||
last_lookup = ((~start >> 31) & 1) << 19;
|
||||
}
|
||||
else {
|
||||
outuintb(c_port, start);
|
||||
last_lookup = ((start >> 31) & 1) << 19;
|
||||
}
|
||||
|
||||
// output 4 times six 10-bit chunks - each lookup is 20 bits (2x oversampling)
|
||||
for (int i = 0; i < 8; i += 2) {
|
||||
unsigned next_lookup;
|
||||
if (i > 0) {
|
||||
if (testct(c_data)) {
|
||||
return;
|
||||
}
|
||||
w[i] = inuint(c_data);
|
||||
w[i + 1] = inuint(c_data);
|
||||
#ifdef ADAT_TX_SINEWAVE
|
||||
w[i] = 0;
|
||||
w[i + 1] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i] >> 24) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i] >> 24) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i] >> 16) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i] >> 16) & 0xFF];
|
||||
outuintb(c_port, (next_lookup << 20) | (last_lookup & 0xFFFFF));
|
||||
outuchar(c_port, next_lookup >> 12);
|
||||
last_lookup = next_lookup;
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i] >> 8) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i] >> 8) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i + 1] >> 24) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i + 1] >> 24) & 0xFF];
|
||||
outuintb(c_port, (next_lookup << 20) | (last_lookup & 0xFFFFF));
|
||||
outuchar(c_port, next_lookup >> 12);
|
||||
last_lookup = next_lookup;
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i + 1] >> 16) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i + 1] >> 16) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i + 1] >> 8) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i + 1] >> 8) & 0xFF];
|
||||
outuintb(c_port, (next_lookup << 20) | (last_lookup & 0xFFFFF));
|
||||
outuchar(c_port, next_lookup >> 12);
|
||||
last_lookup = next_lookup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_until_ct_1x(chanend c_data, chanend c_port, int smux)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void adat_tx(chanend c_data, chanend c_port)
|
||||
{
|
||||
while (1) {
|
||||
int multiplier = inuint(c_data);
|
||||
int smux = inuint(c_data);
|
||||
|
||||
// prefilling the output port:
|
||||
// 3/6/12 outputs and 8 inputs per frame = 0.375/0.75/1.5 outputs per input
|
||||
for (int i = 0; i < 8; i++) {
|
||||
inuint(c_data);
|
||||
}
|
||||
outuint(c_port, 0);
|
||||
outuint(c_port, 0);
|
||||
outuint(c_port, 0);
|
||||
outuint(c_port, 0);
|
||||
|
||||
switch (multiplier) {
|
||||
case 1024: adat_transmit_until_ct_4x(c_data, c_port, smux); break;
|
||||
case 512: adat_transmit_until_ct_2x(c_data, c_port, smux); break;
|
||||
case 256: adat_transmit_until_ct_1x(c_data, c_port, smux); break;
|
||||
}
|
||||
|
||||
chkct(c_data, XS1_CT_END);
|
||||
}
|
||||
}
|
||||
289
lib_adat/lib_adat/src/adat_tx_port.xc
Normal file
289
lib_adat/lib_adat/src/adat_tx_port.xc
Normal file
@@ -0,0 +1,289 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
// history:
|
||||
// 08 Jun 2010 forked from swc_usb/module_usb_audio_shared/src/adat_tx_port.xc tag ADAT_FORK
|
||||
|
||||
#include <platform.h>
|
||||
#include <xclib.h>
|
||||
#include <print.h>
|
||||
#include "adat_lookups.h"
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_port_until_ct_4x(chanend c_data, buffered out port:32 p_data, int smux)
|
||||
{
|
||||
// note: byte reverse is necessary in order to output 40 bits as unint+uchar (rather than 5 uchars)
|
||||
unsigned last_lookup = 0;
|
||||
unsigned start;
|
||||
|
||||
#ifdef ADAT_TX_USE_SHARED_BUFF
|
||||
volatile unsigned * unsafe bufferPtr;
|
||||
#endif
|
||||
|
||||
// sync and user bits - 16 bits output as 64 bits (4x oversampling)
|
||||
/* smux 2:
|
||||
11110000000000001111111100000000
|
||||
1 0 0 0 1 1 0 0
|
||||
00110001
|
||||
00101001
|
||||
uuuu
|
||||
no smux:
|
||||
00001111111111111111111100000000
|
||||
0 1 1 1 1 1 0 0
|
||||
00111110
|
||||
00100001
|
||||
uuuu
|
||||
*/
|
||||
switch (smux) {
|
||||
case 0:
|
||||
case 1: start = 0b00001111111111111111111100000000; break;
|
||||
case 2:
|
||||
case 4: start = 0b11110000000000001111111100000000; break;
|
||||
}
|
||||
while (!testct(c_data)) {
|
||||
unsigned w[8];
|
||||
|
||||
#ifdef ADAT_TX_USE_SHARED_BUFF
|
||||
unsafe
|
||||
{
|
||||
/* Receive pointer to sample buffer over channel */
|
||||
bufferPtr = (unsigned * unsafe) inuint(c_data);
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i< 8; i++)
|
||||
{
|
||||
w[i] = bufferPtr[i];
|
||||
}
|
||||
/* Handshake back to indicate done with buffer */
|
||||
outuint(c_data, 0);
|
||||
}
|
||||
#else
|
||||
w[0] = inuint(c_data);
|
||||
w[1] = inuint(c_data);
|
||||
#endif
|
||||
|
||||
if (last_lookup & 0x80) {
|
||||
p_data <: ~0; /* First 8 bits of sync */
|
||||
p_data <: ~start;
|
||||
last_lookup = ((~start >> 31) & 1) << 7;
|
||||
}
|
||||
else {
|
||||
p_data <: 0; /* First 8 bits of sync */
|
||||
p_data <: start;
|
||||
last_lookup = ((start >> 31) & 1) << 7;
|
||||
}
|
||||
|
||||
// output 8 times three 10-bit chunks - each lookup is 40 bits (4x oversampling)
|
||||
#pragma loop unroll
|
||||
for (int i = 0; i < 8; i++) {
|
||||
#ifndef ADAT_TX_USE_SHARED_BUFF
|
||||
if (i == 2 || i == 4 || i == 6) {
|
||||
if (testct(c_data)) {
|
||||
return;
|
||||
}
|
||||
w[i] = inuint(c_data);
|
||||
w[i + 1] = inuint(c_data);
|
||||
}
|
||||
#endif
|
||||
#pragma loop unroll
|
||||
for (int j = 24; j >= 8; j -= 8) {
|
||||
if (last_lookup & 0x80) {
|
||||
p_data <: byterev(~lookup40w[(w[i] >> j) & 0xFF]);
|
||||
last_lookup = ~lookup40b[(w[i] >> j) & 0xFF];
|
||||
partout(p_data, 8, last_lookup);
|
||||
}
|
||||
else {
|
||||
p_data <: byterev(lookup40w[(w[i] >> j) & 0xFF]);
|
||||
last_lookup = lookup40b[(w[i] >> j) & 0xFF];
|
||||
partout(p_data, 8, last_lookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const int sinewave[100];
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_port_until_ct_2x(chanend c_data, buffered out port:32 p_data, int smux)
|
||||
{
|
||||
#ifdef adat_tx_port_SINEWAVE
|
||||
int sinewave_i = 0;
|
||||
#endif
|
||||
unsigned last_lookup = 0;
|
||||
unsigned start = 0;
|
||||
|
||||
#ifdef ADAT_TX_USE_SHARED_BUFF
|
||||
volatile unsigned * unsafe bufferPtr;
|
||||
#endif
|
||||
|
||||
/* Sync is provided by 10 consecutive 0 bits followed by a 1 bit provide frame synchronization
|
||||
|
||||
4 user bits are also provided:
|
||||
|
||||
User bit 0 is designated for Timecode transport
|
||||
User bit 1 is designated for MIDI data transport
|
||||
User bit 2 is designated for S/Mux indication (96 kHz sample rate mode)
|
||||
User bit 3 is reserved and set to 0
|
||||
|
||||
Sync/user bits: 1uuuu10000000000 (LSB transmitted first)
|
||||
|
||||
Note: NRZI encoding (0 no-trans, 1 trans), a 1 bit sent every 4 bits to force a transaction
|
||||
|
||||
Sync and user bits - 16 bits output as 32 bits (2x oversampling)
|
||||
|
||||
*/
|
||||
switch (smux)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
/*
|
||||
No SMUX:
|
||||
User bits all 0: 1000010000000000
|
||||
NRZI: 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
|
||||
2x oversample: 00111111111100000000000000000000
|
||||
*/
|
||||
start = 0b00111111111100000000000000000000;
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
/*
|
||||
Note: currently use same user bits for SMUX/2 and SMUX/4.
|
||||
SMUX
|
||||
User bits, SMUX set high: 1 0010 1 0000000000
|
||||
NRZI: 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
|
||||
2x oversample 11000000111100000000000000000000
|
||||
*/
|
||||
start = 0b11000000111100000000000000000000;
|
||||
break;
|
||||
}
|
||||
while (!testct(c_data)) {
|
||||
unsigned w[8];
|
||||
|
||||
#ifdef ADAT_TX_USE_SHARED_BUFF
|
||||
unsafe
|
||||
{
|
||||
/* Receive pointer to sample buffer over channel */
|
||||
bufferPtr = (unsigned * unsafe) inuint(c_data);
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i< 8; i++)
|
||||
{
|
||||
w[i] = bufferPtr[i];
|
||||
}
|
||||
/* Handshake back to indicate done with buffer */
|
||||
outuint(c_data, 0);
|
||||
}
|
||||
#else
|
||||
w[0] = inuint(c_data);
|
||||
w[1] = inuint(c_data);
|
||||
#endif
|
||||
|
||||
#ifdef adat_tx_port_SINEWAVE
|
||||
w[0] = sinewave[sinewave_i];
|
||||
w[1] = sinewave[sinewave_i];
|
||||
if (++sinewave_i == 100) {
|
||||
sinewave_i = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (last_lookup & 0x80000) {
|
||||
p_data <: ~start;
|
||||
last_lookup = ((~start >> 31) & 1) << 19;
|
||||
}
|
||||
else {
|
||||
p_data <: start;
|
||||
last_lookup = ((start >> 31) & 1) << 19;
|
||||
}
|
||||
|
||||
// output 4 times six 10-bit chunks - each lookup is 20 bits (2x oversampling)
|
||||
for (int i = 0; i < 8; i += 2) {
|
||||
unsigned next_lookup;
|
||||
if (i > 0) {
|
||||
#ifndef ADAT_TX_USE_SHARED_BUFF
|
||||
if (testct(c_data)) {
|
||||
return;
|
||||
}
|
||||
w[i] = inuint(c_data);
|
||||
w[i + 1] = inuint(c_data);
|
||||
#endif
|
||||
#ifdef adat_tx_port_SINEWAVE
|
||||
w[i] = 0;
|
||||
w[i + 1] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i] >> 24) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i] >> 24) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i] >> 16) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i] >> 16) & 0xFF];
|
||||
|
||||
p_data <: (next_lookup << 20) | (last_lookup & 0xFFFFF);
|
||||
partout(p_data, 8, (next_lookup >> 12));
|
||||
// Note: This is what's achieved by outuchar(c_port, next_lookup >> 12); in the original impl
|
||||
// I.e. outuchar manages to push 8 bit into the bottom of the output word
|
||||
last_lookup = next_lookup;
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i] >> 8) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i] >> 8) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i + 1] >> 24) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i + 1] >> 24) & 0xFF];
|
||||
|
||||
p_data <: (next_lookup << 20) | (last_lookup & 0xFFFFF);
|
||||
partout(p_data, 8, (next_lookup >> 12));
|
||||
last_lookup = next_lookup;
|
||||
|
||||
if (last_lookup & 0x80000)
|
||||
last_lookup = ~lookup20[(w[i + 1] >> 16) & 0xFF];
|
||||
else
|
||||
last_lookup = lookup20[(w[i + 1] >> 16) & 0xFF];
|
||||
if (last_lookup & 0x80000)
|
||||
next_lookup = ~lookup20[(w[i + 1] >> 8) & 0xFF];
|
||||
else
|
||||
next_lookup = lookup20[(w[i + 1] >> 8) & 0xFF];
|
||||
|
||||
p_data <: (next_lookup << 20) | (last_lookup & 0xFFFFF);
|
||||
partout(p_data, 8, (next_lookup >> 12));
|
||||
last_lookup = next_lookup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unsafe arrays
|
||||
void adat_transmit_port_until_ct_1x(chanend c_data, buffered out port:32 p_data, int smux)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void adat_tx_port(chanend c_data, buffered out port:32 p_data)
|
||||
{
|
||||
|
||||
int multiplier = inuint(c_data);
|
||||
int smux = inuint(c_data);
|
||||
|
||||
// prefilling the output port:
|
||||
// 3/6/12 outputs and 8 inputs per frame = 0.375/0.75/1.5 outputs per input
|
||||
|
||||
/* Wait for the other side to start up */
|
||||
if(!testct(c_data))
|
||||
{
|
||||
p_data <: byterev(0);
|
||||
p_data <: byterev(0);
|
||||
p_data <: byterev(0);
|
||||
p_data <: byterev(0);
|
||||
|
||||
switch (multiplier) {
|
||||
case 1024: adat_transmit_port_until_ct_4x(c_data, p_data, smux); break;
|
||||
case 512: adat_transmit_port_until_ct_2x(c_data, p_data, smux); break;
|
||||
case 256: adat_transmit_port_until_ct_1x(c_data, p_data, smux); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
chkct(c_data, XS1_CT_END);
|
||||
}
|
||||
Reference in New Issue
Block a user