9
\$\begingroup\$

I'm new to FPGA and currently taking HDL (Verilog particularly) class. I have sufficient knowledge in digital design like combinational and sequential circuits.

I want to create a project similar to the one shown in this YouTube video.

I also know that Xilinx ISE can process logic signals and simulate waveforms. Does it have extra capability like getting the input signals via USB, camera etc. and output it in your computer.

Is it possible to run this project (like a simulation in computer) without buying an actual FPGA board? What I mean is, can I build, code and run that project in my computer, and just hook up my camera via USB, then let the incoming video signals be processed by HDL simulators like Xilinx ISE, etc. (w/o really buying an FPGA board and synthesize your project there, I currently do not have the budget to have one)

(What I really mean is to interface the HDLl design into real world sources, C code, etc.)

\$\endgroup\$
  • 5
    \$\begingroup\$ I don't know if you can do that with Xilinx's simulator, but something like Icarus Verilog will let your simluation interface to C code which could obtain data from real world sources; however it is likely to run orders of magnitude slower than real-time, so processing a live video source would be difficult. \$\endgroup\$ – Chris Stratton Feb 6 '13 at 1:25
  • 1
    \$\begingroup\$ oh there, thats the phrase im finding, interfacing to real world sources \$\endgroup\$ – WantIt Feb 6 '13 at 1:35
  • 2
    \$\begingroup\$ @vvavepacket upvote the comments / posts to thank the commenter / poster. \$\endgroup\$ – Chetan Bhargava Feb 6 '13 at 6:18
  • 1
    \$\begingroup\$ The FPGA in the video looks like Altera DE2. It's between 200 and 600 USD depending on license and chip. There're simulators at csc.kth.se/~emille/niisim \$\endgroup\$ – Niklas Feb 6 '13 at 7:08
  • 2
    \$\begingroup\$ The Terasic DE0-nano is on the order of $80 and can interface to cameras and LCDs; in fact they have demos of that on their website. Not affiliated with them, but the DE0-nano's got a pretty nice little FPGA on a decently-priced board. I've always hated how expensive most dev boards are. \$\endgroup\$ – akohlsmith Feb 6 '13 at 13:27
5
\$\begingroup\$

The Xilinx tools can't interface in real-time as far as I know, neither can ModelSim (used by Actel's Libero IDE)
I don't know about open source simulators, there are some rather exotic projects out there so it's possible there is something that could do this.

However, this may be you an answer you didn't ask for (I'll delete it if it's not helpful), but I would consider building your own FPGA board to do this or at least get started along the way towards it. I etched my first FPGA board and though it was very simple (the board not the process ;-) ), it taught me an awful lot quite quickly.

Pros:

  • Cheap
  • Jump right in at the deep end and learn all you need to know about the hardware considerations. Forces you to read most of the datasheets first, and write your own starter code, which IMHO is often better than the plug and play dev board approach to learning.
  • Only put on the board what you need to.
  • Get's you further towards your goal of a real working design with possibly the same effort/research as the figuring out how to simulate it all in real-time would.

Cons:

  • Still need to buy a programmer, although cheap versions of the Xilinx/Altera programmers can be found on eBay.
  • If PCB/signal integrity design and issues are not something you wish to focus on, then you may not be interested in much of the knowledge to be gained by doing it this way.

I understand the etching your own board is probably unnecessary, I only did it because I had the FPGAs there, was impatient and didn't want to wait 2 weeks for a PCB to arrive. There are extremely cheap deals out here for 2-layer boards, which would do to at least run your design (possibly at lower speeds than eventually desired - normally the minimum layer count for a high-speed FPGA design would be 4, but these are much more expensive)

Anyway, Spirit Circuits does a completely free 2-layer "bare bones" PCB deal (one a month, one design, no mask or silkscreen) which comes in handy for a one off design.
Also, for proper 2 and 4 layer cheap prototype boards, ITead and Seed Studio go as low as $10 for 10 boards (or possibly 5 at that price) services.

\$\endgroup\$
  • \$\begingroup\$ very interesting take on this! and encouraging also \$\endgroup\$ – davidbak Jul 16 '19 at 23:10
6
\$\begingroup\$

The standard Xilinx ISE Webpack (the free version that you can download from xilinx.com) includes a simulator called iSim. It's not a great simulator, but is fully functional and the price is right.

Although I haven't used the Altera tools, it would surprise me if a simulator was not included.

But... You need to know what a simulator can and cannot do. For starters, it cannot simulate an FPGA running at full speed. In fact, they are quite slow. Depending on the complexity of the FPGA being simulated, it would not surprise me to see it take 1 minute to simulate 1 ms of "simulated time". If you want to simulate an hour of "simulated time", it would require 1000 hour of real time.

