Application Note: AN10129 Using zip/unzip to implement streaming interfaces on multibit ports

Similar documents
Application Note: AN00141 xcore-xa - Application Development

Application Note: AN00103 Enabling DSD256 in the USB Audio 2.0 Device Reference Design Software

Application Note: AN00121 Using XMOS TCP/IP Library for UDP-based Networking

S/PDIF Software Component

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

AN3998 Application note

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

DFU loader for XMOS USB AUDIO devices

AN1754 APPLICATION NOTE

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

Installation and Testing of NMM (Windows)

COM Port Stress Test

Freescale Semiconductor, I

Command Processor for MPSSE and MCU Host Bus Emulation Modes

Using the CoreSight ITM for debug and testing in RTX applications

Embedded Systems Design Course Applying the mbed microcontroller

IR Communication a learn.sparkfun.com tutorial

Intel Dialogic System Release 6.1 CompactPCI for Windows

21152 PCI-to-PCI Bridge

Table of Contents. ARM Evaluation Board (AEB-1) Welcome Guide ARM DGI 0005D. Proprietary Notice

ChipScope Pro Tutorial

Definitions and Documents

DE4 NetFPGA Packet Generator Design User Guide

Lab 17: Building a 4-Digit 7-Segment LED Decoder

White Paper Utilizing Leveling Techniques in DDR3 SDRAM Memory Interfaces

NETWRIX CHANGE NOTIFIER

Enhanced Diagnostics Improve Performance, Configurability, and Usability

Getting Started with IntelleView POS Administrator Software

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Application Note 120 Communicating Through the 1-Wire Master

Linux. Reverse Debugging. Target Communication Framework. Nexus. Intel Trace Hub GDB. PIL Simulation CONTENTS

KEPServerEX Client Connectivity Guide

Developing applications under CODE COMPOSER STUDIO

Application Note. Running Applications Using Dialogic Global Call Software as Windows Services

USER GUIDE EDBG. Description

Moxa Device Manager 2.0 User s Guide

Serial Communications

Sample Configuration Using the ip nat outside source list C

Craig Pelkie Bits & Bytes Programming, Inc. craig@web400.com

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

Serial ATA PCI Quick Installation Guide

Intel Retail Client Manager Audience Analytics

Android Application Development and Bluetooth Technology

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

MatrixSSL Getting Started

Best Practises for LabVIEW FPGA Design Flow. uk.ni.com ireland.ni.com

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

RETRIEVING DATA FROM THE DDC112

AlazarTech SDK Programmer s Guide. Version May 28, 2010

Moxa Device Manager 2.3 User s Manual

PCMCIA 1 Port RS EDITION OCTOBER 1999

What is LOG Storm and what is it useful for?

Omron I/O Driver (Series 2) Programmable Serial Interface Card

Modbus and ION Technology

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Logic Pro 9. TDM Guide

Measurement and Analysis Introduction of ISO7816 (Smart Card)

Dyalog for Mac OS Installation and Configuration Guide

KEPServerEX Client Connectivity Guide

AN1229. Class B Safety Software Library for PIC MCUs and dspic DSCs OVERVIEW OF THE IEC STANDARD INTRODUCTION

Technical Manual. For use with Caller ID signaling types: Belcore 202, British Telecom, & ETSI

XMOS Programming Guide

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

Cisco T1 Layer 1 Troubleshooting

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

AN3332 Application note

Sample Configuration Using the ip nat outside source static

DAC Digital To Analog Converter

POOSL IDE Installation Manual

Configuring a Leased Line

DEPLOYING EMC DOCUMENTUM BUSINESS ACTIVITY MONITOR SERVER ON IBM WEBSPHERE APPLICATION SERVER CLUSTER

System Requirements for Microsoft Dynamics NAV 2013 R2

UM0834 User manual. Developing and debugging your STM8S-DISCOVERY application code. Introduction. Reference documents

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

PHY-2464 Physical Basis of Music

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

Board also Supports MicroBridge

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

Lesson 16 Analog-to-Digital Converter (ADC)

