Learning Chisel -- advanced examples to understand Rocket Chip code - riscv

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.

Related

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.

Platform for creating a visual programming language

I'm interested in creating a visual programming language which can aid non-programmers(like children) to write simple programs, much like Labview or Simulink allows engineers to connect functional blocks together without the knowledge of how they are internally built. Is this called programming by demonstration? What are example applications?
What would be an ideal platform which can allow me to do this(it can be a desktop or a web app)
Check out Google Blockly. Blockly allows a developer to create their own blocks, translations (generators) to virtually any programming language (or even JSON/XML) and includes a graphical interface to allow end users to create their own programs.
Brief summary:
Blockly was influenced by App Inventor, which itself was based off Scratch
App Inventor now uses Blockly (?!)
So does the BBC microbit
Blockly itself runs in a browser (typically) using javascript
Focused on (visual) language developers
language independent blocks and generators
includes a Block Factory - which allows visual programming to create new Blocks (?!) - I didn't find this useful myself...except for understanding
includes generators to map blocks to javascript/python
e.g. These blocks:
Generated this code:
See https://developers.google.com/blockly/about/showcase for more details
Best wishes - Andy
The adventure on which you are about to embark is the design and implementation of a visual programming language. I don't know of any good textbooks in this area, but there are an IEEE conference and refereed journal devoted to this field. Margaret Burnett of Oregon State University, who is a highly regarded authority, has assembled a bibliography on visual programming languages; I suggest you start there.
You might consider writing to Professor Burnett for advice. If you do, I hope you will report the results back here.
There is Scratch written by MIT which is much like what you are looking for.
http://scratch.mit.edu/
A restricted form of programming is dataflow (aka. flow-based) programming, where the application is built from components by connecting their ports. Depending on the platform and purpose, the components are simple (like a path selector) or complex (like an image transformator). There are several dataflow systems (just I've made two), some of them has no visual editor, some of them are just a part of a bigger system, and there're some which don't even mention the approach. (Did you think, that make, MS-Excel and Unix Shell pipes are some kind of this?)
All modern digital synths based on dataflow approach, there's an amazing visual example: http://www.youtube.com/watch?v=0h-RhyopUmc
AFAIK, there's no dataflow system for definitly educational purposes. For more information, you should check this site: http://flowbased.org/start
There is a new open source library out there: TUM.CMS.VPLControl. Get it here. This library may serve as a basis for your purposes.
There is Snap written by UC Berkeley. It is another option to understand VPL.
Pay attention on CoSpaces Edu. It is an online platform that enables the creation of virtual worlds and learning experiences whilst providing a more flexible approach to the learning curriculum.
There is visual coding named "CoBlocks".
Learners can animate and code their creations with "CoBlocks" before exploring and sharing them in mobile VR.
Also It is possible to use JavaScript or TypeScript.
If you want to go ahead with this, the platform that I suggest is the one used to implement Scratch (which already does what you want, IMHO), which is Squeak Smalltalk. The Squeak environment was designed with visual programming explicitly in mind. It's free, and Smalltalk syntax can learned in half an hour. Learning the gigantic class library may take just a little longer.
The blocks editor which was most support and development for microbit is microsoft makecode
Scratch is a horrible language to teach programming (i'm biased, but check out Pipes Visual Programming Language)
What you seem to want to do sounds a lot like Functional Block programming (as in functional block programming language IEC 61499 and other VPLs for mechatronics development). There is already a lot of research into VPLs so you might want to make sure that A) what your are trying to do has an audience and B) what you are trying to do can be done easily.
It sounds a bit negative in tone, but a good place to start to test the plausibility of your idea is by reading Davor Babic's short blog post at http://blog.davor.se/blog/2012/09/09/Visual-programming/
As far as what platform to use - you could use pretty much anything, just make sure it has good graphic libraries (You could use Java with Swing - if you like pain - or Python with TKinter) just depends what you are familiar with. Just keep in mind who you want to eventually launch the language to (if its iOS, then look at using Objective-C, etc.)

