Sending data through the USB port to an FPGA

Discussion in 'Programmer's Corner' started by tstana, May 18, 2009.

  1. tstana

    Thread Starter New Member

    Apr 2, 2009
    1
    0
    Hello!

    I'd like to implement a 16-bit ALU on a Xilinx Spartan-3E FPGA using VHDL. Of course, the VHDL code for this ALU isn't the problem here.

    My problem is that I would like to send the data from a C# or C++ interface in Windows through the USB port and then display the result on the board's LED display (again, the VHDL code isn't a problem). As I'm relatively (read: very) inexperienced in C#/C++ programming, I would like some hints on:
    1. which is better for my project: C# or C++ ?
    2. how can I send data through the USB port to the FPGA?

    Some help would really be appreciated!
     
  2. DonQ

    Active Member

    May 6, 2009
    320
    11
    There should be libraries with the system to let you read/write the USB port. If there isn't, you don't want to be writing it yourself. You will also need to use some sort of driver on the PC side. You could probably use one of the serial-port emulators like those from FTDI (or is it FDTI?). I would bet that there is a tutorial in the manual about doing exactly this type of communication.

    There may also be a USB to "regular" serial converter on whatever development board you are using. Writing a "regular" serial receiver is something that is not too involved.
     
  3. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,794
    Problem is not on the PC side. Isn't the problem on the FPGA side? A USB slave device might just be an FPGA project all by itself. Worse would be having to get the CPU working well enough so you could write the firmware for a USB driver that would enumerate correctly. BTW -- do you have any idea how badly your registry will become polluted by enumerations that don't complete correctly. Fixing the registry manually is kind of a PITA.
     
  4. slight_return

    Member

    Mar 4, 2009
    12
    1
    You should be able to use the System class to bang data through the USB port. On the FPGA end however you'll need to manage the data that's presented to the FPGA. Are you using a USB core on the FPGA side? Is this an FPGA-based "system" and if so, do you have a USB software stack on the FPGA-end? Is there USB hardware on the FPGA side you can use (like the FTDI chip someone mentioned). You might err on the side of simplicity and have a go at using something like the FT232 or some other USB-serial converter to convert USB to serial and serial to USB. That way you can use a UART on the FPGA-end, if you don't require USB functionality on the FPGA side.

    These guys (below) have a hardware board and software that make USB comms really easy. They supply the whole stack including HW, SW, and programmable HW. They also have the full PC-USB-FPGA comms sorted out. They also have a 3E board: www<dot>altium<dot>com Not sure if it'll be useful at this stage in your design but it may be worth a look. Alternatively, I believe Xilinx has a USB controller available and working as a part of the Microblaze developer's kit. (Again, only if you haven't already made accomodation on that end).

    Regarding languages, C++ will be more typed, C# will feel more abstract. Both will get you where you want to go. You should look at the examples on Experts-Exchange and you'll find more code than you know what to do with. It's a paid site but pretty cheap considering. www<dot>experts-exchange<dot>com . You can pick what language you want help with and I trust you'll see what I mean about C++ just being more typed. C# may feel like you're giving up a lot of control but I guess this is the trade-off anytime you go up a notch in terms of abstraction.

    If you're going to debug the USB data on the PC side, you might favor C++ if you know C and have never used C# before. Just my experience. C# was a little goofy getting used to debugging when I didn't know all of the libraries and calls being made the way I did in C++.
     
  5. slight_return

    Member

    Mar 4, 2009
    12
    1
    One thing: I would look at the IO class. I mentioned the System class but I think what you're after is the IO class.

     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,794
    Dead thread resurected! The OP has not been back for a couple of months: another one post wonder.
     
  7. slight_return

    Member

    Mar 4, 2009
    12
    1
    oops, yep. guess I didn't catch the date on that one. just saw it in the list of topics and responded. oh well...at least it's in the archive.
     
Loading...