Installing S500 Power Monitor Software and LabVIEW Run-time Engine

Deploying Windows Streaming Media Servers NLB Cluster and metasan

2.0 Command and Data Handling Subsystem

TFTP Firmware upgrade

Identikey Server Getting Started Guide 3.1

How to deploy console cable to connect WIAS-3200N and PC, to reset setting or check status via console

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

DS-5 ARM. Using the Debugger. Version 5.7. Copyright 2010, 2011 ARM. All rights reserved. ARM DUI 0446G (ID092311)

Studio 5.0 User s Guide

Lab 2.0 Thermal Camera Interface

Solutions for Increasing the Number of PC Parallel Port Control and Selecting Lines

Flexible Active Shutter Control Interface using the MC1323x

AN3265 Application note

Digipass Plug-In for IAS. IAS Plug-In IAS. Microsoft's Internet Authentication Service. Getting Started

Additional Setup Instructions for Modbus: RTU, ASCII, TCP, Omni & Enron

E-Blocks Easy RFID Bundle

Experiment 2 Introduction to TI C2000 Microcontroller, Code Composer Studio (CCS) and Matlab Graphic User Interface (GUI)

PetaLinux SDK User Guide. Application Development Guide

Transcription:

Application Note: AN10129 Using zip/unzip to implement streaming interfaces on multibit ports This application note shows how to implement a streaming interface like I2S using a buffered 4-bit port. Streaming interfaces are usually implemented using a buffered 1-bit port for best performance. The ability to use 4-bit ports to stream multiple independent 1-bit signals provides added flexibility when all the 1-bit ports are utilized. xcore-200 devices feature zip and unzip instructions, which facilitate the efficient use of multibit ports as multiple single bit ports. This examples shows how to send and receive four 1-bit streams of data. However, instead of using four 1-bit ports, a single 4-bit port will be used, treating each pin of the port as if it were a 1-bit port. The new zip and unzip instructions of xcore-200 provide enough performance to enable four I2S interfaces at 192 khz sampling rate over 4-bit ports. Required tools and libraries xtimecomposer Tools - Version 14.1.0 Required hardware This application note is designed to run on any XMOS multicore microcontroller or the XMOS simulator. Prerequisites None Copyright 2016 XMOS Ltd. 1 www.xmos.com

1 Overview 1.1 Introduction To transmit data serially on a specific pin of a multibit port, the serial data has to be transformed. Any nibble that is output on a 4-bit port has to be composed of bits from each of the four serial streams. Serial stream 0 is transmitted on bit 0 of the 4-bit-port. Serial stream 1 is transmitted on bit 1 of the 4-bit-port. Serial stream 2 is transmitted on bit 2 of the 4-bit-port. Serial stream 3 is transmitted on bit 3 of the 4-bit-port. See Chapter 6.1 Ports in 1 for more information on I/O Ports The zip instruction can be used to efficiently generate the output data for the multibit port. The unzip instruction is used for the reverse transformation. The example uses the port loopback feature of the xsim simulator to connect the input ports to the output ports and implement a HW loopback test. 1.2 zip/unzip of data The zip and unzip instructions are documented in XMOS XS2 Architecture (ISA) 2. Like closing a zipper, chunks from two words are alternately joined into a 64-bit result by the zip instruction. The size of the chunks (or zipper teeth) can be configured. Like opening a zipper, unzip is the reverse operation taking 64-bit data as an input and producing two unzipped 32-bit results. The zip operation to transform the data from four streaming channels for output on a 4-bit port is illutrated in Figure 1: Figure 1: Zip operations to transform four serial streams for output on a 4-bit port Zipping is done in two stages. Note that the first stage uses a chunk size of one bit. The second stage uses a chunk size of two bits. 1 http://www.xmos.com/published/xmos-programming-guide 2 http://www.xmos.com/published/xs2-isa-specification Copyright 2016 XMOS Ltd. 2 www.xmos.com