verilog modelsim fpga

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.

Prerequisite for learning directx

I am from .net C# background and I want to learn DirectX. I have knowledge of C++ but I am fairly new to graphic world.
I am little confused about how to start learning directx, should I start learning direct directly or buy a basic graphic book like hern and baker and then jump to directx.
Which is the recommended book for learning basic graphic concepts, is it hern and baker? Is there any directx book which will cover graphic concepts as well?
I think that keeping a basic graphics book is allways good, because i can use it as reference anytime
Any suggestions from experts here?
You say that you have a C# background so I am going to assume you are more comfortable with C# then C++. Also, you say that you have knowledge of C++ so I will assume that you already have an understanding of memory management.
If you just want to learn and become more comfortable with the graphics pipeline you should check out SlimDX and XNA. They both allow you to use DirectX without having to dive into C/C++.
As for whether to learn the theory or API first I don't think you should do either one first. It makes sense to learn them asynchronously. Pick up a book on the theory but mess around with an API at the same time.
I highly recommend XNA. People commonly say that you should stick with C++ if you want to develop games but I strongly disagree. XNA will allow you to learn more high level game concepts in less time than if you use C++ and DirectX alone. You will be able to focus on learning why you are doing something rather than how to manage the memory. If in the future you decide that game development is a serious passion then by all means C++ is the way to go. You will find that XNA's graphics pipeline closely mirrors DirectX 9 and wont have much trouble moving to C++.
Also, DirectX 9 should be good enough for any beginner and it will give you a better understanding of how and why things have changed in 10 and 11. However, if you really want bleeding edge technologies you can try out SlimDX which is a C# wrapper for DirectX.
With all this said, XNA offers many easy to understand samples that you can start playing with on their educational catalog page. Also, check out ziggyware (great collection of xna tutorials).
Also, there are many blogs you can check out. A lot of them have excellent tutorials on them. Here are some off the top of my head:
Reimer Grootjans
Shawn Hargreaves
Richard Dodsworth
Renaud Bédard
Nick Gravelyn
Finally, here are 2 graphics books that I highly recommend (they are pretty complex and will last you a long time):
Fundamentals of Computer
Graphics
Real-Time Rendering
They are not directly related to DirectX, but rather they cover the theory every graphics developer should know. (from linear algebra to texture mapping to volumetrix rendering...)
Well I have to disagree with the C# option. If you don't have a deadline to finish the game, then I recommend using the language that teach you most. Working with 3d graphics is A LOT about management so if you are avoding it you are not actually learning but just using it, ie. you not only have to manage memory but the actual render calls you make and the device state changes, a lot of things that you will never know by avoding lower level, and which applies for other APIs too such as OpenGL or for other kind of devices. I think the best way of knowing how the api works is by using the api, instead of a bunch of helper libraries. You can use the helper libraries when you really need it instead (which you can find in their C++ version anyway).
In the DX SDK you can also find the Sample Browser with some sample applications with their documentation and you have the DirectX Utility Toolkit which contains a framework and libraries to make a DirectX app without having to worry much about the nasty device things such as enumeration and config. It also comes with a GUI system and a settings dialog for the device config. I doubt you can find those in C# and they are very good if you want to start with DX.
Some resources that helped me when I started were
the zophusX tutorials
and a book called "Introduction to 3D Game Programming with DirectX 9.0c", by Frank D. Luna (there is the DX10 version now)
and probably the book 3d Game Engine Programming by Stephan Zerbst also helped me to understand some things about how to work better with the apis. Though you may have to buy them in order to read them. They are helpful to start with both some theory and using the API at the same time.
I think if your target is to learn how to make a game then you can use any language/library you want you don't even need to know a programming language :) but if your target is learning DirectX and graphics APIs you should definitively start with the C++ api which is the "actual" DX.
If you have a bit of extra money, I was very impressed with the DirectX graphics courses from http://www.gameinstitute.com. The textbook they provide was very good as far as the other DirectX books I've seen are concerned. The first module DirectX Graphics I starts off with a bit of a math review and some 3D fundamentals before diving into setting up and using DirectX. By the end of the first module you will have built a textured terrain renderer and an indoor scene.
Overall the courses are not that expensive when you consider how much books on the subject cost. I would definitely recommend checking it out!

