SimH

From Tech Tangents
Revision as of 20:52, 3 March 2025 by Akbkuku (talk | contribs)
Jump to navigation Jump to search

simH is a computer system simulation platform similar to how MAME works. It can be used to run older software or gain more familiarity with the simulated systems.

Compiling - Linux

While some package managers may have simH included, for niche projects like this I will always recommend building directly from the source.

The official directions to compile the software are fairly good. These are the commands I used from the root of the project for compiling on my Ubuntu system:

sh .travis/deps.sh linux
cmake/cmake-builder.sh --flavor unix

Before doing this I had installed cmake and the libvdeplug-dev and libpcre3-dev packages, but I believe the deps script would have handled that had I not.

Usage

Host Level

simH starts as an interactive shell before starting the computer simulation. You can see all available commands with help and exit the shell with the q or quit command. The shell supports tab completion for host filenames and unique shorthands for commands (example, CAT can be run with CA). There are commands for working at the host level available in this shell that mimic the respective UNIX/Linux and DOS/Windows commands. Here are just some of them to give you an idea:

  • ls / DIR
  • cp / COPY
  • pwd
  • cat / TYPE
  • echo

Any command not available in simH's shell natively can be directly run on the host using the ! command prefix. For example ! vim config.simh would open the vim editor with the specified file in the simH shell. Quiting vim returns to the simH shell.

Scripting

There are more advanced logic commands such as IF statements available as well that can be used with a launch script with simH. For built in help with commands like these you can run help if to see more information. You can end the help menu with exit.

To run a script from within the simH shell you can use the DO command followed by the script name, ensure you are in the correct directory on the host to access it.

Here is an example script:

help-dir.simh

help
echo The above are all available commands. The following is your current host path.
pwd

This would be run with do help-dir.simh and will print the built in help, some text, and your current path. The scripting interface can also be programmed to respond to outputs from the simulated machine. Here is an example that automatically respond to a specif prompt:

expect 'Type C to continue' send -t after=10m,'C'; continue

If the simulated machine ever prints "Type C to continue" the expect command will trip and run the send command. The send command will input a "C" to the machine and followed by continue is run to resume execution. The after parameter is used to set a wait time before sending the data to the machine. Responses like this should be setup before the machine is booted.

Scripting is most useful for setting up the configuration for your simulated system. Scripts can be run on startup with simH by simply passing the filename as a parameter. This makes configuring and maintaining simulated systems much easier. As you continue with the configuration commands, keep in mind that you can put them in a script to automate them.

Simulation Configuration

The simulated machine will have a number of virtual devices available to it. The command SHOW FEATURES will output all of the devices for the simulated machine. The SET and ATTATCH commands are used to configure the devices before starting the machine.

Running Simulation

Stop the simulation with Ctrl+E.