verilog modelsim fpga - verilog

Sorry for Newbish question.
I am trying to learn about FPGA programming.
Before I spend $1K on a FPGA board:
if I just want to learn Verilog, can I run it entirely in Modelsim? (I realize there are some timing issues that only show up in actual chips; but for learning syntax / style of coding / ...)_
Thanks!

You can of course!
However, there are a few things that a simulator will let you away with that the FPGA compiler will not. Have a $FAVOURITE_SEARCH_ENGINE around for keywords like verilog coding styles synthesis.
See Resources for learning Verilog for some info on the differences between HDL programming and computer programming.

You most definitely don't need to splashout on a dev board if you are happy with just learning the language and simulating the results.
You can get the free Xilinx ISE Webpack which includes a basic version of ModelSim.
As you have mentioned simulation and testbenching is one aspect of FPGA design. Actually getting a design to work on real hardware is usually the more challenging part. However, just using software you can learn the language, get to grips with simulation and even synthesize your design to make sure it will meet timing and fit on a target device.
I would also suggest that $1K for your first dev board is quite high. I would start with something like the low-cost Xilinx Spartan-6 board, which is a tad under $300. You'll get a device with a decent amount of logic, memory and DSP slices for that.

If you're trying to learn Verilog there's no need to actually get an FPGA board (though, you can get FPGA development boards for much less than $1000 - you can get Xilinx's kit for $100). You can and should first learn Verilog using a simulator, though if you don't want to spend anything I'd suggest Icarus Verilog which is free (Open Source).

We had a hardware systems course in which some FPGA programming was done using VHDL. I downloaded ModelSim-Altera Software (starter edition available here)
We had FPGA boards in our lab, so it was easy to actually see your model behave. In your case, I would suggest:
Start modeling basic circuits like adder, decoders etc. In ModelSim you can also create and configure(characteristics like frequency of different signals) a test bench to verify (using timing diagrams) your model.
Once you are confident with the syntax and modeling, you can look for a lab around you which will allow you to get your hands dirty.
I hope this helps.
cheers

As others have noted, a simulator will get you a long way. There's nothing quite like flashing some real LEDs on and off though - wiggly waveforms on a screen just aren't the same :)
Many of the starter kits have VGA outputs so you can display your own pictures, which is always gratifying (I've found anyway!) $1000 is a lot to spend, try this Xilinx starter kit for $189 (which does have VGA), or this Altera starter kit (which doesn't).

Everyone above is right. However there is a synthesizable subset of Verilog and VDHL that can be used for actual hardware. For example $display can't be used. Recursion may be supported in some tools, as #Chiggs pointed out below. Keep that in mind when writing your code if it will ever be used in a chip. However the full language can be used in test benches.

No one mentioned www.edaplayground.com to learn SystemVerilog and/or VHDL. 100% free versions of the industry standard tools for simulation from the major vendors. Runs in the cloud. Nothing to download. Need email to register. Don't put your employers code up there; its on someone else's computer. There are example designs on the edaplaygroud site itself. Other sites have code examples that run on edaplayground, so you can run their code examples as a learning lesson by clicking one button. A list of verilog examples here: https://verificationguide.com/verilog-examples/
As others have stated there are aspects of FPGA & ASIC design that you will not learn in the simulation flow, specifically those related physical implementation but you can learn a lot from this approach, and it is very low cost (they want your email).
That being said edaplaygroud also has a synthesis tool.

Related

Learning Chisel -- advanced examples to understand Rocket Chip code

