element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog XuLA2 FPGA - Test the VGA StickIt! Module: Image Preparation
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 20 Jul 2017 9:09 PM Date Created
  • Views 1094 views
  • Likes 13 likes
  • Comments 4 comments
  • fpga
  • xula
  • vga
  • xess
Related
Recommended

XuLA2 FPGA - Test the VGA StickIt! Module: Image Preparation

Jan Cumps
Jan Cumps
20 Jul 2017

This post is a preparation for my attempt to generate VGA with a XuLA2 FPGA board.

I'm generating an image file that I can upload to the board's SDRAM.

The FPGA will read it from the RAM and convert it into a VGA image.

 

The example project for the VGA plug-in for the XuLA has an example image.

The latest loader tool for the board (xsload 0.1.31) doesn't support the format of that file.

There's an older version of the loader that supports it but doesn't want to run on my pc.

Not to worry. In this post I convert the image to a supported load format: Intel HEX.

 

The XuLA FPGA VGA project and the image file are available on the Xess github:
https://github.com/xesscorp/StickIt/tree/master/modules/Vga/FPGA/PixelVgaTest

 

 

Preparation - Generate Binary Image

 

The example image is in a proprietary format. Below are a few lines as exampe

 

+ 10 00000000 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C
+ 10 00000010 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C
+ 10 00000020 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C 7F 2C

 

10 stands for 0x10 data elements (16 bytes), the second field is the address in ram it has to go, then there's the 16 bytes payload that represent a few pixels of the image.

 

The easiest path from that file to the somewhat elaborate Intel HEX format is to convert this into a binary file that only contains the pixel data.

There are existing utilities that can convert bin to Intel HEX.

 

I made a small c++ utility to grab those pixel bytes from that example and write it to a binary file.

The fixed filenames, not using a data buffer and the way I did the ascii-hex to number conversion show that I'm in a holiday mood.

 

//============================================================================
// Name        : xess_file_converter.cpp
// Author      : Jan Cumps
// Version     :
// Copyright   : copyleft
// Description : Convert XES images to BIN files
//============================================================================


#include <iostream>
#include <fstream>
#include <string>
#include <sstream>


using namespace std;


int main() {


    ifstream inFile("D:\\users\\jancu\\Documents\\elektronica\\xess\\master\\StickIt\\modules\\Vga\\FPGA\\PixelVgaTest\\img_800x600.xes");
    ofstream outFile ("D:\\users\\jancu\\Documents\\elektronica\\xess\\master\\StickIt\\modules\\Vga\\FPGA\\PixelVgaTest\\img_800x600.bin", ios::out | ios::binary | ios::trunc);
    string subs;
    uint32_t uToken = 0U;
    char c;
    uint16_t uVal;

    string line;
    while (getline(inFile, line))
    {
    uToken = 0U;
        istringstream iss(line);
        while (iss >> subs) {
        if (uToken > 2) {
        stringstream ss;


        ss << hex << uppercase << subs;
            ss >> uVal;
            c = uVal;
            outFile.write(&c, 1);
        }
        uToken++;
         }
    }


    outFile.close();
    inFile.close();


return 0;
}

 

The result is a file that has 800 * 600 * 2 bytes. Checked with the file size:

 

image

 

 

Generate Intel HEX File

 

The sourceforge.net srecord project supports converting binary files into Intel HEX format.

 

 

srec_cat img_800x600.bin -binary -o img_800x600.hex -intel

 

The output format generated by the utility is as below:

 

:020000040000FA
:200000007F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C30
:200020007F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C7F2C10
...
:20A5C00000000000000000000000000000000000000000000000000000000000000000007B
:20A5E00000000000000000000000000000000000000000000000000000000000000000005B
:00000001FF

 

 

The xsload utility seems (I can't prove it yet because I don't have a VGA cable) to accept the format and load the file to RAM:

 

xsload  --ram img_800x600.hex

 

output

 

Success: Data in None downloaded to RAM on XuLA2-LX25!

 

 

Success?

 

I will know that once I connect the kit to a TV. I've checked the VGA output on an oscilloscope.

I built and loaded the Xess VHDL example (I'll explain the steps in a future blog) and loaded the bitstream:

 

xsload --fpga pixelvgatest.bit

 

output

 

Success: Bitstream in pixelvgatest.bit downloaded to FPGA on XuLA2-LX25!

 

 

Yellow: HSYNC

Cyan: VSYNC

Magenta: one of the video signals

image

 

image

 

I hope to be able to show a TV screen with image soon. Hang on ...

 

edit: I found a VGA monitor at a curb . Here's the image - only took me a year image.

image

 

 

 

XuLA2 FPGA - First Impressions of the Development Tools
XuLA2 FPGA - SD Card Read and Write
XuLA2 FPGA - Rotary Encoder and VHDL
XuLA2 FPGA - PWM with Dead Band in VHDL
XuLA2 FPGA - Up the Clock
XuLA2 FPGA - Utility to Generate Pin Assignments
XuLA2 FPGA - Test the VGA StickIt! Module: Image Preparation
  • Sign in to reply

Top Comments

  • shabaz
    shabaz over 8 years ago +2
    This is awesome! Looking forward to seeing the video image : )
  • Jan Cumps
    Jan Cumps over 7 years ago +1
    I finally have a VGA monitor. Here's the image. I have some position issues, but there's definitely an image coming out of the FPGA
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to jc2048 +1
    I also suspect it's the monitor. There must be a reason why it's left at the curb. I maxed out both position and clock settings of the monitor. It only helped partly - maybe 10 % more to the left. The…
Parents
  • Jan Cumps
    Jan Cumps over 7 years ago

    I finally have a VGA monitor. Here's the image.

     

    image

     

    I have some position issues, but there's definitely an image coming out of the FPGA

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 7 years ago in reply to Jan Cumps

    Your waveforms look fine.

     

    I'd say it's the monitor that has the 'position issues'. Won't it let you adjust the horizontal position using the menus?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to jc2048

    I also suspect it's the monitor. There must be a reason why it's left at the curb.

    I maxed out both position and clock settings of the monitor. It only helped partly - maybe 10 % more to the left. The monitor will be disposed of now - it served its purpose.

     

    The good news for my FPGA morale is that there is an image. It's like blinking an LED on an Arduino.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to jc2048

    I also suspect it's the monitor. There must be a reason why it's left at the curb.

    I maxed out both position and clock settings of the monitor. It only helped partly - maybe 10 % more to the left. The monitor will be disposed of now - it served its purpose.

     

    The good news for my FPGA morale is that there is an image. It's like blinking an LED on an Arduino.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube