[myhdl-list] mu0-0.2: MU0 CPU simulator in MyHDL.
Brought to you by:
jandecaluwe
From: Nick P. <np...@in...> - 2003-10-08 12:30:35
|
As a toy-project, to help me get acquainted with myhdl, I wrote this simple MU0-CPU simulator. From the comments in "mu0.py": # # mu0.py # # MU0-processor simulator in MyHDL # # One of the world's first computers (in the modern sense) was the # Small Scale Experimental Machine (SSEM) built by the University of # Manchester, around 1948. While it was originally built using # valves, and could fill a reasonably sized room, it's gate-count was # relatively low, and its architecture had to be very simple. The SSEM # was also experimental, so it was used as the basis of an evolving # design which later became the Manchester Mark I. # # For more information on the SSEM, take a look at: # # http://www.computer50.org/ # # MU0 is an abstract machine based on SSEM. It is a complete processor # specification and it is quite capable of running useful # programs. Its architecture is so simple that a functioning simulator # can be constructed---by a complete novice like myself---in a couple of # days. So almost 55 years after the original SSEM's inspection, and # as a toy project for improving my skills in Python and MyHDL, I # decided to write this simple model of the legendary machine. I hope # you will enjoy playing with it, as much as I did writing it. # # Tested with python-2.3.1 and myhdl-0.3, on a x86 box running Linux. # # Invocation: # # cp mul.mu0 ram.mu0 # python ./mu0.py # # The simulator expects to find a file called "ram.mu0" in the current # directory, containing mu0 symbolic assembly (see the docstring of # the "load_ram" function for the details of the assembler syntax). # It assembles the contents of the file and initializes the processor # memory. Execution starts at address 0. The accumulator is also # initialized at 0. # # version 0.1, 29 Sep 2003 # - Initial version # # version 0.2, 7 Oct 2003 # - Made RAM latch the address, and drive or read the data-bus # at the falling-edge (negedge) of the clock. Before that RAM was # kind-of combinational. # - Remodeled the CU as a combinational block. # - Added a 'state' internal register, that keeps the current state of # the processor's FSM. 'state' is update by the CU. # - Moved all the MU0-construction code into a 'gen_mu0' function. # - Better 'intbv' use (slicing instead of masks) # - Added a tracer-block that prints the instructions executed when # its debugging control is enabled # - Wrote a unit-testing module for MU0. It is implemented in the # file: "mu0_test.py" # # by Nick Patavalis (np...@in...) # # The "mu0 simulator" is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # Comments regarding its operation, its design, as well as suggestions for possible improvements---in style and functionality---are very welcome. /npat P.S. I don't know if it is ok, or even technically possible, to post messages with attachments to this list; but since it's a rather small file, I'll do it anyway. If it doesn't get through, or if it is against the customs of the list (please drop me a line, let me know) I'll see that any future announcements will only contain URL's to downloadable sources. I'm not doing this know as I don't have a readily-available place where to put publicly-accessible stuff. -- All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can't get them together again, there must be a reason. By all means, do not use a hammer. -- IBM maintenance manual, 1925 |