-
xCORE-200 eXplorerKIT
03/03/2017 at 02:01 • 0 commentsReceived my xCORE-200 eXplorerKIT today. At some point in the near future I'll probably need it to for more RAM space, if nothing else. Compared to the XS-1 StartKit:
- 256k RAM per tile, 512k total, vs. 64k available on the StartKit
- 2 available tiles with 5 fully-clocked cores each, compared to 1 tile with 4 fully-clocked cores on the StartKit
- 16 total logical cores vs 8 total logical cores on the StartKit
- Dual-issue pipeline should almost double MIPS per core
- Additional 64-bit and DSP-oriented instructions
So all in all, I should be looking at a 5x performance speedup, anyway. The extra RAM will definitely be useful. Also there's GbE on board, for networking options, and USB. Maybe I'll code support for USB keyboard and mouse. I'm hoping I can attach a hub, since there's only one USB link (the other USB port is for power only).
A number of I/O pins are taken up by GbE and the on-board xSYS header. Hopefully I can figure out a way to get 24 parallel bits out to the video DAC. -
Alpha-blending optimization
03/03/2017 at 01:53 • 0 commentsSpent some time last night coding a circle-drawing "Rect" with anti-aliased edges. Rolled in a super fast LUT-based integer square root method, and optimized the daylights out of the Pixel::Blend() code. I now have a 64-bit wide calculation in there that handles all three color channels in single vector operations. Should be even faster on XS-200, which has some native 64-bit math. Even so, the 64-bit variant outperformed by best 32-bit incarnation on XS-1 by a small margin.
-
Getting Started
02/26/2017 at 22:12 • 0 commentsDocumentation is an ongoing process...
Right now I have the XMOS StartKit connected to a separate PCB which houses a 24-bit RGB DAC, NTSC/PAL Video Encoder chip, misc. support components, and VGA, S-Video, and Composite Video output connectors.Source Code
Source code is released under the GPL, can can be found at https://bitbucket.org/kpatterson/anacon-xc/
Project Layout
If you want to familiarize yourself with the code, I suggest taking a look at the header files first, starting at the top of the Repo.
The project is written in two main languages. xC exposes the hardware-level parallelism and event-driven nature of the xCore microcontroller in a simple way, so most I/O and timing routines are written in xC. However, C++ is my preferred language and eases the development of object-oriented hierarchies. Most of the code that does not require xC is written in C++. In particular, the graphics engine uses a "render list" of objects derived from a basic Rect class. xC and C++ don't mix in the same compilation unit, so "plain C" interfaces are used when calls need to be made back and forth. These "bridge" interfaces are typically encapsulated in ".h" header files.
Some file naming conventions:
- .h - "Standard C" header file, for inclusion anywhere needed
- .xc.h - xC header file. May use xC language-specific features, and should only be included in .xc source files.
- .hpp - C++ header file. May use C++ language-specific features, and should only be included in .cpp source files.
- .xc - xC source file
- .cpp - C++ source file
Hardware
Right now the project runs on an XMOS "StartKit" development board, which is only about $15. The StartKit features an XS-1 device with a single xCore tile available for use, supporting up to 8 hardware threads on 4 logical cores. The scanline rendering loop can run in multiple threads simultaneously, depending on how much performance you need. Right now I am using 2 threads, but any number from 1 to 4 (or more) should work if you monkey around with the code properly. Contact me for details on that until I get it better documented.
I'm pushing the pixels out of a 32-bit port, but the StartKit board does not expose all the pins. In particular, bits 20-27 of that port are not exposed on headers, so I have opted to output the RGB data on the lower 18 bits only, using 6 bits for each color. Full 24-bit data is generated internally and then "packed" using the PackPixel and PackPixels methods in src/Grafx/Screen.cpp. The code is these methods can be altered for different output.
I'm using an Exar CDK3404CTQ48 24-bit RGB DAC and Analog Devices AD724JRZ NSTC/PAL Video encoder. Support circuitry for these chips can be found in their datasheets, but I will probably be making some kind of board available in the future.
Pin Mappings
StartKit pin mappings for video output can be found at the top of the src/VideoOut.xc file. Video timing parameters (based on an internal 100 MHz clock) are currently set for interlaced NTSC (TV) video output, and can be found in the VideoOutInit() function at the bottom of the same file. PAL support should work with the right timing parameters, but has not been tested yet. The basic requirements for VGA output are there but it is not yet ready to be tested.
StartKit pin mappings for PS/2 input are around line 64 of src/UserInput/PS2/PS2.xc. Any number of PS/2 ports can be handled, but I have only mapped pins for two. I am using 4 pins per port (separate pins for input and output). You'll need an interface circuit between the StartKit and your PS/2 device(s). Figure 1 on this page will give you an idea. Keep in mind that the XS-1 chip on the StartKit does not have 5V-tolerant inputs, so you'll need to handle level conversion properly. Also, I'm using inverting logic in my interface circuit. There's a #define in src/Globals.h where you can change that. You can also change the number of PS/2 ports there.