What is the best way to learn x86 assembly on a Linux platform? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have no prior knowledge of assembly programming, and would like to learn how to code x86 assembly on a Linux platform. However, I'm having a hard time finding a good resource to teach myself with.
The Art of Assembly book looks good, but it teaches HLA. I'm not interested in having to learn one way, then relearning it all over again. It also seems like RISC architectures have better resources for assembly, but unfortunately I do not have a RISC processor to learn with. Does anyone have any suggestions?
http://asm.sf.net has some material on architectures besides x86.
If you are interested in RISC architectures, you could run Linux on Qemu. Qemu emulates several RISC architectures like PowerPC, ARM and MIPS. You might be able to find a ready to use Qemu hard disk image here.
Another way to experiment with RISC architectures would be to use gdb's built-in simulator.
I found Assembly language step-by-step to be a very good resource. It has a section in the back thats aimed at Linux assembly too.
Probably nothing much better than The Art of Assembly Language Programming and the other resources at that web site.
There are really two parts to learning assembly-level programming: the basic concepts, and then specific architectures. If you haven't had any exposure to asm programming, I strongly suggest you get the basics down first with a simple, small architecture, even tho' it likely is not directly applicable to any real hardware. If many folks are pointing to a particular resource like "The Art of...", take another look at it, use it to learn what an architecture is, how to use the basic tools (asm, debugger, disasm, etc).
Once those are out of the way, then you can start looking into more advanced instruction sets. The x86 architecture and instruction set are pretty convoluted and there are many obscure ways to twist your brain - learn something simple before you tackle that.
Even though many people I know at school hated this book, I will link it anyway:
http://www.amazon.com/Professional-Assembly-Language-Programmer/dp/0764579010
The main reason I used this book is because it uses x86 on Linux with the GNU assembler. That last point helped since I had to use that assembler in our school's lab, and if you aren't aware - the syntax is different from Intel syntax.
Also, I would just add that learning how high level languages are compiled into assembly language really helped me move along.
x86 assembly is really an intel language, best learnt with an intel chip and a windows platform which does DOS
If you have something like WinXP there used to be a DOS interpreter which showed a user the basics of asm and allowed a user to reverse a command and tweak the code in real time, then assemble the code into a block which could be run on the interpreter
It was called the "Ketman Interpreter"
It was for DOS asm only but it was pretty unique because it let you see what happens with all the registers and flags and allows a totally clueless individual to get a handle on the logic
Try http://www.emu8086.com which is a windows-hosted 8086 emulator with an assembler and debugger. It comes with a tutorial.
I learned x86 assembler from a book about the 8086 (which I can't remember the name of at present... it was obviously quite old, and purple. if you're really interested I can dig it up when I get home). That will only teach you 16 bit stuff, for the more advanced 32 bit stuff I read some tutorials online. I've never done 64 bit. At least at first, the OS you're targeting probably won't matter, as you're too low-level... the BIOS is all you really care about. If you don't have access to a test system, an emulator is probably a good choice, as others have mentioned, but you can also build yourself an 8088 or 8086 without too much trouble from discrete parts. You can find tutorials and circuit diagrams online easily. It should cost less than $50 and it's a great learning experience -- you're essentially building a motherboard from scratch.
If you're not too attached to x86 assembly and want to learn RISC, I recommend the Microchip PIC microcontrollers. You can pick up a starter kit for less than $50 (the PICKit 1, which I have, even works under Linux). They have extensive documentation and plenty of third-party tutorials aimed at hobbyists.
don't forget to grab a copy of Guide-Assembly-Language-Programming-in-Linux book.
The Art of Assembly Language Programming

Resources