Note: To keep the image in Figure 1 readable, the illustration is limited to zipping four bytes. In reality, zip instructions have word operands. The function zip_4_streams_for_4_bit_port transforms four words. This requires a total of four zip instructions. Two for each zip stage: // zip 4 words (streams) of serial data for output on a 4-bit port // word 0 will be output on bit0 of the 4-bit port // word 1 will be output on bit1 of the 4-bit port // word 2 will be output on bit2 of the 4-bit port // word 3 will be output on bit3 of the 4-bit port static inline void zip_4_streams_for_4_bit_port(unsigned int outputs[4]) { unsigned long long tmp64_0, tmp64_1; // zip x, y, s. // zip packs of 1 bit. MSB of x comes first. tmp64_0 = zip(outputs[0], outputs[1], 0); tmp64_1 = zip(outputs[2], outputs[3], 0); outputs[0] = (unsigned int) tmp64_0; outputs[1] = (unsigned int) tmp64_1; outputs[2] = (unsigned int) (tmp64_0 >> 32); outputs[3] = (unsigned int) (tmp64_1 >> 32); // zip packs of two bits! tmp64_0 = zip(outputs[0], outputs[1], 1); tmp64_1 = zip(outputs[2], outputs[3], 1); outputs[0] = (unsigned int) tmp64_0; outputs[1] = (unsigned int) (tmp64_0 >> 32); outputs[2] = (unsigned int) tmp64_1; outputs[3] = (unsigned int) (tmp64_1 >> 32); //MSB from word 0 (original output[0]) is now MSB of outputs[3]! Note: The function unzip_from_4_bit_port_to_4_streams does the reverse operation. Copyright 2016 XMOS Ltd. 3 www.xmos.com

2 Integration with an existing streaming interface The following describes the integration of the zip/unzip functionality with an existing streaming interface like I2S. 2.1 Output: Call the function zip_4_streams_for_4_bit_port to transform 4 words of serial data into 4 words formatted to be output successively on a 4-bit port: // zip output data zip_4_streams_for_4_bit_port(outputs); Note that the most significant data will end up in outputs[3], the least significant data in outputs[0]. So to output the MSBs of the four streams first, outputs[3] has to be output first (bit reversed) to the 4-bit port: // Formats like I2S transmit MSB first. bitrev is needed because port outputs LSB first p_4bit_out <: bitrev(outputs[3]); 2.2 Input: Call the function unzip_from_4_bit_port_to_4_streams to transform 4 words received from a 4-bit port into 4 words of serial data. We assume again a protocol like I2S where the MSB is transmitted first. That means the received data has to be bit reversed: p_4bit_in :> tmp; inputs[3] = bitrev(tmp); When 4 words are received, call the unzip function to transform the data back into 4 words of serial data: // unzip input data unzip_from_4_bit_port_to_4_streams(inputs); Copyright 2016 XMOS Ltd. 4 www.xmos.com

3 Performance The example was tested on the simulator with a port clock (bit clock) of 12.5 MHz. The bitclock of an I2S interface running at 192kHz sampling rate would be 12.288 MHz so this would work. Copyright 2016 XMOS Ltd. 5 www.xmos.com

APPENDIX A - Running the example To make the data loopback work, the: out buffered port:32 p_4bit_out = XS1_PORT_4A; is connected to the: in buffered port:32 p_4bit_in = XS1_PORT_4C; using the port loopback feature of the xsim simulator. After the data is output on XS1_PORT_4A and looped back to XS1_PORT_4C it is unzipped and then checked for correctness. The received data and the test result are printed on the console. The messages should look like this: unzipped input data: 87654321 18765432 21876543 32187654 Loopback data check PASS :) A.1 Launching from the command line From the command line the xsim simulator is launched. The port loopback plugin is activated connecting the XS1_PORT_4A (output) to the XS1_PORT_4C (input). xsim --plugin LoopbackPort.dll '-port tile[0] XS1_PORT_4A 4 0 -port tile[0] XS1_PORT_4C 4 0' AN10129_xCORE_200_using_zip_unzip_with_multibit_ports.xe See 3 for more information about using port looopback with the xsim simulator on the command line. 3 http://www.xmos.com/support/examples/an10098 Copyright 2016 XMOS Ltd. 6 www.xmos.com