The Berkeley implementation of RISC-V is called Rocket Chip and it is written in a hardware language called Chisel. Chisel is object oriented, and it has been difficult for the people on our team to learn to the point of being effective at modifying Rocket Chip code.
There is this Learning Journey that we created for Chisel, which is great. It goes from basics, includes relevant parts of Scala, and ends with a collection of advanced examples taken from Sodor and Rocket Chip code, all with hands-on exercises:
http://learningjourney.intensivate.com
We have opened it up to the community to contribute, but it seems there should be other good places that explain the advanced Chisel coding practices that are used in Rocket Chip code. Does anyone have links?
Somes good documentations links i'm using for Chisel :
Chisel bootcamp
Chisel3 wiki
Chisel3 cheat sheet
And lots of Questions & Answers on Stackoverflow of course.
This tutorial introduces a standalone implementation of the Rocket chip.
https://hardsecurity.github.io/docs/untether-v0.2/
Chisel design Risc-V cpu
https://fatalfeel.blogspot.com/2013/12/chisel-design-ic-for-risc-v.html
XiangShan using rocket-chip core to design risc-v cpu
the link explain the cache, TLB, register file and basic design theory and teach you how to use intellij IDE set breakpoint to debug and use Vivado to see the circuit
Chipyard has decent documentation of Rocket-chip and the Tilelink/Diplomacy package.
It would be best for riscv.org to abandon using Chisel for their designs, as there are relatively few design engineers that use it, or want to use it. Most are using Verilog, System Verilog and VHDL. Using Chisel is building a wall between the majority of design engineers wanting to use Rocket Chip. In other words, use commonly accepted design tools used by the majority of design engineers.

is there a verilog tutorial where you build a very simple microprocessor? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm a programmer wishing to learn verilog.
What would be amazingly neat would be a tutorial where one constructs a tiny microprocessor with a very clean design, something like an Intel 4004, and then goes on to actually make it using an fpga and gets it to flash LEDs to order.
Is there such a tutorial?
If not, I might have a go at writing one as I try to do it. Has anyone got any recommendations as to resources I might draw on? e.g. nice open source verilog compiler, debugging tools, simulators, verilog tutorials, cheap fpgas and programming tools, breadboards for LEDs, etc.
I found some glorious slides about an elementary microprocessor here:
http://www.slideshare.net/n380/elementary-processor-tutorial
The open source tools are good for development/testing but won't be able to synthesise your hdl to produce a bitstream, you'll need to use one of the manufacturers tools from altera or xilinx (or others).
The manufacturers tools come as suites , are large (5GB install and need 7 to 12 GB drive space) available for windows and linux. altera.com xilinx.com
There are plenty of soft cores out there.
opencores.org would be a good place to have a look at
There is the zpuino which is arduino compatible.
Best idea is start simple and build up
Get a fpga board, implement a simple design (led flasher) and work up from there.
Quite a learning curve especially if you haven't done much digital electronics.
Remember its hardware and your designing circuits not writing code
so timing is everything.
Have a look at the fpga4fun.com projects and work through them
as a starting point.
xilinx based
digilentinc has some low cost boards , as does gadget factory.
avnet has a usb dongle based board for $80.
altera based .
terasic has some nice boards.
Gadget factory has a kickstarter project up at the moment for the paillio + a few addon boards http://www.kickstarter.com/projects/13588168/retrocade-synth-one-chiptune-board-to-rule-them-al
You can play with Verilog without an actual board using the GNU Icarus Verilog. You can get a Windows build from here.
There is a also a tutorial by Niklaus Wirth on how to design and build a simple CPU, with code in Verilog for a Xilinx board:
https://www.inf.ethz.ch/personal/wirth/FPGA-relatedWork/RISC.pdf
https://www.inf.ethz.ch/personal/wirth/FPGA-relatedWork/ComputerSystemDesign.pdf
~Yes, it is the same Wirth that invented Pascal -- he is playing with FPGAs in his retirement.
Not sure about an explicit verilog tutorial, but you might find this class interesting from MIT open courseware:
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-004-computation-structures-spring-2009/
All the class notes are online, and the syllabus sounds like it might be what you're interested in (emphasis mine):
6.004 offers an introduction to the engineering of digital systems. Starting with MOS transistors, the course develops a series of
building blocks — logic gates, combinational and sequential circuits,
finite-state machines, computers and finally complete systems. Both
hardware and software mechanisms are explored through a series of
design examples.
6.004 is required material for any EECS undergraduate who wants to understand (and ultimately design) digital systems. A good grasp of
the material is essential for later courses in digital design,
computer architecture and systems. Before taking 6.004, students
should feel comfortable using computers; a rudimentary knowledge of
programming language concepts (6.001) and electrical fundamentals
(6.002) is assumed.
The problem sets and lab exercises are intended to give students
"hands-on" experience in designing digital systems; each student
completes a gate-level design for a reduced instruction set computer
(RISC) processor during the semester. Access to workstations as well
as help from the course staff is provided in the lab but it is
possible to complete the assignments using Athena machines or one's
home computer.
Altera has great resources on this kind of stuff.
You can try out this link:
http://www.altera.com/education/univ/materials/digital_logic/labs/unv-labs.html
There's a series of lab tutorials that goes through making an embedded processor using Verilog/VHDL.
All of the FPGA vendors have inexpensive ($200~250 range) development kits. For example, the SP601 from Xilinx or the Cyclone III Starter from Altera. I personally own an SP605 (~$500) from Xilinx. You may be able to find cheaper options from other options (e.g. Sparkfun).
Strictly speaking, while you can find open source VHDL/Verilog tools, I am not aware of any such tools for synthesis (making something the FPGA will use). Both Xilinx and Altera provide free (as in beer) tooling, but they are not open or free (as in libre) software. The Xilinx tools include a simulator (limited in the free version) and can run on Windows or Linux. I assume the Altera tools are similar, but I am not familiar with them.
Building a simple microprocessor in Verilog/VHDL is a pretty common feature in college computer architecture classes. You can undoubtedly find class notes and the like from pretty much any major school.
There is an excellent open source verilog compiler, Icarus. From the Icarus web page
Icarus Verilog is a Verilog simulation and synthesis tool. It operates as a compiler, compiling source code written in Verilog (IEEE-1364) into some target format.
I am not aware of a microprocessor-in-verilog tutorial, but there is the OpenCores web site. In the Processors tag under Projects, I see many processors implemented in Verilog or VHDL: 8080, 6502, 8051, Z80, 6805, to name a few. I assume one of these would serve you as an example to get you started.

