init
This commit is contained in:
38
lib_adat/CHANGELOG.rst
Normal file
38
lib_adat/CHANGELOG.rst
Normal file
@@ -0,0 +1,38 @@
|
||||
lib_adat change log
|
||||
===================
|
||||
|
||||
2.0.1
|
||||
-----
|
||||
|
||||
* CHANGED: Documentation updated
|
||||
|
||||
2.0.0
|
||||
-----
|
||||
|
||||
* ADDED: "adat.h" header file provided access to both transmit and receive
|
||||
API
|
||||
* CHANGED: Receive API now uses streaming chanend (breaking change)
|
||||
* CHANGED: Documentation updates
|
||||
* CHANGED: Examples now build using XCommon Cmake build system
|
||||
|
||||
1.2.0
|
||||
-----
|
||||
|
||||
* CHANGED: Example applications now run on xcore.ai hardware
|
||||
* CHANGED: Example applications build using XCommon CMake
|
||||
|
||||
1.1.0
|
||||
-----
|
||||
|
||||
* ADDED: Support for XCommon CMake build system
|
||||
|
||||
1.0.1
|
||||
-----
|
||||
|
||||
* REMOVED: Duplicate header file
|
||||
|
||||
1.0.0
|
||||
-----
|
||||
|
||||
* Initial release
|
||||
|
||||
84
lib_adat/LICENSE.rst
Normal file
84
lib_adat/LICENSE.rst
Normal file
@@ -0,0 +1,84 @@
|
||||
*******************************
|
||||
XMOS PUBLIC LICENCE: Version 1
|
||||
*******************************
|
||||
|
||||
Subject to the conditions and limitations below, permission is hereby granted by XMOS LIMITED (“XMOS”), free of charge, to any person or entity obtaining a copy of the XMOS Software.
|
||||
|
||||
**1. Definitions**
|
||||
|
||||
**“Applicable Patent Rights”** means: (a) where XMOS is the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to XMOS and (ii) that cover subject matter contained in the Software, but only to the extent it is necessary to use, reproduce or distribute the Software without infringement; and (b) where you are the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to you and (ii) that cover the subject matter contained in your Derivatives, taken alone or in combination with the Software.
|
||||
|
||||
**“Compiled Code”** means any compiled, binary, machine readable or executable version of the Source Code.
|
||||
|
||||
**“Contributor”** means any person or entity that creates or contributes to the creation of Derivatives.
|
||||
|
||||
**“Derivatives”** means any addition to, deletion from and/or change to the substance, structure of the Software, any previous Derivatives, the combination of the Derivatives and the Software and/or any respective portions thereof.
|
||||
|
||||
**“Source Code”** means the human readable code that is suitable for making modifications but excluding any Compiled Code.
|
||||
|
||||
**“Software”** means the software and associated documentation files which XMOS makes available and which contain a notice identifying the software as original XMOS software and referring to the software being subject to the terms of this XMOS Public Licence.
|
||||
|
||||
This Licence refers to XMOS Software and does not relate to any XMOS hardware or devices which are protected by intellectual property rights (including patent and trade marks) which may be sold to you under a separate agreement.
|
||||
|
||||
|
||||
**2. Licence**
|
||||
|
||||
**Permitted Uses, Conditions and Restrictions.** Subject to the conditions below, XMOS grants you a worldwide, royalty free, non-exclusive licence, to the extent of any Patent Rights to do the following:
|
||||
|
||||
2.1 **Unmodified Software.** You may use, copy, display, publish, distribute and make available unmodified copies of the Software:
|
||||
|
||||
2.1.1 for personal or academic, non-commercial purposes; or
|
||||
|
||||
2.1.2 for commercial purposes provided the Software is at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.1.1 and 2.1.2):
|
||||
|
||||
(a) you must retain and reproduce in all copies of the Software the copyright and proprietary notices and disclaimers of XMOS as they appear in the Software, and keep intact all notices and disclaimers in the Software files that refer to this Licence; and
|
||||
|
||||
(b) you must include a copy of this Licence with every copy of the Software and documentation you publish, distribute and make available and you may not offer or impose any terms on such Software that alter or restrict this Licence or the intent of such Licence, except as permitted below (Additional Terms).
|
||||
|
||||
The licence above does not include any Compiled Code which XMOS may make available under a separate support and licence agreement.
|
||||
|
||||
2.2 **Derivatives.** You may create and modify Derivatives and use, copy, display, publish, distribute and make available Derivatives:
|
||||
|
||||
2.2.1 for personal or academic, non-commercial purposes; or
|
||||
|
||||
2.2.2 for commercial purposes, provided the Derivatives are at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.2.1 and 2.2.2):
|
||||
|
||||
(a) you must comply with the terms of clause 2.1 with respect to the Derivatives;
|
||||
|
||||
(b) you must copy (to the extent it doesn’t already exist) the notice below in each file of the Derivatives, and ensure all the modified files carry prominent notices stating that you have changed the files and the date of any change; and
|
||||
|
||||
(c) if you sublicence, distribute or otherwise make the Software and/or the Derivatives available for commercial purposes, you must provide that the Software and Derivatives are at all times used on a device designed, licensed or developed by XMOS.
|
||||
|
||||
Without limitation to these terms and clause 3 below, the Source Code and Compiled Code to your Derivatives may at your discretion (but without obligation) be released, copied, displayed, published, distributed and made available; and if you elect to do so, it must be under the terms of this Licence including the terms of the licence at clauses 2.2.1, 2.2.2 and clause 3 below.
|
||||
|
||||
2.3 **Distribution of Executable Versions.** If you distribute or make available Derivatives, you must include a prominent notice in the code itself as well as in all related documentation, stating that the Source Code of the Software from which the Derivatives are based is available under the terms of this Licence, with information on how and where to obtain such Source Code.
|
||||
|
||||
**3. Your Grant of Rights.** In consideration and as a condition to this Licence, you grant to any person or entity receiving or distributing any Derivatives, a non-exclusive, royalty free, perpetual, irrevocable license under your Applicable Patent Rights and all other intellectual property rights owned or controlled by you, to use, copy, display, publish, distribute and make available your Derivatives of the same scope and extent as XMOS’s licence under clause 2.2 above.
|
||||
|
||||
**4. Combined Products.** You may create a combined product by combining Software, Derivatives and other code not covered by this Licence as a single application or product. In such instance, you must comply with the requirements of this Licence for any portion of the Software and/or Derivatives.
|
||||
|
||||
**5. Additional Terms.** You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations and/or other rights consistent with the term of this Licence (“Additional Terms”) to any legitimate recipients of the Software and/or Derivatives. The terms on which you provide such Additional Terms are on your sole responsibility and you shall indemnify, defend and hold XMOS harmless against any claims asserted against XMOS.
|
||||
|
||||
**6. New Versions.** XMOS may publish revised and/or new versions of this Licence from time to time to accommodate changes to the Licence terms, new versions, updates and bug fixes of the Software. Each version will be given a distinguishing version number. Once Software has been published under a particular version of this Licence, you may continue to use it under the terms of that version. You may also choose to use the latest version of the Software under any subsequent version published by XMOS. Only XMOS shall have the right to modify these terms.
|
||||
|
||||
**7. IPR and Ownership**
|
||||
Any rights, including all intellectual property rights and all trademarks not expressly granted herein are reserved in full by the authors or copyright holders. Any requests for additional permissions by XMOS including any rights to use XMOS trademarks, should be made (without obligation) to XMOS at **support@xmos.com**
|
||||
|
||||
Nothing herein shall limit any rights that XMOS is otherwise entitled to under the doctrines of patent exhaustion, implied license, or legal estoppel. Neither the name of the authors, the copyright holders or any contributors may be used to endorse or promote any Derivatives from this Software without specific written permission. Any attempt to deal with the Software which does not comply with this Licence shall be void and shall automatically terminate any rights granted under this licence (including any licence of any intellectual property rights granted herein).
|
||||
Subject to the licences granted under this Licence any Contributor retains all rights, title and interest in and to any Derivatives made by Contributor subject to the underlying rights of XMOS in the Software. XMOS shall retain all rights, title and interest in the Software and any Derivatives made by XMOS (“XMOS Derivatives”). XMOS Derivatives will not automatically be subject to this Licence and XMOS shall be entitled to licence such rights on any terms (without obligation) as it sees fit.
|
||||
|
||||
**8. Termination**
|
||||
|
||||
8.1 This Licence will automatically terminate immediately, without notice to you, if:
|
||||
|
||||
(a) you fail to comply with the terms of this Licence; and/or
|
||||
|
||||
(b) you directly or indirectly commence any action for patent or intellectual property right infringement against XMOS, or any parent, group, affiliate or subsidiary of XMOS; provided XMOS did not first commence an action or patent infringement against you in that instance; and/or
|
||||
|
||||
(c) the terms of this Licence are held by any court of competent jurisdiction to be unenforceable in whole or in part.
|
||||
|
||||
**9. Critical Applications.** Unless XMOS has agreed in writing with you an agreement specifically governing use of the Goods in military, aerospace, automotive or medically related functions (collectively and individually hereinafter referred to as "Special Use"), any permitted use of the Software excludes Special Use. Notwithstanding any agreement between XMOS and you for Special Use, Special Use shall be at your own risk, and you shall fully indemnify XMOS against any damages, losses, costs and claims (direct and indirect) arising out of any Special Use.
|
||||
|
||||
**10. NO WARRANTY OR SUPPORT.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XMOS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, WARRANTY, CIVIL TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE INCLUDING GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND NOT WITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE. IN SOME JURISDICTIONS PARTIES ARE UNABLE TO LIMIT LIABILTY IN THIS WAY, IF THIS APPLIES TO YOUR JURISDICTION THIS LIABILITY CLAUSE ABOVE MAY NOT APPLY. NOTWITHSTANDING THE ABOVE, IN NO EVENT SHALL XMOS’s TOTAL LIABILITY TO YOU FOR ALL DAMAGES, LOSS OR OTHERWISE EXCEED $50.
|
||||
|
||||
**11. Governing Law and Jurisdiction.** This Licence constitutes the entire agreement between the parties with respect to the subject matter hereof. The Licence shall be governed by the laws of England and the conflict of laws and UN Convention on Contracts for the International Sale of Goods, shall not apply.
|
||||
69
lib_adat/README.rst
Normal file
69
lib_adat/README.rst
Normal file
@@ -0,0 +1,69 @@
|
||||
:orphan:
|
||||
|
||||
########################
|
||||
lib_adat: ADAT lightpipe
|
||||
########################
|
||||
|
||||
:vendor: XMOS
|
||||
:version: 2.0.1
|
||||
:scope: General Use
|
||||
:description: ADAT Lightpipe digital audio interface
|
||||
:category: Audio
|
||||
:keywords: ADAT
|
||||
:devices: xcore.ai, xcore-200
|
||||
|
||||
*******
|
||||
Summary
|
||||
*******
|
||||
|
||||
Provides ADAT transmitter and receiver implementations, each in a separate thread. Additional
|
||||
threads are required to collect and supply data via a channel end interface. These threads are
|
||||
required to deal with any sample ordering required for S/MUX.
|
||||
|
||||
********
|
||||
Features
|
||||
********
|
||||
|
||||
* 48000 and 44100 ADAT receivers
|
||||
* 48000 and 44100 ADAT transmitters
|
||||
* Application for loopback testing on Simulator or hardware
|
||||
|
||||
************
|
||||
Known issues
|
||||
************
|
||||
|
||||
* ADAT Rx: Requirement for 100 MHz reference clock (#18)
|
||||
* ADAT Tx: No support for 256x master clock (i.e. 48 kHz from 12.288 MHz master clock) (#17)
|
||||
|
||||
****************
|
||||
Development repo
|
||||
****************
|
||||
|
||||
* `lib_adat <https://www.github.com/xmos/lib_adat>`_
|
||||
|
||||
**************
|
||||
Required tools
|
||||
**************
|
||||
|
||||
* XMOS XTC Tools: 15.3.0
|
||||
|
||||
*********************************
|
||||
Required libraries (dependencies)
|
||||
*********************************
|
||||
|
||||
* None
|
||||
|
||||
*************************
|
||||
Related application notes
|
||||
*************************
|
||||
|
||||
The following application notes use this library:
|
||||
|
||||
* `AN02003: SPDIF/ADAT/I²S Receive to I²S Slave Bridge with ASRC <https://www.xmos.com/file/an02003>`_
|
||||
|
||||
*******
|
||||
Support
|
||||
*******
|
||||
|
||||
This package is supported by XMOS Ltd. Issues can be raised against the software at: http://www.xmos.com/support
|
||||
|
||||
11
lib_adat/examples/app_adat_loopback/CMakeLists.txt
Normal file
11
lib_adat/examples/app_adat_loopback/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
project(app_adat_loopback)
|
||||
|
||||
set(APP_HW_TARGET xk-audio-316-mc.xn)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)
|
||||
set(APP_COMPILER_FLAGS -O3 -g -DADAT_TX_USE_SHARED_BUFF)
|
||||
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
2
lib_adat/examples/app_adat_loopback/basic.xscope
Normal file
2
lib_adat/examples/app_adat_loopback/basic.xscope
Normal file
@@ -0,0 +1,2 @@
|
||||
<xSCOPEconfig ioMode="basic" enabled="true">
|
||||
</xSCOPEconfig>
|
||||
134
lib_adat/examples/app_adat_loopback/src/main.xc
Normal file
134
lib_adat/examples/app_adat_loopback/src/main.xc
Normal file
@@ -0,0 +1,134 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
#include "adat_tx.h"
|
||||
#include "adat_rx.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sw_pll.h"
|
||||
}
|
||||
|
||||
#include "stdio.h"
|
||||
#include "assert.h"
|
||||
|
||||
#define MAX_GEN_VAL (1<<24)
|
||||
#define COUNT_SHIFT 5
|
||||
#define DONE_CONDITION_MASK ~((1<<COUNT_SHIFT)-1)
|
||||
|
||||
buffered out port:32 p_adat_tx = PORT_ADAT_OUT;
|
||||
buffered in port:32 p_adat_rx = PORT_ADAT_IN;
|
||||
in port p_mclk_in = PORT_MCLK_IN;
|
||||
out port p_ctrl = PORT_CTRL;
|
||||
on tile[1]: clock clk_audio = XS1_CLKBLK_2;
|
||||
|
||||
#define MCLK_FREQUENCY_48 24576000
|
||||
|
||||
void board_setup()
|
||||
{
|
||||
set_port_drive_high(p_ctrl);
|
||||
|
||||
// Drive control port to turn on 3V3.
|
||||
// Bits set to low will be high-z, pulled down.
|
||||
p_ctrl <: 0xA0;
|
||||
|
||||
// Wait for power supplies to be up and stable.
|
||||
delay_milliseconds(10);
|
||||
|
||||
sw_pll_fixed_clock(MCLK_FREQUENCY_48);
|
||||
}
|
||||
|
||||
void collect_samples(streaming chanend c)
|
||||
{
|
||||
unsigned expected_data = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
while(expected_data < MAX_GEN_VAL) {
|
||||
unsigned channels[8];
|
||||
|
||||
c :> unsigned tmp;
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
c :> channels[i];
|
||||
|
||||
expected_data += 1 << (count >> COUNT_SHIFT);
|
||||
|
||||
if(channels[i] != expected_data << 8) {
|
||||
printf("Error: Received data 0x%x differs from expected data 0x%x. Correctly received so far %d\n", channels[i], expected_data << 8, count);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
printf("Received %d samples as expected\n", count);
|
||||
}
|
||||
|
||||
unsigned samples[8];
|
||||
|
||||
void generate_samples(chanend c_data)
|
||||
{
|
||||
unsigned data = 0;
|
||||
int count = 0;
|
||||
|
||||
outuint(c_data, MCLK_FREQUENCY_48 / 48000); // master clock multiplier
|
||||
outuint(c_data, 1); // S/MUX value
|
||||
|
||||
while(1) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
data += 1 << (count >> COUNT_SHIFT);
|
||||
++count;
|
||||
samples[i] = data << 8;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
volatile unsigned * unsafe sample_ptr = (unsigned * unsafe) &samples[0];
|
||||
outuint(c_data, (unsigned) sample_ptr);
|
||||
}
|
||||
|
||||
if (data >= MAX_GEN_VAL) {
|
||||
break;
|
||||
}
|
||||
|
||||
inuint(c_data);
|
||||
};
|
||||
|
||||
printf("Finished sending %d words\n", count);
|
||||
|
||||
inuint(c_data);
|
||||
outct(c_data, XS1_CT_END);
|
||||
}
|
||||
|
||||
void receive_adat(streaming chanend c)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
adatReceiver48000(p_adat_rx, c);
|
||||
}
|
||||
}
|
||||
|
||||
void transmit_adat(chanend c) {
|
||||
set_clock_src(clk_audio, p_mclk_in);
|
||||
configure_out_port_no_ready(p_adat_tx, clk_audio, 0);
|
||||
set_clock_fall_delay(clk_audio, 7);
|
||||
start_clock(clk_audio);
|
||||
|
||||
adat_tx_port(c, p_adat_tx);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
chan c_data_tx;
|
||||
streaming chan c_data_rx;
|
||||
|
||||
par {
|
||||
on tile[0]: {
|
||||
board_setup();
|
||||
receive_adat(c_data_rx);
|
||||
}
|
||||
on tile[0]: collect_samples(c_data_rx);
|
||||
on tile[1]: generate_samples(c_data_tx);
|
||||
on tile[1]: transmit_adat(c_data_tx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
93
lib_adat/examples/app_adat_loopback/src/xk-audio-316-mc.xn
Normal file
93
lib_adat/examples/app_adat_loopback/src/xk-audio-316-mc.xn
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Network xmlns="http://www.xmos.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
|
||||
<Type>Board</Type>
|
||||
<Name>xcore.ai MC Audio Board</Name>
|
||||
|
||||
<Declarations>
|
||||
<Declaration>tileref tile[2]</Declaration>
|
||||
</Declarations>
|
||||
|
||||
<Packages>
|
||||
<Package id="0" Type="XS3-UnA-1024-TQ128">
|
||||
<Nodes>
|
||||
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
|
||||
<Boot>
|
||||
<Source Location="bootFlash"/>
|
||||
</Boot>
|
||||
<Tile Number="0" Reference="tile[0]">
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
|
||||
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
|
||||
|
||||
<!-- Various ctrl signals -->
|
||||
<Port Location="XS1_PORT_8D" Name="PORT_CTRL"/>
|
||||
|
||||
<!-- I2C -->
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2C_SCL"/>
|
||||
<Port Location="XS1_PORT_1M" Name="PORT_I2C_SDA"/>
|
||||
|
||||
<!-- Clocking -->
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/> <!-- N: Coax O: Optical -->
|
||||
<Port Location="XS1_PORT_1N" Name="PORT_SPDIF_IN"/> <!-- N: Coax O: Optical -->
|
||||
|
||||
</Tile>
|
||||
<Tile Number="1" Reference="tile[1]">
|
||||
<!-- Audio Ports: I2S -->
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/>
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
|
||||
<port Location="XS1_PORT_1O" Name="PORT_I2S_DAC1"/>
|
||||
<port Location="XS1_PORT_1N" Name="PORT_I2S_DAC2"/>
|
||||
<port Location="XS1_PORT_1M" Name="PORT_I2S_DAC3"/>
|
||||
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
|
||||
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1G" Name="PORT_ADAT_OUT"/> <!-- A: Coax G: Optical -->
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_SPDIF_OUT"/> <!-- A: Coax G: Optical -->
|
||||
|
||||
<!-- MIDI -->
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/>
|
||||
<Port Location="XS1_PORT_4C" Name="PORT_MIDI_OUT"/> <!-- bit[0] -->
|
||||
|
||||
</Tile>
|
||||
</Node>
|
||||
</Nodes>
|
||||
</Package>
|
||||
</Packages>
|
||||
<Nodes>
|
||||
<Node Id="2" Type="device:" RoutingId="0x8000">
|
||||
<Service Id="0" Proto="xscope_host_data(chanend c);">
|
||||
<Chanend Identifier="c" end="3"/>
|
||||
</Service>
|
||||
</Node>
|
||||
</Nodes>
|
||||
<Links>
|
||||
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
|
||||
<LinkEndpoint NodeId="0" Link="XL0"/>
|
||||
<LinkEndpoint NodeId="2" Chanend="1"/>
|
||||
</Link>
|
||||
</Links>
|
||||
<ExternalDevices>
|
||||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
|
||||
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
|
||||
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
|
||||
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
|
||||
</Device>
|
||||
</ExternalDevices>
|
||||
<JTAGChain>
|
||||
<JTAGDevice NodeId="0"/>
|
||||
</JTAGChain>
|
||||
|
||||
</Network>
|
||||
11
lib_adat/examples/app_adat_rx_example/CMakeLists.txt
Normal file
11
lib_adat/examples/app_adat_rx_example/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
project(app_adat_rx_example)
|
||||
|
||||
set(APP_HW_TARGET xk-audio-316-mc.xn)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)
|
||||
set(APP_COMPILER_FLAGS -O3 -g -D ADAT_REF=100)
|
||||
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
2
lib_adat/examples/app_adat_rx_example/basic.xscope
Normal file
2
lib_adat/examples/app_adat_rx_example/basic.xscope
Normal file
@@ -0,0 +1,2 @@
|
||||
<xSCOPEconfig ioMode="basic" enabled="true">
|
||||
</xSCOPEconfig>
|
||||
79
lib_adat/examples/app_adat_rx_example/src/main.xc
Normal file
79
lib_adat/examples/app_adat_rx_example/src/main.xc
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
#include <print.h>
|
||||
#include "adat_rx.h"
|
||||
|
||||
/* Port declarations */
|
||||
buffered in port:32 p_adat_rx = PORT_ADAT_IN;
|
||||
out port p_ctrl = PORT_CTRL;
|
||||
|
||||
/* Receive loop */
|
||||
void receive_adat(streaming chanend c)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
adatReceiver48000(p_adat_rx, c);
|
||||
adatReceiver44100(p_adat_rx, c);
|
||||
}
|
||||
}
|
||||
//::
|
||||
|
||||
/* Data handler */
|
||||
void collect_samples(streaming chanend c)
|
||||
{
|
||||
unsigned head, channels[9];
|
||||
int count = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
c :> head;
|
||||
if ((head & 0xF) == 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
channels[i] = head;
|
||||
}
|
||||
++count;
|
||||
|
||||
if ((count % 100000) == 0)
|
||||
{
|
||||
printstr("Frames received: ");
|
||||
printintln(count);
|
||||
}
|
||||
// One whole frame in channels [0..7]
|
||||
}
|
||||
}
|
||||
//::
|
||||
|
||||
void board_setup(void)
|
||||
{
|
||||
set_port_drive_high(p_ctrl);
|
||||
|
||||
// Drive control port to turn on 3V3.
|
||||
// Bits set to low will be high-z, pulled down.
|
||||
p_ctrl <: 0xA0;
|
||||
|
||||
// Wait for power supplies to be up and stable.
|
||||
delay_milliseconds(10);
|
||||
}
|
||||
|
||||
/* Top-level main */
|
||||
int main(void)
|
||||
{
|
||||
streaming chan c;
|
||||
par
|
||||
{
|
||||
on tile[0]:
|
||||
{
|
||||
board_setup();
|
||||
receive_adat(c);
|
||||
}
|
||||
on tile[0]: collect_samples(c);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//::
|
||||
93
lib_adat/examples/app_adat_rx_example/src/xk-audio-316-mc.xn
Normal file
93
lib_adat/examples/app_adat_rx_example/src/xk-audio-316-mc.xn
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Network xmlns="http://www.xmos.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
|
||||
<Type>Board</Type>
|
||||
<Name>xcore.ai MC Audio Board</Name>
|
||||
|
||||
<Declarations>
|
||||
<Declaration>tileref tile[2]</Declaration>
|
||||
</Declarations>
|
||||
|
||||
<Packages>
|
||||
<Package id="0" Type="XS3-UnA-1024-TQ128">
|
||||
<Nodes>
|
||||
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
|
||||
<Boot>
|
||||
<Source Location="bootFlash"/>
|
||||
</Boot>
|
||||
<Tile Number="0" Reference="tile[0]">
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
|
||||
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
|
||||
|
||||
<!-- Various ctrl signals -->
|
||||
<Port Location="XS1_PORT_8D" Name="PORT_CTRL"/>
|
||||
|
||||
<!-- I2C -->
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2C_SCL"/>
|
||||
<Port Location="XS1_PORT_1M" Name="PORT_I2C_SDA"/>
|
||||
|
||||
<!-- Clocking -->
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/> <!-- N: Coax O: Optical -->
|
||||
<Port Location="XS1_PORT_1N" Name="PORT_SPDIF_IN"/> <!-- N: Coax O: Optical -->
|
||||
|
||||
</Tile>
|
||||
<Tile Number="1" Reference="tile[1]">
|
||||
<!-- Audio Ports: I2S -->
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/>
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
|
||||
<port Location="XS1_PORT_1O" Name="PORT_I2S_DAC1"/>
|
||||
<port Location="XS1_PORT_1N" Name="PORT_I2S_DAC2"/>
|
||||
<port Location="XS1_PORT_1M" Name="PORT_I2S_DAC3"/>
|
||||
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
|
||||
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1G" Name="PORT_ADAT_OUT"/> <!-- A: Coax G: Optical -->
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_SPDIF_OUT"/> <!-- A: Coax G: Optical -->
|
||||
|
||||
<!-- MIDI -->
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/>
|
||||
<Port Location="XS1_PORT_4C" Name="PORT_MIDI_OUT"/> <!-- bit[0] -->
|
||||
|
||||
</Tile>
|
||||
</Node>
|
||||
</Nodes>
|
||||
</Package>
|
||||
</Packages>
|
||||
<Nodes>
|
||||
<Node Id="2" Type="device:" RoutingId="0x8000">
|
||||
<Service Id="0" Proto="xscope_host_data(chanend c);">
|
||||
<Chanend Identifier="c" end="3"/>
|
||||
</Service>
|
||||
</Node>
|
||||
</Nodes>
|
||||
<Links>
|
||||
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
|
||||
<LinkEndpoint NodeId="0" Link="XL0"/>
|
||||
<LinkEndpoint NodeId="2" Chanend="1"/>
|
||||
</Link>
|
||||
</Links>
|
||||
<ExternalDevices>
|
||||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
|
||||
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
|
||||
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
|
||||
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
|
||||
</Device>
|
||||
</ExternalDevices>
|
||||
<JTAGChain>
|
||||
<JTAGDevice NodeId="0"/>
|
||||
</JTAGChain>
|
||||
|
||||
</Network>
|
||||
11
lib_adat/examples/app_adat_tx_direct_example/CMakeLists.txt
Normal file
11
lib_adat/examples/app_adat_tx_direct_example/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
project(app_adat_tx_direct_example)
|
||||
|
||||
set(APP_HW_TARGET xk-audio-316-mc.xn)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)
|
||||
set(APP_COMPILER_FLAGS -g -DADAT_TX_USE_SHARED_BUFF)
|
||||
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
134
lib_adat/examples/app_adat_tx_direct_example/src/main.xc
Normal file
134
lib_adat/examples/app_adat_tx_direct_example/src/main.xc
Normal file
@@ -0,0 +1,134 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
#include "adat_tx.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sw_pll.h"
|
||||
}
|
||||
|
||||
/* Port declarations */
|
||||
buffered out port:32 p_adat_tx = PORT_ADAT_OUT;
|
||||
in port p_mclk_in = PORT_MCLK_IN;
|
||||
out port p_ctrl = PORT_CTRL;
|
||||
on tile[1]: clock clk_audio = XS1_CLKBLK_2;
|
||||
//:
|
||||
|
||||
#define MCLK_FREQUENCY_48 24576000
|
||||
|
||||
void board_setup(void)
|
||||
{
|
||||
set_port_drive_high(p_ctrl);
|
||||
|
||||
// Drive control port to turn on 3V3.
|
||||
// Bits set to low will be high-z, pulled down.
|
||||
p_ctrl <: 0xA0;
|
||||
|
||||
// Wait for power supplies to be up and stable.
|
||||
delay_milliseconds(10);
|
||||
|
||||
sw_pll_fixed_clock(MCLK_FREQUENCY_48);
|
||||
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
#define SINE_TABLE_SIZE 100
|
||||
const int sine_table[SINE_TABLE_SIZE] =
|
||||
{
|
||||
0x0100da00,0x0200b000,0x02fe8100,0x03f94b00,0x04f01100,
|
||||
0x05e1da00,0x06cdb200,0x07b2aa00,0x088fdb00,0x09646600,
|
||||
0x0a2f7400,0x0af03700,0x0ba5ed00,0x0c4fde00,0x0ced5f00,
|
||||
0x0d7dd100,0x0e00a100,0x0e754b00,0x0edb5a00,0x0f326700,
|
||||
0x0f7a1800,0x0fb22700,0x0fda5b00,0x0ff28a00,0x0ffa9c00,
|
||||
0x0ff28a00,0x0fda5b00,0x0fb22700,0x0f7a1800,0x0f326700,
|
||||
0x0edb5a00,0x0e754b00,0x0e00a100,0x0d7dd100,0x0ced5f00,
|
||||
0x0c4fde00,0x0ba5ed00,0x0af03700,0x0a2f7400,0x09646600,
|
||||
0x088fdb00,0x07b2aa00,0x06cdb200,0x05e1da00,0x04f01100,
|
||||
0x03f94b00,0x02fe8100,0x0200b000,0x0100da00,0x00000000,
|
||||
0xfeff2600,0xfdff5000,0xfd017f00,0xfc06b500,0xfb0fef00,
|
||||
0xfa1e2600,0xf9324e00,0xf84d5600,0xf7702500,0xf69b9a00,
|
||||
0xf5d08c00,0xf50fc900,0xf45a1300,0xf3b02200,0xf312a100,
|
||||
0xf2822f00,0xf1ff5f00,0xf18ab500,0xf124a600,0xf0cd9900,
|
||||
0xf085e800,0xf04dd900,0xf025a500,0xf00d7600,0xf0056400,
|
||||
0xf00d7600,0xf025a500,0xf04dd900,0xf085e800,0xf0cd9900,
|
||||
0xf124a600,0xf18ab500,0xf1ff5f00,0xf2822f00,0xf312a100,
|
||||
0xf3b02200,0xf45a1300,0xf50fc900,0xf5d08c00,0xf69b9a00,
|
||||
0xf7702500,0xf84d5600,0xf9324e00,0xfa1e2600,0xfb0fef00,
|
||||
0xfc06b500,0xfd017f00,0xfdff5000,0xfeff2600,0x00000000,
|
||||
};
|
||||
|
||||
unsigned samples[8];
|
||||
|
||||
/* Data generation task */
|
||||
void generate_samples(chanend c) {
|
||||
int count1 = 0;
|
||||
int count2 = 0;
|
||||
int count4 = 0;
|
||||
outuint(c, MCLK_FREQUENCY_48 / 48000); // clock multiplier value
|
||||
outuint(c, 1); // S/MUX value
|
||||
unsafe {
|
||||
volatile unsigned * unsafe sample_ptr = (unsigned * unsafe) &samples[0];
|
||||
outuint(c, (unsigned) sample_ptr);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
inuint(c);
|
||||
|
||||
// Update sample values
|
||||
samples[0] = sine_table[count1]; // 500Hz sine
|
||||
samples[1] = sine_table[SINE_TABLE_SIZE - 1 - count1]; // 500Hz sine, phase-shifted from channel 0
|
||||
samples[2] = sine_table[count2]; // 1000Hz sine
|
||||
samples[3] = sine_table[SINE_TABLE_SIZE - 1 - count2]; // 1000Hz sine, phase-shifted from channel 2
|
||||
samples[4] = sine_table[count4]; // 2000Hz sine
|
||||
samples[5] = sine_table[SINE_TABLE_SIZE - 1 - count4]; // 2000Hz sine, phase-shifted from channel 4
|
||||
samples[6] = sine_table[count1]; // same as channel 0
|
||||
samples[7] = sine_table[SINE_TABLE_SIZE - 1 - count1]; // same as channel 1
|
||||
|
||||
unsafe {
|
||||
volatile unsigned * unsafe sample_ptr = (unsigned * unsafe) &samples[0];
|
||||
outuint(c, (unsigned) sample_ptr);
|
||||
}
|
||||
|
||||
// Handle rollover of the sine_table array indices
|
||||
count1 += 1;
|
||||
count2 += 2;
|
||||
count4 += 4;
|
||||
if (count1 == SINE_TABLE_SIZE) {
|
||||
count1 = 0;
|
||||
count2 = 0;
|
||||
count4 = 0;
|
||||
} else if (count2 == SINE_TABLE_SIZE) {
|
||||
count2 = 0;
|
||||
count4 = 0;
|
||||
} else if (count4 == SINE_TABLE_SIZE) {
|
||||
count4 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//:
|
||||
|
||||
void transmit_adat(chanend c)
|
||||
{
|
||||
/* Setup ports and clocks */
|
||||
set_clock_src(clk_audio, p_mclk_in);
|
||||
configure_out_port_no_ready(p_adat_tx, clk_audio, 0);
|
||||
set_clock_fall_delay(clk_audio, 7);
|
||||
start_clock(clk_audio);
|
||||
|
||||
adat_tx_port(c, p_adat_tx);
|
||||
}
|
||||
|
||||
/* Top-level main */
|
||||
int main(void)
|
||||
{
|
||||
chan c;
|
||||
par
|
||||
{
|
||||
on tile[0]: board_setup();
|
||||
on tile[1]: transmit_adat(c);
|
||||
on tile[1]: generate_samples(c);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//:
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Network xmlns="http://www.xmos.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
|
||||
<Type>Board</Type>
|
||||
<Name>xcore.ai MC Audio Board</Name>
|
||||
|
||||
<Declarations>
|
||||
<Declaration>tileref tile[2]</Declaration>
|
||||
</Declarations>
|
||||
|
||||
<Packages>
|
||||
<Package id="0" Type="XS3-UnA-1024-TQ128">
|
||||
<Nodes>
|
||||
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
|
||||
<Boot>
|
||||
<Source Location="bootFlash"/>
|
||||
</Boot>
|
||||
<Tile Number="0" Reference="tile[0]">
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
|
||||
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
|
||||
|
||||
<!-- Various ctrl signals -->
|
||||
<Port Location="XS1_PORT_8D" Name="PORT_CTRL"/>
|
||||
|
||||
<!-- I2C -->
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2C_SCL"/>
|
||||
<Port Location="XS1_PORT_1M" Name="PORT_I2C_SDA"/>
|
||||
|
||||
<!-- Clocking -->
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/> <!-- N: Coax O: Optical -->
|
||||
<Port Location="XS1_PORT_1N" Name="PORT_SPDIF_IN"/> <!-- N: Coax O: Optical -->
|
||||
|
||||
</Tile>
|
||||
<Tile Number="1" Reference="tile[1]">
|
||||
<!-- Audio Ports: I2S -->
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/>
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
|
||||
<port Location="XS1_PORT_1O" Name="PORT_I2S_DAC1"/>
|
||||
<port Location="XS1_PORT_1N" Name="PORT_I2S_DAC2"/>
|
||||
<port Location="XS1_PORT_1M" Name="PORT_I2S_DAC3"/>
|
||||
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
|
||||
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1G" Name="PORT_ADAT_OUT"/> <!-- A: Coax G: Optical -->
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_SPDIF_OUT"/> <!-- A: Coax G: Optical -->
|
||||
|
||||
<!-- MIDI -->
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/>
|
||||
<Port Location="XS1_PORT_4C" Name="PORT_MIDI_OUT"/> <!-- bit[0] -->
|
||||
|
||||
</Tile>
|
||||
</Node>
|
||||
</Nodes>
|
||||
</Package>
|
||||
</Packages>
|
||||
<Nodes>
|
||||
<Node Id="2" Type="device:" RoutingId="0x8000">
|
||||
<Service Id="0" Proto="xscope_host_data(chanend c);">
|
||||
<Chanend Identifier="c" end="3"/>
|
||||
</Service>
|
||||
</Node>
|
||||
</Nodes>
|
||||
<Links>
|
||||
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
|
||||
<LinkEndpoint NodeId="0" Link="XL0"/>
|
||||
<LinkEndpoint NodeId="2" Chanend="1"/>
|
||||
</Link>
|
||||
</Links>
|
||||
<ExternalDevices>
|
||||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
|
||||
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
|
||||
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
|
||||
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
|
||||
</Device>
|
||||
</ExternalDevices>
|
||||
<JTAGChain>
|
||||
<JTAGDevice NodeId="0"/>
|
||||
</JTAGChain>
|
||||
|
||||
</Network>
|
||||
11
lib_adat/examples/app_adat_tx_example/CMakeLists.txt
Normal file
11
lib_adat/examples/app_adat_tx_example/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
project(app_adat_tx_example)
|
||||
|
||||
set(APP_HW_TARGET xk-audio-316-mc.xn)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)
|
||||
set(APP_COMPILER_FLAGS -g)
|
||||
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
145
lib_adat/examples/app_adat_tx_example/src/main.xc
Normal file
145
lib_adat/examples/app_adat_tx_example/src/main.xc
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright 2011-2024 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
#include <xclib.h>
|
||||
#include "adat_tx.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sw_pll.h"
|
||||
}
|
||||
|
||||
/* Port declarations */
|
||||
buffered out port:32 p_adat_tx = PORT_ADAT_OUT;
|
||||
in port p_mclk_in = PORT_MCLK_IN;
|
||||
out port p_ctrl = PORT_CTRL;
|
||||
on tile[1]: clock clk_audio = XS1_CLKBLK_2;
|
||||
//*
|
||||
|
||||
#define MCLK_FREQUENCY_48 24576000
|
||||
|
||||
void board_setup(void)
|
||||
{
|
||||
set_port_drive_high(p_ctrl);
|
||||
|
||||
// Drive control port to turn on 3V3.
|
||||
// Bits set to low will be high-z, pulled down.
|
||||
p_ctrl <: 0xA0;
|
||||
|
||||
// Wait for power supplies to be up and stable.
|
||||
delay_milliseconds(10);
|
||||
|
||||
sw_pll_fixed_clock(MCLK_FREQUENCY_48);
|
||||
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
/* Port driver */
|
||||
void drive_port(chanend c_port)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
p_adat_tx <: byterev(inuint(c_port));
|
||||
}
|
||||
}
|
||||
//:
|
||||
|
||||
void transmit_adat(chanend c)
|
||||
{
|
||||
chan c_port;
|
||||
|
||||
/* Port and clock setup */
|
||||
set_clock_src(clk_audio, p_mclk_in);
|
||||
configure_out_port_no_ready(p_adat_tx, clk_audio, 0);
|
||||
set_clock_fall_delay(clk_audio, 7);
|
||||
start_clock(clk_audio);
|
||||
//:
|
||||
|
||||
/* Par port-driver and adat_rx() */
|
||||
par
|
||||
{
|
||||
adat_tx(c, c_port);
|
||||
drive_port(c_port);
|
||||
}
|
||||
//:
|
||||
}
|
||||
|
||||
#define SINE_TABLE_SIZE 100
|
||||
const int sine_table[SINE_TABLE_SIZE] =
|
||||
{
|
||||
0x0100da00,0x0200b000,0x02fe8100,0x03f94b00,0x04f01100,
|
||||
0x05e1da00,0x06cdb200,0x07b2aa00,0x088fdb00,0x09646600,
|
||||
0x0a2f7400,0x0af03700,0x0ba5ed00,0x0c4fde00,0x0ced5f00,
|
||||
0x0d7dd100,0x0e00a100,0x0e754b00,0x0edb5a00,0x0f326700,
|
||||
0x0f7a1800,0x0fb22700,0x0fda5b00,0x0ff28a00,0x0ffa9c00,
|
||||
0x0ff28a00,0x0fda5b00,0x0fb22700,0x0f7a1800,0x0f326700,
|
||||
0x0edb5a00,0x0e754b00,0x0e00a100,0x0d7dd100,0x0ced5f00,
|
||||
0x0c4fde00,0x0ba5ed00,0x0af03700,0x0a2f7400,0x09646600,
|
||||
0x088fdb00,0x07b2aa00,0x06cdb200,0x05e1da00,0x04f01100,
|
||||
0x03f94b00,0x02fe8100,0x0200b000,0x0100da00,0x00000000,
|
||||
0xfeff2600,0xfdff5000,0xfd017f00,0xfc06b500,0xfb0fef00,
|
||||
0xfa1e2600,0xf9324e00,0xf84d5600,0xf7702500,0xf69b9a00,
|
||||
0xf5d08c00,0xf50fc900,0xf45a1300,0xf3b02200,0xf312a100,
|
||||
0xf2822f00,0xf1ff5f00,0xf18ab500,0xf124a600,0xf0cd9900,
|
||||
0xf085e800,0xf04dd900,0xf025a500,0xf00d7600,0xf0056400,
|
||||
0xf00d7600,0xf025a500,0xf04dd900,0xf085e800,0xf0cd9900,
|
||||
0xf124a600,0xf18ab500,0xf1ff5f00,0xf2822f00,0xf312a100,
|
||||
0xf3b02200,0xf45a1300,0xf50fc900,0xf5d08c00,0xf69b9a00,
|
||||
0xf7702500,0xf84d5600,0xf9324e00,0xfa1e2600,0xfb0fef00,
|
||||
0xfc06b500,0xfd017f00,0xfdff5000,0xfeff2600,0x00000000,
|
||||
};
|
||||
|
||||
/* Data generation task */
|
||||
void generate_samples(chanend c) {
|
||||
int count1 = 0;
|
||||
int count2 = 0;
|
||||
int count4 = 0;
|
||||
outuint(c, MCLK_FREQUENCY_48 / 48000); // clock multiplier value
|
||||
outuint(c, 0); // S/MUX value
|
||||
|
||||
for (int idx = 0; idx < 8; ++idx) {
|
||||
outuint(c, 0);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
// Send the next samples
|
||||
outuint(c, sine_table[count1]); // 500Hz sine
|
||||
outuint(c, sine_table[SINE_TABLE_SIZE - 1 - count1]); // 500Hz sine, phase-shifted from channel 0
|
||||
outuint(c, sine_table[count2]); // 1000Hz sine
|
||||
outuint(c, sine_table[SINE_TABLE_SIZE - 1 - count2]); // 1000Hz sine, phase-shifted from channel 2
|
||||
outuint(c, sine_table[count4]); // 2000Hz sine
|
||||
outuint(c, sine_table[SINE_TABLE_SIZE - 1 - count4]); // 2000Hz sine, phase-shifted from channel 4
|
||||
outuint(c, sine_table[count1]); // same as channel 0
|
||||
outuint(c, sine_table[SINE_TABLE_SIZE - 1 - count1]); // same as channel 1
|
||||
|
||||
// Handle rollover of the sine_table array indices
|
||||
count1 += 1;
|
||||
count2 += 2;
|
||||
count4 += 4;
|
||||
if (count1 == SINE_TABLE_SIZE) {
|
||||
count1 = 0;
|
||||
count2 = 0;
|
||||
count4 = 0;
|
||||
} else if (count2 == SINE_TABLE_SIZE) {
|
||||
count2 = 0;
|
||||
count4 = 0;
|
||||
} else if (count4 == SINE_TABLE_SIZE) {
|
||||
count4 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//:
|
||||
|
||||
/* Top-level main */
|
||||
int main(void) {
|
||||
|
||||
chan c;
|
||||
par
|
||||
{
|
||||
on tile[0]: board_setup();
|
||||
on tile[1]: transmit_adat(c);
|
||||
on tile[1]: generate_samples(c);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//:
|
||||
93
lib_adat/examples/app_adat_tx_example/src/xk-audio-316-mc.xn
Normal file
93
lib_adat/examples/app_adat_tx_example/src/xk-audio-316-mc.xn
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Network xmlns="http://www.xmos.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
|
||||
<Type>Board</Type>
|
||||
<Name>xcore.ai MC Audio Board</Name>
|
||||
|
||||
<Declarations>
|
||||
<Declaration>tileref tile[2]</Declaration>
|
||||
</Declarations>
|
||||
|
||||
<Packages>
|
||||
<Package id="0" Type="XS3-UnA-1024-TQ128">
|
||||
<Nodes>
|
||||
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
|
||||
<Boot>
|
||||
<Source Location="bootFlash"/>
|
||||
</Boot>
|
||||
<Tile Number="0" Reference="tile[0]">
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
|
||||
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
|
||||
|
||||
<!-- Various ctrl signals -->
|
||||
<Port Location="XS1_PORT_8D" Name="PORT_CTRL"/>
|
||||
|
||||
<!-- I2C -->
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2C_SCL"/>
|
||||
<Port Location="XS1_PORT_1M" Name="PORT_I2C_SDA"/>
|
||||
|
||||
<!-- Clocking -->
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/> <!-- N: Coax O: Optical -->
|
||||
<Port Location="XS1_PORT_1N" Name="PORT_SPDIF_IN"/> <!-- N: Coax O: Optical -->
|
||||
|
||||
</Tile>
|
||||
<Tile Number="1" Reference="tile[1]">
|
||||
<!-- Audio Ports: I2S -->
|
||||
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/>
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
|
||||
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
|
||||
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
|
||||
<port Location="XS1_PORT_1O" Name="PORT_I2S_DAC1"/>
|
||||
<port Location="XS1_PORT_1N" Name="PORT_I2S_DAC2"/>
|
||||
<port Location="XS1_PORT_1M" Name="PORT_I2S_DAC3"/>
|
||||
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
|
||||
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>
|
||||
|
||||
<!-- Audio Ports: Digital -->
|
||||
<Port Location="XS1_PORT_1G" Name="PORT_ADAT_OUT"/> <!-- A: Coax G: Optical -->
|
||||
<Port Location="XS1_PORT_1A" Name="PORT_SPDIF_OUT"/> <!-- A: Coax G: Optical -->
|
||||
|
||||
<!-- MIDI -->
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/>
|
||||
<Port Location="XS1_PORT_4C" Name="PORT_MIDI_OUT"/> <!-- bit[0] -->
|
||||
|
||||
</Tile>
|
||||
</Node>
|
||||
</Nodes>
|
||||
</Package>
|
||||
</Packages>
|
||||
<Nodes>
|
||||
<Node Id="2" Type="device:" RoutingId="0x8000">
|
||||
<Service Id="0" Proto="xscope_host_data(chanend c);">
|
||||
<Chanend Identifier="c" end="3"/>
|
||||
</Service>
|
||||
</Node>
|
||||
</Nodes>
|
||||
<Links>
|
||||
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
|
||||
<LinkEndpoint NodeId="0" Link="XL0"/>
|
||||
<LinkEndpoint NodeId="2" Chanend="1"/>
|
||||
</Link>
|
||||
</Links>
|
||||
<ExternalDevices>
|
||||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
|
||||
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
|
||||
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
|
||||
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
|
||||
</Device>
|
||||
</ExternalDevices>
|
||||
<JTAGChain>
|
||||
<JTAGDevice NodeId="0"/>
|
||||
</JTAGChain>
|
||||
|
||||
</Network>
|
||||
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