A.2 Launching from xtimecomposer Studio From xtimecomposer Studio, create a run or debug application. Click on the.xe file in the bin directory and select Run->Debug Configurations. Double click on xcore Application to create a new Debug Configuration. Click Device options simulator and then click on the Similator tab. To connect the signal loopback, click Enable pin connections and then add. Select from: tile[0] XS1_PORT_4A and then to: tile[0] XS1_PORT_4C as shown here: Figure 2: Debug configurations dialog. Simulator tab showing Signal Loopback connections Click Apply and then Debug. Now you should see the expected console output shown in A. A.3 Waveform Viewer One advantage of A.2 is the Waveform Viewer. It is useful to analyse the signal activity on the 4-bit ports. For futher information on using the Waveform Viewer please consult AN10102 How to enable VCD tracing when running on the simulator 4. 4 https://www.xmos.com/support/examples/an10102 Copyright 2016 XMOS Ltd. 7 www.xmos.com

APPENDIX B - References XMOS Tools User Guide http://www.xmos.com/published/xtimecomposer-user-guide XMOS xcore Programming Guide http://www.xmos.com/published/xmos-programming-guide XMOS XS2 Architecture (ISA) http://www.xmos.com/published/xs2-isa-specification Copyright 2016 XMOS Ltd. 8 www.xmos.com

APPENDIX C - Full source code listing C.1 Source code for main.xc // Copyright (c) 2016, XMOS Ltd, All rights reserved /** xcore-200 devices contain support for zip and unzip instructions, which facilitate the efficient use of multibit ports as multiple single bit ports. This examples shows how to send and receive four 1-bit streams of data. However, instead of using four 1-bit ports, a single 4-bit port will be used, treating each pin of the port as if it were a 1-bit port. Two 4-bit ports are defined, an output and an input port. The output port will be connected to the input port using the loopbacks in the simulation environment. We will use the zip instruction to format the data correctly, then send it to the output port. We will then read it back from the input port and use unzip to recreate the original data. It will then be automatically checked and displayed on the console. **/ #include <xs1.h> #include <stdio.h> #include <xclib.h> out buffered port:32 p_4bit_out = XS1_PORT_4A; in buffered port:32 p_4bit_in = XS1_PORT_4C; out port p_bbit_clock = XS1_PORT_1A; clock bit_clock = XS1_CLKBLK_1; //#define SW_LOOPBACK #define DEBUG_PRINT // zip 4 words (streams) of serial data for output on a 4-bit port // word 0 will be output on bit0 of the 4-bit port // word 1 will be output on bit1 of the 4-bit port // word 2 will be output on bit2 of the 4-bit port // word 3 will be output on bit3 of the 4-bit port static inline void zip_4_streams_for_4_bit_port(unsigned int outputs[4]) { unsigned long long tmp64_0, tmp64_1; // zip x, y, s. // zip packs of 1 bit. MSB of x comes first. tmp64_0 = zip(outputs[0], outputs[1], 0); tmp64_1 = zip(outputs[2], outputs[3], 0); outputs[0] = (unsigned int) tmp64_0; outputs[1] = (unsigned int) tmp64_1; outputs[2] = (unsigned int) (tmp64_0 >> 32); outputs[3] = (unsigned int) (tmp64_1 >> 32); // zip packs of two bits! tmp64_0 = zip(outputs[0], outputs[1], 1); tmp64_1 = zip(outputs[2], outputs[3], 1); outputs[0] = (unsigned int) tmp64_0; outputs[1] = (unsigned int) (tmp64_0 >> 32); outputs[2] = (unsigned int) tmp64_1; outputs[3] = (unsigned int) (tmp64_1 >> 32); //MSB from word 0 (original output[0]) is now MSB of outputs[3]! Copyright 2016 XMOS Ltd. 9 www.xmos.com

