0
\$\begingroup\$

I am reading Digital Design and Computer Architecture book and if I will be persistent then I will have MIPS architecture computer at the end, implemented from scratch by me .

I wonder is it possible to somehow define different components of this computer using Verilog or VHDL or something else maybe and simulate them on a computer? I'd like to build it from most basic blocks like NAND or AND and do one step at a time building each layer of abstraction. Then when I am done with hardware part I'd like to write an operating system for it.

Is it possible to do all of this without buying any real hardware and using only some simulation software?

If so, please, point me to some resources where I can read more about it. Or explain how this can be done.

Thanks in advance.

\$\endgroup\$
1
  • \$\begingroup\$ If you can find Peter Ashenden's "The VHDL Cookbook" online somewhere, it's a bit dated now but that's pretty much what he does - not with MIPS but another simple RISC. \$\endgroup\$
    – user16324
    Commented Apr 16, 2015 at 22:15

3 Answers 3

0
\$\begingroup\$

Of course it is possible to simulate a computer microprocessor using Verilog and VHDL. As Alex said, that's what they are intended for.

Three points:

  1. You won't get far building it out of primitive gates (AND, OR, etc). While it is instructive to learn to build modules such as Adders and Counters at the gate level once you get past that it becomes a grind and you don't learn as much anymore. Modern digital design is done at a higher level of abstraction called the Register Transfer Level. Code written at that level is called RTL. A great place to learn about how to write Verilog RTL is at Asic-World (I use it all the time): asic-world

  2. It's never, ever, ever going to simulate fast enough in RTL for you to write an operating system on it. If you're interested in higher-level abstractions what you should do is write an instruction set simulator in C (not difficult) and you can use THAT to write and operating system.

  3. There are a lot of open-source VHDL and Verilog cores that implement the MIPS instruction set and include source code. You can download them, play around with them, and learn a lot. Here is just one project of many: miniMIPS

\$\endgroup\$
4
  • \$\begingroup\$ Could you tell me more about 2nd approach where I can build instruction set simulator using C? I thought about this, but I didn't know is it possible or not \$\endgroup\$ Commented Apr 17, 2015 at 9:06
  • \$\begingroup\$ It's actually a pretty easy, fun program to write. I wrote one as part of my research in grad school. The idea is you define some unsigned integers for all of your microprocessor registers. Have a big 2-D array for your RAM. Write a function to read in an instruction from a file. Then you have a big case statement that decodes the instruction and updates all your registers and RAM. It's easier than it sounds. You need to learn about how to do bitwise operations in C (it's easy) and read up on doing fixed-point operations (multiply and divide, especially). Have fun! \$\endgroup\$
    – crgrace
    Commented Apr 17, 2015 at 16:15
  • \$\begingroup\$ Thank you. Sounds great, may be you have github repo? \$\endgroup\$ Commented Apr 17, 2015 at 17:47
  • 1
    \$\begingroup\$ Take a look at QEMU, this is more or less what it's designed for. A lot of firmware/OS work has been done using it to simulate, vice working on real hardware. \$\endgroup\$
    – GB - AE7OO
    Commented Jan 1, 2020 at 10:37
0
\$\begingroup\$

Yes, this is most definitely possible. This is what Verilog and VHDL were designed for in the first place. There are multiple open source Verilog and VHDL simulators available, including Icarus Verilog, cver, GHDL, and probably quite a few more. You may need to install a waveform viewer such as gtkwave as well to look at the simulation traces.

Most of the FPGA toolchains will also include a free simulator as well. Xilinx ISE comes bundled with isim and can be downloaded for free, though you pay for it in hard drive space (~10 GB). I believe their newer Vivado environment is similar in both bundled features and hard drive footprint, though I'm not familiar with it as I use mainly Xilinx 6 series devices which require ISE. Altera's Quartus software includes a free version of Modelsim and can also be downloaded for free, but it's also about 10 GB. The open source simulators are three orders of magnitude smaller (~10 MB).

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

Or, Just use Logisim, a GPL logic simulator. Its not hard to build simple processors in Logisim once you get the hang of it. Very cool software.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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