Showing posts with label Xilinx. Show all posts
Showing posts with label Xilinx. Show all posts

Monday, June 30, 2014

Xilinx Spartan-3 I/O timing

Working on updating the MHZ100Q project, and one significant design issue is I/O delay. To review, the Xilinx Spartan-3A FPGA generates a 100MHz clock using an internal DCM block, and this clock drives an external 100MHz A/D converter. The total delays through the output buffer, A/D clock to output pins, and FPGA input buffer add up to 9 to 16 ns, while the clock cycle time is 10 ns. So aligning the clock and data at the input latch is tricky.
Per the A/D data sheet, the value on the output pins is stable for about 5ns (minimum) and the FPGA data sheet says the latches need about 1ns to capture the value (setup+hold times from the clock edge). So we have a 4 ns window in which everything will work right.
It's hard to measure the actual offset at the internal latch input of the FPGA, so for initial setup I would like to be able to adjust the phasing of the A/D clock relative to the internal latch clock over the full 10 ns range.
First option is to use the built-in delays. The *.ucf file supports the per-pin specifications IFD_DELAY_VALUE and IBUF_DELAY_VALUE which put variable amounts of delay between the input pin and the logic (the former applies when using the latch built-in to the I/O Block, and the latter applies when the I/O Block is just used as a buffer). Total adjustment range is about 2 ns, which might be enough.
Next step up in complexity is to use the Digital Clock Module (DCM) to adjust the phase of the generated clock. The DCM can produce essentially any clock phase, but for this application, I think I can just use the 4-phase quadrature outputs. That gives me effectively 0 2.5, 5, 7.5 ns adjustment points, and combined with the IFD_DELAY_VALUE, I can get within 0.5 ns of any required timing offset.

Friday, March 11, 2011

USB inside an FPGA

I'm working on updating the MHZ100Q project, and for a low-cost USB interface I want to put all of the USB functions inside the FPGA. So externally the interface consists of a connector and 3 resistors - can't get much lower cost than that.
I found 3 open source USB implementations:
1) opencores.org has the usb1_funct and usb_phy Verilog projects, which implement a USB device controller and physical layer (transceiver) respectively.
2) Joris has implemented the USB Communication Device Controller (CDC) protocol in VHDL. CDC devices basically look like an RS232 serial port to the host PC. This one is intended for use with an external PHY chip, and supports both full-speed(12MB/s) and high-speed(480MB/s) operation. Source is available on his website at www.xs4all.nl/~rjoris/fpga/usb.html .
3) Robert E. Jenkins of Johns Hopkins has published the USBF_IFC VHDL core, which includes both controller and PHY functions. It's set up for a XESS board, and is available at www.xess.com/projects/FPGA-USB-V2/readmeusb-v2.php .

Evaluation


I ported all 3 to my custom PCB, and did a brief evaluation.
1) The opencores modules went together easily, and Linux sees the USB device. I didn't implement any data transfers to/from the USB device, but it looks easy to do.
2) I decided to use the Joris controller with the opencores soft PHY instead of an external chip. That limits me to full speed, but saves parts. After a bit of hacking around to get the signals and polarities right, the combination worked great. (Mixing VHDL and Verilog wasn't a problem). His test program gave about 10 megabytes/second transfer rates, which is just about the maximum possible rate for a full-speed device. I've posted my files to demo this combination on my website at www.sensicomm.com/main/downloads/index.shtml (the specific file is 110310cdc_usb.tgz).
3) USBF_IFC took a bit of hacking to get it to run on my board. As stated on the project web page, it was a project for lab classes and still has some quirks.

I've been using USBF_IFC for several months now to test my hardware, but going forward I'm planning to use the Joris core. It's operation seems solid, being able to treat it as a serial device is nice for writing host software, and I can go to high speed if I add an external PHY in the future.

Monday, February 21, 2011

ATLYS HDMI