I want to do a project on sound programming, but I don't know where to start

At my high school we can take a class where we basically learn about a subject on our own for a semester. I was thinking that I want to learn about "sound programming," but I realized that I have no idea what that entails. I'm interested in learning about, for example, how a synthesizer works, how I could write a VSTi, and how sound works in computer science. Is this a feasible subject? Are there any good tutorials out there for somebody completely new to this? Any tips or suggestions would be greatly appreciated.
Edit: This is the sort of thing that I'm interested in.
VST plugins are normally written with C++. But it's possible to use other languages as well. Building a VST plugin with C++ is quite an involved project. Without pre-existing experience it's probably too much for a school project. Additionally you'll probably spend as much or more time implementing the VST part and GUI as you will actual sound programming.
However there are a other ways to create a VST plugin and still get your hands dirty writing code.
SynthEdit is a modular environment for creating synthesizers and effects. Modules such as oscillators, envelopes etc are connected visually with wires. Patches can be exported as VST plugins. SynthEdit allows additional modules to be programmed with C++.
SynthMaker is another option similar to SynthEdit. It features a code module which allows you write DSP code without the difficultly of compiling modules in another language.
The advantage of using SynthEdit or SynthMaker in your situation is that you can focus your programming efforts on a particular area, such as creating a filter or oscillator module. SynthEdit/SynthMaker can then handle the other areas (GUI, voice logic, etc).
Using SynthEdit or SynthMaker will also allow you to prototype ideas quicker. So you will have more time to experiment with different synthesizer or effect architectures before settling on something to complete for your school project.
DSP theory can be quite involved and maths heavy but that alone shouldn't put you off. Depending on what you want to do, a basic understanding of digital audio principles and algebra level maths may be enough to take you a surprising long way.
You might try looking for resources on DSP (Digital Signal Processing) and/or Audio Signal Processing. The programming itself (unless you're looking for an existing audio library) will likely be more math intensive than programming intensive, so it might be a good fit for a query at math.stackexchange.com.
There's a very flexible and powerful audio application called Plogue Bidule. You could use it to learn about audio processing and synthesis, by creating your own 'bidules' or groups using low-level math and logic building blocks. There's an existing user community, and I've had a hard time finding a limit to what it can do. You're not going to be doing any code with this tool, but it's great for performance and learning about audio processing and synthesis fundamentals.

Programming VHDL on Linux?

Anyone knows good environment to program VHDL and simulate it (don't matter Xilinx or Altera) using Linux?
You're stuck with either vendors tools, which are spotty at best on Linux (though my experience with Alteras utilities are somewhat better than with ISE).
However, if all you want to do is run your testbed, not actually synthesize anything, ghdl will be of use.
As mentioned by Arpan (almost) every VHDL simulator is supported by Linux, but they are usually very expensive. Your best shot would be to use one of the following:
Altera DS Web edition (Linux support has just been added) which comes with a free version of ModelSim.
Symphony EDA Sonata 3.1 is available as a free version with limited support.
Xilinx ISE which comes with Xilinxs own simulator: ISim.
Just to add an update to this: Xilinx Vivado has now been released with Linux support for ubuntu/debian and (I believe) redhat/centos.
The software is free for a range of the smaller devices and more common IP cores and includes a mostly decent simulator that is integrated into the tools and is also free.
It has a pretty steep learning curve, as do most of these tools, but as far as software in this industry goes, they've really done a good job with it.
If you prefer open source tools, look into http://www.cliftonlabs.com/vhdl/savant.html - vhdl does not have too many options in the FOSS space currently. If you are opting for vendor tools, all vendors would do Linux version of their simulators. Modelsim is a personal favorite due to the easy-to-debug features that it sports.
For a coding environment, I usually use VIM with vhdl syntax checkers turned on. Sigasi apparently has a commercial IDE with fancy stuff as automatic code completion, on the fly syntax check etc.
Let us know if you have further questions.
Arpan
For coding vhdl, Emacs with vhdl-mode is a must. You can use advanced edition functions, view the structure of designs, manage architectures and configurations. You can setup for multiple simulators.
I use the modelsim from Altera's Quartus web edition. Beware if you use a 64 bits Linux, this version of modelsim is 32 bits only.
There is now QUCS (http://qucs.sourceforge.net/) as well. It is open source and based on FreeHDL.
It can be used to design and simulate circuits using a graphical interface. And it can also simulate VHDL. Although for this you must also design the circuit components on the graphical area.
This video shows it clearly:
https://www.youtube.com/watch?v=-RrQlzLsf18
I'm using the linux ppa on Debian Jessie and it works fine.
GHDL is a nice simulator for VHDL, and even works with some third-party libraries (for example, Xilinx UNISIMS).
If you combine it with gtkwave, you should have a full working VHDL simulator and waveform viewer.
GHDL also supports writing to .GHW waveforms, which are fantastic for small simulations, cause it does include (often) all of the signals on your design.
I've used them with standard RTL simulation, and also for post-synthesis simulation with Xilinx UNISIMs.
Both should be available in your Linux distro repository. If not, you can fetch them from:
GHDL: http://ghdl.free.fr/
GtkWave: http://gtkwave.sourceforge.net/

Need some ignition for learning Embedded Systems [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I'm very much interested in building applications for Embedded Devices. I'm in my 3rd year Electrical Engineering and I'm passionate about coding, algorithms, Linux OS, etc. And also by Googling I found out that Linux OS is one of the best OSes for Embedded devices(may be/may not be). I want to work for companies which work on mobile applications. I'm a newbie/naive to this domain & my skills include C/C++ & MySQL. I need help to get started in the domain of Embedded Systems; like how/where to start off, Hardware prerequisites, necessary programming skills, also what kind of Embedded Applications etc. I've heard of ARM, firmware, PIC Micorcontrollers; but I don't know anything & just need proper introduction about them.
P.S: I'm currently reading Bjarne Struotsup's lecture in C++ at Texas A&M University, and one chapter in it describes about Embedded Systems Programming.
I would avoid operating systems all together, Embedded Linux is an oxymoron, what are you really learning? You could learn the same thing with your home computer.
Yes, ARM is the king of embedded and may remain so for a while, eventually you will need to take a look.
Sparkfun.com is a great site, they offer a number of the olimex boards plus others like arduino derivatives. I prefer the msp430 to the avr, but the avr is more popular.
Outside sparkfun look at the ez430 from TI (msp430) direct or from digikey or mouser. Stellaris has a number of nice boards, the 811 is easy to brick, my first one lasted only a few hours, oops, I should have read the 17 warning labels stuck to everything in the box, dont touch the enables or direction on those jtag lines. stellaris packed a ton of stuff on the boards, very good platform for learning embedded programming, reading schematics, reading data sheets and programmers reference manuals, learning that all schematics and reference manuals are a little buggy and you have to hack your way through. If you want something to build your own projects on though you have to cut away (not literally) goodies on the boards, so I would go with an olimex header board for adding your own electronics to.
Back to sparkfun. The olimex header boards are good, sub $50, the various arm vendors are represented (except for ti/stellaris). Arduino pro mini for under $20. The armmite pro is good. Avoid the mbed2 and lpcxpresso, perhaps avoid lpc all together (other than the armmite pro).
qemu is also a good simulator, not as easy as the armulator or my thumbulator to dig into to see what your code is doing. But there are many rtoses and linuxes that run on it (arm and other processors are simulated), the arm integrator eval board is a popular target and is simulated by qemu. Just within arm there are many eval boards emulated by qemu.
The beagleboard is popular but I was quite disappointed with my beagleboard and always innovating netbook. It cost another $100 - $150 to make the beagleboard useful. Embest has a much better beagleboard clone, that is useful out of the box. I like the hawkboard.org much better than the beagleboard, slower by a bit, half the price, but a better board. You can work on linux or true embedded (no operating system) or whatever you like. Being TI omap based there is a dsp on chip as well in case you have some interests there.
I am not a fan of pic, and have been and will get flamed for it, doesnt bother me. I recommend learning assembler for the msp430, avr, arm, thumb (and pic), real embedded always involves a little assembler to manage the boot process, interrupt handling and the like at a minimum. The msp430 and arm are well suited instruction sets for C compilers, pic is horrible as is the 8051, that doesnt mean there arent C compilers, it is just horribly inefficient and adding a high level language makes the result that much worse. The pics are quite resource limited. The pic32 is a mips derivative and not what I am talking/complaining about. That is a whole other family and category of device. I would go with the msp430 over pic given the choice both for assembler and C, size, power, features, etc.
Mips is probaby arms biggest competitor, sadly it is the one platform I have not had the opportunity to learn.
8051, 6501, and the lsi11 used by the pdp11 are a nice trip down history lane. the lsi11 is what the C language was invented on and you can see parallels between the assembler and C. The msp430 instruction set has the same feel, both the msp430 and lsi11 are excellent instruction sets for beginning assembler. The 8051 is probably the oldest surviving workhorse, it had its day as the dominant embedded processor, and can still be found in new chip products. like the pic the instruction set is a tower of hanoi puzzle, in and out of the accumulator, in and out, in and out several instructions to do anything useful. sdcc is a free 8051 C compiler and just the right size if you want to dig into the guts of a compiler and have a chance at understanding it (without having to buy books or take classes).
I am a big fan of the gameboy advance and nintendo ds, the gba is easier, emulators are out there for both, although are geared toward playing rom games and not necessarily perfect at emulation you might do for homebrew development. the gba's other than the mini have serial ports making debug that much easier (mini has one but getting at it is harder). start with the gba if you can, much cheaper, much easier, once you get the hang of the the ds is a couple of gbas tied together with some extra complications.
Based on your post, not knowing if the cost is too much, my guess is the hawkboard (hawkboard.org) is a good choice for linux, embedded, algorithms and other items you listed. Go ahead and get the power supply and the otg usb cable if it doesnt come with it. If you are like I was as an EE student that may be too rich, look at the arduino pro or actually the lillypad because it comes with the pins already, no soldering or extra parts required, yes get the $14 usb to serial thing. For the price of the lillypad and usb to serial/power board you could get a armmite pro and not need anything else other than a usb cable (I know it is a lpc, its okay). I have web pages on how to remove the arduino like firmware from both platforms and get at the processor, not brain surgery, pretty easy, but first timers might hesitate. The ez430 falls into this same price category, you dont need anything else but the $20 kit, three more boards cost you $10 for the set. If that is too rich or even if not the emulators are free some are much easier to debug than running on real hardware as you have the source code and can compile in print statements or whatever. You can get your feet wet without expending anything but time, and see if this is something you are really interested in.
Remember even the best emulator is not like being on the real hardware (same as running your code under a debugger). You may have to start your project over on hardware, but that is the fun of embedded. board bring up...
by Googling I found out that Linux OS
is one of the best OSes for Embedded
devices(may be/may not be)
It gives you a lot of functionality at on the face of it, low cost. However you have to factor in the cost of the hardware needed to run it, when you might otherwise have been able to use lower cost devices, and the huge amount of third-party code over which you have little control. Also it is not suited to hard real-time applications. By using Linux, you will have implicitly imposed a requirement for a 32 bit processor with an MMU (unless you use uClinux and loose memory protection), and several Mb of RAM and non-volatile storage.
Also you'd learn a lot more about embedded systems by not initially targeting Linux, but using an RTOS or real-time kernel such as FreeRTOS, QNX, VxWorks, eCOS, uC/OS-II or III for example, or just programming 'bare metal' without an OS or executive at all.
A good resource for embedded systems articles is http://embedded.com/
Regarding hardware, ARM is the most ubiquitous architecture in embedded systems used everywhere including phones, PDAs, STBs, DAB radios, digital cameras, hand-held games, netbooks, iPad, robotics etc. It is available from many chip-makers, in a wide range of cost/performance and peripherals and on-chip memory. A Cortex-M3 based part would be a good introduction, and is a cleaner design that the older ARM7TDMI core that it essentially replaces. (so long as you don't want to run Linux in which case you'll need at least an ARM9 with external memory).
If board/tool cost is critical, you might rather use an 8bit device, and I suggest something based on Atmel's AVR. These devices are simple, come in an extensive range, and are suited to programming in C (and C++ if you wish). PIC may seem attractive, but it covers a range of largely incompatible architectures (each requiring different tool-chains) and unless you use a high end-device (PIC24/dsPIC for example), they do not present the best platform for programming in C or C++.
Take a look at the Arduino project. It was designed, among other things, as a cheap and easy to program embedded system for students.
I happen to be a fan of the more recent PIC devices, such as PIC24F and dsPIC33F. They are optimized for C, and Microchip has a free compiler available. One thing nice about the PICs is that many of them come in DIP packages, so you can put them on a plastic breadboard and get started with them right away. Inexpensive also. For example, Digikey sells the PIC24FJ16GA002 (16K Flash, 4K RAM, I2C, SPI, UART and parallel port) in a 28-pin DIP package for $3.64.

Resources