Skip to content
hdl4fpga edited this page Aug 21, 2024 · 3 revisions

Graphics is a FPGA application designed to showcase the capabilities of the core library by displaying an image stored in the kit's DRAM through the HDMI interface. The image is transmitted to the kit from a computer via one of the communication interface available. Those are Ethernet, UART, or USB. The primary objective of this application is to illustrate the utilization of multiple core components, including but not limited to the DDR controller, DMA, DVI, Ethernet, USB, and UART, in a cohesive and integrated manner.

The documentation of ULX3S kit can be found at ULX3S .The Lattice Diamond project to generate the bitfiles for it can be accessed by following the link here. Prebuilt bitfiles are available below, along with a preformatted raw image sample.

To monitor the SDRAM clock, test points labeled J2 GN27 and GP27 are provided. The labels are indicated on the PCB silkscreen at J2 27. The connector pins associated with these test points are J2:35 and J2:36, respectively. Note that the signal frequency that can be measured on the test points is the DRAM clock divided by two. The kit comes with a builtin USB UART on interface US1.

12F UART Bitfile Raw image
LFE5U12F6C-SDRAM133MHz-UART3MBd-HDMI800x600x32bpp.bit train800x600xrgb32-1280B.raw
LFE5U12F6C-SDRAM166MHz-UART3MBd-HDMI720px32bpp.bit train1280x720xrgb32-1280B.raw
LFE5U12F6C-SDRAM166MHz-UART3MBd-HDMI1080p30x32bpp.bit train1920x1080xrgb32-1280B.raw
LFE5U12F8C-SDRAM200MHz-UART3MBd-HDMI1080p30x32bpp.bit train1920x1080xrgb32-1280B.raw
LFE5U12F8C-SDRAM250MHz-UART3MBd-HDMI1080p30x32bpp.bit train1920x1080xrgb32-1280B.raw
LFE5U12F8C-SDRAM225MHz-UART3MBd-HDMI1440p30x24bpp.bit train2560x1440xrgb24-1280B.raw
12F USB Bitfile Raw image
LFE5U12F8C-SDRAM225MHz-USBFS-HDMI800x600x24bpp.bit train800x600xrgb24-1280B.raw
LFE5U12F8C-SDRAM225MHz-USBFS-HDMI1440p30x24bpp.bit train2560x1440xrgb24-1280B.raw
85F USB Bitfile Raw image
LFE5U85F8C-SDRAM200MHz-USBFS-HDMI800x600x24bpp.bit train800x600xrgb24-1280B.raw

Follow the instruction on https://github.com/emard/ulx3s-bin to upload bitfiles into the kit. For Linux users, a binary version of ujprog can be found at this location. Once the kit is connected to the computer through the USB interface labeled US1, you can proceed with the bitfile upload

  • 12F 800x600 UART 3MBd

    ujprog LFE5U12F6C-SDRAM133MHz-UART3MBd-HDMI800x600x32bpp.bit
    
  • 12F 800x600 USB

    ujprog LFE5U12F8C-SDRAM225MHz-USBFS-HDMI800x600x24bpp.bit
    
  • Download the hdl4fpga repository code and make programs

    • Install libusb if it hasn't been installed on the system
    • Download the hdl4fpga repository code fhttps://github.com/hdl4fpga/hdl4fpga.git
    • Change to the <hdl4fpga repository >/apps directory
    • Run
    make
    
  • UART bitfile

    Set HOST, SPEED and TTY values to upload the image. If the default values are already suitable for your setup, there's no need to change them. Use the export command to set those that are needed. An example to change the serial port value would be:

    export TTY=/dev/ttyUSB0
    
    • HOST : Default value is unset. UART is used instead If it is unset. Hostname of the kit if Ethernet capable device is available.
    • TTY : Default value /dev/ttyUSB0. Serial port device.
    • SPEED : Default value 3MBds. Serial port speed.
    • USBDEV : Default value is unset. USB device

    On directory <repository>/apps, run the following command according to your choice :

    • 12F 800x600 UART 3MBd

      ./scripts/siocomm.sh < train800x600xrgb32-1280B.raw
      
  • USB bitfile

    Connect the second USB interface labeled US2. A USB device with vendorID=1234 and productID=abcd should be listed if the host recognized it. Now, the image can be uploaded following the next command. It is recommended to unplug the US1 USB interface after US2 was plugged

    • 12F 800x600 USB

      USBDEV="1234:abcd.01" ./scripts/siocomm.sh < train800x600xrgb24-1280B.raw
      

The following image should be displayed progressively on the monitor :