Followup to my previous post, related to Kaveh's comment. This post describes how I set up HDMI TX and RX.
To test HDMI TX and RX, I loaded the HDMI switch example from Xilinx App Note 495. Loaded Top-level files dvi_demo.v and dvi_demo.ucf into ISE WebPACK, along with all the lower-level modules they require. Everything is in xapp495.zip from Xilinx.
Board configuration:
JP6&JP7 in: link SCL/SDA between TX&RX.
JP11 in: boot from USB stick.
JP5 in: Enable J1 HDMI input.
Connected J2 to display, J3 to source (J1 sometimes works as well).
I load dvi_demo.bit from a USB stick - takes about 30 seconds each time.
Tested with a Samsung TV and DirecTV box and Samsung BluRay.
The LED's show that RX is sync'ing with the signal and the display shows up on the TV. Tried several channels at different resolutions (no 1080p ones available). Sometimes had to unplug and replug the HDMI cables to get things to sync up. Just video, no audio passing through yet for some reason.
So that's my progress so far.

Wednesday, January 12, 2011

Atlys and HDMI on Linux

Xilinx App Note 495 describes sample implementations of DVI/HDMI receiver and transmitter on the Digilent Atlys board. I built the code using WebPACK 12.4, and it works as advertised: The colorbar test pattern displays nicely on my HDMI monitor.

Also installed Digilent's Linux version of their Adept tools for FPGA programming. They don't seem to have the full GUI version available, but the command-line tool was able to load my test code (as a WebPACK-generated .bit file) into the Atlys FPGA with no problem. Don't see any way to load code into the SPI flash: it appears that Windows-based tools are still needed for that.

Only one minor glitch: I use Debian, which isn't one of Digilent's supported distributions. In recent versions of Debian, the udev package doesn't allow plugin devices to have protection mode 0666, which means that the Digilent tools will only work if run as root.
The fix is to edit "/etc/udev/rules.d/52-digilent-usb.rules" and add a group:
SYSFS{idVendor}=="1443", MODE="666" GROUP="plugdev"
then any user in the "plugdev" group can run the Digilent tools. The /etc/group file should have a line like
plugdev:x:46:jr
where "jr" is my username.

Wednesday, December 29, 2010

Digilent Atlys

For Christmas, Santa Claus brought a Digilent Atlys development board for the Xilinx Spartan-6 FPGA's. Nice board, with a bunch of peripherals (Ethernet, USB, audio, HDMI!, etc).
The HDMI interface and protocol is implemented as firmware in the FPGA. My only test so far was to connect an HDMI output to a monitor and power up the board. It generates a test pattern of colored squares right out of the box. Nice. 2011 is going to be interesting.
While setting it up, I also noticed that Digilent now provides tools for Linux programming and communication with their FPGA boards. Need to check those out as well.

Wednesday, April 15, 2009

MHZ100Q - on sourceforge

I can now digitize one signal at 100MHz using my A/D card, capture in the Digilent Xilinx FPGA board, and upload to a PC via the USB port. I'm using Octave to upload and display the data, making a sort of oscilloscope. So I decided it's time to create a sourceforge open-source project.
It's http://mhz100q.sourceforge.net . Code is all in Subversion. It's all there, but I still need to create some build instructions and other documentation.

Monday, March 2, 2009

Cypress CY7C68013A (FX2) USB to FPGA

I just got the USB interface working under Linux for the Digilent Nexys and Nexys 2 FPGA boards. Started with some ideas from the blog at braiden.org , updated the FX2 firmware and added from VHDL test code. Details at www.sensicomm.com/main/projects/fpga/ieee_fpga.shtml#nexys_usb .

Monday, July 21, 2008

FPGA frequency counter code.


An FPGA project that does something useful: implements a frequency counter using the Xilinx Spartan 3AN development board. Basically consists of two counters and the AX8 uC core. The first counter generates a 1 Hz timing signal from the on-board 50 MHz crystal oscillator, and the second counter counts the signal under test. The AX8 core runs a simple program that reads the count value and formats it for display on the LCD.
The attached image is counting the frequency of a VEX RC transmitter using a 75.97 MHz crystal. The measured count is 75.971459 MHz, which is within 0.002% of the expected value. The development board uses an xtal oscillator marked AGXO-751L 50.000 A. I found a datasheet at www.inysa.es indicating that A versions are 100ppm, or 0.01%, so the measured value is well inside the tolerances.
I'll be posting the code when I get it ready.

Friday, May 23, 2008

AX8 core, UART, and uC programming

Progress! I got the AX8 core (a uC based on the Atmel AVR instruction set, available from opencores.org) running on the Xilinx Spartan-3an eval board. It writes to the UART core, and I can see the UART's output on my PC.
Since it takes 7 minutes or more to recompile an FPGA design, I decided to set up data2mem. That's a Xilinx-supplied tool to update just the contents of internal RAM blocks without doing a full recompile. It took quite a bit of searching, but I figured out how to do it, and it works fast.
Details are online at
> www.sensicomm.com/main/projects/fpga/AX8_on_Xilinx.shtml