// unzip from 4 words received from a 4-bit into 4 words (streams) static inline void unzip_from_4_bit_port_to_4_streams(unsigned int inputs[4]) { unsigned long long tmp64_0, tmp64_1; // make long longs tmp64_0 = (unsigned long long) (inputs[1]) << 32 inputs[0]; tmp64_1 = (unsigned long long) (inputs[3]) << 32 inputs[2]; // unzip into packs of 2 bits {inputs[0], inputs[1] = unzip(tmp64_0, 1); {inputs[2], inputs[3] = unzip(tmp64_1, 1); // make long longs tmp64_0 = (unsigned long long) (inputs[2]) << 32 inputs[0]; tmp64_1 = (unsigned long long) (inputs[3]) << 32 inputs[1]; // unzip into packs of 1 bits {inputs[0], inputs[1] = unzip(tmp64_0, 0); {inputs[2], inputs[3] = unzip(tmp64_1, 0); #pragma unsafe arrays // Disable array range check for better performance int main() { unsigned int outputs[4] = {0x87654321, 0x18765432, 0x21876543, 0x32187654; unsigned int inputs[4]; unsigned expected_data[4]; unsigned int tmp; unsigned int t; // generate expected data expected_data[i] = outputs[i]; // setup clock configure_clock_rate(bit_clock, 100, 8); // 12.5 MHz // Note: This proves that a 12.288 MHz bbit_clock works. That's 4 I2S stereo channels at 192kHz // 25MHz is too fast : configure_clock_rate(bit_clock, 100, 4); // 25 MHz configure_out_port(p_4bit_out, bit_clock, 0); configure_in_port(p_4bit_in, bit_clock); //configure_clock_out start_clock(bit_clock); #ifdef DEBUG_PRINT printf("\noutput data:\n"); printf("%0.8x\n", outputs[i]); #endif // zip output data zip_4_streams_for_4_bit_port(outputs); #ifdef DEBUG_PRINT printf("\nzipped output data:\n"); printf("%0.8x\n", outputs[i]); #endif Copyright 2016 XMOS Ltd. 10 www.xmos.com

// align port timing p_4bit_out <: 0 t; t += 100; // output 0 at t p_4bit_out t <: 0; // To align input with output, set the time of the next input on p_4bit_int. asm volatile("setpt res[%0], %1"::"r"(p_4bit_in),"r"(t+15)); // MSB of channel 0 is MSB of outputs[3]! // See zip_4_streams_for_4_bit_port for details // Formats like I2S transmit MSB first. bitrev is needed because port outputs LSB first p_4bit_out <: bitrev(outputs[3]); p_4bit_in :> tmp; inputs[3] = bitrev(tmp); p_4bit_out <: bitrev(outputs[2]); p_4bit_in :> tmp; inputs[2] = bitrev(tmp); p_4bit_out <: bitrev(outputs[1]); p_4bit_in :> tmp; inputs[1] = bitrev(tmp); p_4bit_out <: bitrev(outputs[0]); p_4bit_in :> tmp; inputs[0] = bitrev(tmp); #ifdef SW_LOOPBACK inputs[i] = outputs[i]; #endif // unzip input data unzip_from_4_bit_port_to_4_streams(inputs); #ifdef DEBUG_PRINT printf("\nunzipped input data:\n"); printf("%0.8x\n", inputs[i]); #endif // check the data unsigned errors=0; if(inputs[i]!= expected_data[i]) { printf("error in input data %d. Expected %x, Received %x\n", i, expected_data[i], inputs[i]); errors++; if(errors==0) { printf("loopback data check PASS :)\n"); else { printf("loopback data check FAIL, %d Errors\n",errors); return 0; Copyright 2016, All Rights Reserved. Xmos Ltd. is the owner or licensee of this design, code, or Information (collectively, the Information ) and is providing it to you AS IS with no warranty of any kind, express or implied and shall have no liability in relation to its use. Xmos Ltd. makes no representation that the Information, or any particular implementation thereof, is or will be free from any claims of infringement and again, shall have no liability in relation to any such claims. Copyright 2016 XMOS Ltd. 11 www.xmos.com