./img/app_graphics/train.jpg
  • Download and install Imagemagick

    Imagemagick is required by the scripts to convert your_image.your_format to a WIDTHxHEIGHT RGB888.

  • Set the working directory to ./apps and run according the downloaded bitfile

  • For 800x600 32bpp

    make
    BSIZE=1280 WIDTH=800 PIXEL=rgb32 ./scripts/img2siofmt.sh < your_image.fmt > myimage.raw
    ./scripts/siocomm.sh < myimage.raw
    
  • For 800x600 24bpp

    make
    BSIZE=1280 WIDTH=800 PIXEL=rgb24 ./scripts/img2siofmt.sh < your_image.fmt > myimage.raw
    ./scripts/siocomm.sh < myimage.raw
    
  • scripts/img2siofmt.sh

    It uses Imagemagick to convert an image to raw data format that is required by the application. WIDTH, PIXEL, WSIZE and BSIZE are parameters that can be set. Their default values match to ULX3S. Image is read from standard input and processed data is written to standard output.

    • WIDTH : Image width size. Default value 800
    • PIXEL : Pixel format. values : [ rgb565, rgb32, rgb24 ]. Default value rgb565
    • WSIZE : Memory transfer word size. Default value 16 bits
    • BSIZE : Block transfer size. Default value 1280 Bytes

    Example :

    ./scripts/img2siofmt.sh < your_image.ext > your_data.raw
    
  • scripts/siocomm.sh

    Send formatted data to the kit. HOST, SPEED and TTY can be set as desired. Their default match for serial port. Data is read from standard input and sent to the communication port.

    • HOST : Kit's hostname, if an Internet capable interface is available. If it is unset, serial port will be used instead. Default value is unset.
    • TTY : Serial port device. Default value /dev/ttyUSB0.
    • SPEED : Serial port speed. Default value 3MBds.

    Example :

    ./scripts/siocomm.sh < your_data.raw
    

Follow the instruction on https://github.com/emard/ulx3s-bin to upload bitfiles into the kit. A binary version of ujprog for Windows can be found at https://github.com/emard/ulx3s-bin/tree/master/usb-jtag/win64mingw. Once the kit is connected to the computer through the USB interface labeled US1, you can proceed with the bitfile upload

  • 12F 800x600 UART 3MBd

    ujprog LFE5U12F6C-SDRAM133MHz-UART3MBd-HDMI800x600x32bpp.bit
    
  • 12F 800x600 USB

    ujprog LFE5U12F8C-SDRAM225MHz-USBFS-HDMI800x600x24bpp.bit
    
./img/zadig.png
  • Make programs

    • Change to <hdl4fpga repository>/apps and open a CMD windows there
    • Run
    mingw32-make
    

It is important to open a CMD command line as it is essential to use standard input/output redirect and command pipes

  • UART bitfile

    Set host, speed and tty values to upload the image. If the default values are already suitable for your setup, there's no need to change them. Use the export command to set those that are needed. An example to change the serial port value would be:

    set tty=COM3
    
    • host : Default value is unset. UART is used instead If it is unset. Hostname of the kit if Ethernet capable device is available.
    • tty : Default value COM3. Serial port device.
    • speed : Default value 3MBds. Serial port speed.
    • usbdev : Default value is unset. USB device
  • 12F 800x600 UART 3MBd

    ./scripts/siocomm.bat < train800x600xrgb32-1280B.raw
    
  • USB bitfile

    Connect the second USB interface labeled US2. A USB device with vendorID=1234 and productID=abcd should be listed if the host recognized it. Now, the image can be uploaded following the next command. It is recommended to unplug the US1 USB interface after US2 was plugged

    • 12F 800x600 USB
    set usbdev=1234:abcd.01 & ./scripts/siocomm.bat < train800x600xrgb24-1280B.raw
    

The following image should be displayed progressively on the monitor :

./img/app_graphics/train.jpg
  • Download and install Imagemagick

    Imagemagick is required by the scripts to convert your_image.your_format to a WIDTHxHEIGHT RGB888.

  • Set the working folder to ./apps and run according the downloaded bitfile

  • For 800x600 32bpp

    make
    set bsize=1280 & set width=800 & set pixel=rgb32 & ./scripts/img2siofmt.bat < your_image.fmt > myimage.raw
    ./scripts/siocomm.bat < myimage.raw
    
  • For 800x600 24bpp

    make
    set bsize=1280 & set width=800 & set pixel=rgb24 & ./scripts/img2siofmt.sh < your_image.fmt > myimage.raw
    ./scripts/siocomm.bat < myimage.raw
    
  • scripts/img2siofmt.bat

    It uses Imagemagick to convert an image to raw data format that is required by the application. width, pixel, wsize and bsize are parameters that can be set. Their default values match to ULX3S. Image is read from standard input and processed data is written to standard output

    • width : Image width size. Default value 800
    • pixel : Pixel format. values : [ rgb565, rgb32, rgb24 ]. Default value rgb565
    • wsize : Memory transfer word size. Default value 16 bits
    • bsize : Block transfer size. Default value 1280 Bytes .

    Example :

    ./scripts/img2siofmt.bat < your_image.ext > your_data.raw
    
  • scripts/siocomm.bat

    Send formatted data to the kit. HOST, SPEED and TTY can be set as desired. Their default match for serial port. Data is read from standard input and sent to the communication port.

    • host : kit's hostname, if an internet capable interface is available. if it is unset, serial port will be used instead. default value is unset.
    • tty : serial port device. default value COM3.
    • speed : Serial port speed. Default value 3MBds.

    Example :

    ./scripts/siocomm.bat < your_data.raw
    
Clone this wiki locally