Also, a simulated FPGA cannot communicate directly with things like your USB port. The simulated FPGA does communicate with a "testbench". The testbench is a chunk of VHDL or Verilog code that feeds the inputs of the FPGA (or parts of the FPGA) and verifies the output of your FPGA. You can do some fairly complex things in a testbench, like use floating point numbers, read and write files, and run logic that is impossible to synthesize.

\$\endgroup\$
  • 1
    \$\begingroup\$ Altera's got free editions of Quartus which include ModelSim. The free version of ModelSim limits your simulation speed, and the free version of Quartus limits the number of CPU cores used to synthesize, but are otherwise fully-functional. \$\endgroup\$ – akohlsmith Feb 6 '13 at 13:28
  • 1
    \$\begingroup\$ Altera ModelSim does not support co-simulation of VHDL and Verilog in the same design. \$\endgroup\$ – shuckc Feb 7 '13 at 14:32
3
\$\begingroup\$

I don't know of any simulator that will directly interface to signals arriving on a USB port (or other hardware).

At least in theory, it would be possible to write some software that would take signals arriving on a port, and translate those into a testbench file that a simulator could process. Unfortunately, I don't know of any existing software to do this, and writing it yourself would be decidedly non-trivial.

\$\endgroup\$
  • \$\begingroup\$ then best way is to get an entry level, low cost fpga board for n00bs like me \$\endgroup\$ – WantIt Feb 6 '13 at 11:43
  • \$\begingroup\$ You don't actually have to go through a testbench file if you have a simulator which supports an interface to custom code such a VPI, however, given that the simulator will run orders of magnitude slower than real time, it may be easier to deal with captured data in a file that can be read at the speed of the simulation. \$\endgroup\$ – Chris Stratton Feb 6 '13 at 17:03
  • \$\begingroup\$ @ChrisStratton Im interested in idea of captured data in a file. Any resources for that? Thanks \$\endgroup\$ – WantIt Feb 7 '13 at 12:56
  • \$\begingroup\$ It would entirely depend on the peripherals you want to use as data sources. \$\endgroup\$ – Chris Stratton Feb 7 '13 at 13:42
3
\$\begingroup\$

You'll need to use a co-simulation interfaces (DPI, VPI, VHPI, FLI) which allows you to write code that hooks into the simulator and thus bridge between the RTL running in simulation and real hardware on your machine.

The significant problems you'll encounter (apart from poorly documented interfaces) are synchronisation and timing related. RTL running in simulation is far slower than real hardware - you'll need to be able step through interactions with the external interface to match the simulation speed. Some hardware interfaces won't like this! For example if using TCP you might have to fudge the timers in the kernel stack to avoid spurious retransmissions etc.

Icarus supports the VPI and is free so you can experiment without spending any money on licenses. You might want to look into existing frameworks that do some of the co-simulation heavy lifting and provide a cleaner abstraction to the simulator. One such framework is Cocotb, an open-source library which provides a Python interface to the simulator. (Disclaimer: I'm one of the developers of cocotb.)

An example that may be relevant: yesterday I knocked up some RTL to respond to ping requests and created a testbench that opens a TUN interface. You can then ping the interface using the ping command and the RTL running in simulation receives the ping and responds. The entire testbench is less than 50 lines of Python! The source code for this example is on Github and it runs on Icarus under Linux.

\$\endgroup\$
0
\$\begingroup\$

In the vast majority of cases, anything you do in the simulation stays in the simulation. You can't access real hardware from it - you have to have a simulation model of the real hardware.

However, if you are willing to put some effort, most simulators have an interface to arbitrary code. In Verilog it's a fairly standard interface as I understand it, so the Verilog side of things will port between simulators. In VHDL-land, there is a standard way of doing it but at least one of the big vendors has their own way of doing it!

Also bear in mind that interfacing in real-time (ie at the rate the FPGA would do it) is very unlikely - and the rest of your simulation (the HDL) will not run in real-time either. As noted in the comments, real-time simulated processing of video is not feasible in this fashion.

Personally, I've never had a need to try this, I find I'm more productive writing models of the hardware and running all in VHDL.

But, don't overlook the benefits of doing simulation - it's a much quicker way to find if things are working (compiles take seconds) then building bitstreams (compiles take tens of minutes to hours) and trying them in hardware.

\$\endgroup\$
  • \$\begingroup\$ Untrue, see comments to the question. \$\endgroup\$ – Chris Stratton Feb 6 '13 at 15:17
  • \$\begingroup\$ OK, I should've been clearer - I was limiting my answer to the "I'm new to FPGA" level :) Answer updated \$\endgroup\$ – Martin Thompson Feb 7 '13 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.