Saturday, May 3, 2008

fpga uC core

For most things, I'll need a microcomputer core on the FPGA. Xilinx has the Microblaze and Picoblaze synthesizable cores, but I want something that's open-source. That way I can see how things are done and modify as desired.
There are several open cores available. I settled on the AX8 from opencores.org. It's fairly simple, but it implements most of the Atmel AVR instruction set (which I have a lot of experience with). A simple "Hello World" in this core turned out to be pretty straightforward.
After downloading AX8 from opencores, I loaded A90S1200.vhd, AX8.vhd, AX_TC8.vhd, and AX_Port.vhd into ISE WEBPACK. Then I modified A90S1200.vhd to divide the clock down to a lower frequency and to invert the reset line (since the core is set up for an active-low reset and most of the buttons on the board are active-high). I then created a .ucf file to attach port D to the LED's.
The test program just writes to port D to blink the LED's. I assemble the program with tavrasm, then convert the program to a rom vhdl file using the hex2rom program that's included with AX8.
And that's it!. Build in ISE, download to the FPGA, and the LED's blink.
I can post source if anybody's interested.

Thursday, May 1, 2008

VHDL HelloWorld

First step is to write a "Hello World" program. This one just counts cycles of the input clock, and displays a binary count on the LED's. Sample code is included here. hello.vhd implements the counter and connects to the LED's. The ucf file defines the clock and LED connections on the board.These would need to be changed to use anything other than this specific Spartan 3AN development board.
It loads and the lights blink, so now we can do some real work.


-- $Id: hello.vhd,v 1.1 2008/05/01 15:18:18 jrothwei Exp $
-- Joseph Rothweiler, Sensicomm LLC Started 16Apr2008.
-- "Hello world" program. Count down the clock, and display a binary
-- count on the 8 LED's.
------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; -- Common things.
use IEEE.STD_LOGIC_ARITH.ALL; -- Makes the "div+1" instruction work.
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity main is
Port (
CLK_50M : in STD_LOGIC; -- Input: 50 MHz clock.
LED : out STD_LOGIC_VECTOR (7 downto 0)
);
end main;

architecture Behavioral of main is
signal div: STD_LOGIC_VECTOR(29 downto 0);
begin
process(CLK_50M) begin
if rising_edge(CLK_50M) then
div <= div+1; -- Increment counter on every clock.
LED <= div(29 downto 22); -- Display the counter MSB's on the LED's.
end if; end process; end Behavioral;



# $Id: hello_3an.ucf,v 1.1 2008/05/01 15:23:01 jrothwei Exp $
# Joseph Rothweiler Sensicomm LLC started 01may2008.
# Settings for the Xilinx Spartan-3AN development board by Digilent.
# This file just contains the parts I'm using.

#################################################
# Settings specific to this Board.
CONFIG VCCAUX = "3.3" ;
CONFIG ENABLE_SUSPEND = "FILTERED" ;
CONFIG POST_CRC = "DISABLE" ;

#################################################
# The main onboard clock, with the recommended settings.

NET "CLK_50M" LOC = "E12" | IOSTANDARD = LVCMOS33 | PERIOD = 20.000 ;
OFFSET = IN 10.000 VALID 20.000 BEFORE "CLK_50M" ;
OFFSET = OUT 20.000 AFTER "CLK_50M" ;

#################################################
# The row of 8 LED's above the switches.

NET "LED<0>" LOC = "R20" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<1>" LOC = "T19" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<2>" LOC = "U20" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<3>" LOC = "U19" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<4>" LOC = "V19" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<5>" LOC = "V20" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<6>" LOC = "Y22" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;
NET "LED<7>" LOC = "W21" | IOSTANDARD = LVCMOS33 | DRIVE = 8 | SLEW = SLOW ;

Wednesday, April 23, 2008

Starting FPGA project

I've just started working with the Xilinx Spartan-3AN development board. First step was getting the USB interface to work with my Debian 32-bit Linux system. Fortunately, the latest (10.1) version of the Xilinx ISE WebPACK software supports a nice interface using the libusb package. Notes on the system are now on my website, at www.sensicomm.com/main/projects/fpga/ieee_fpga.shtml