Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

VirtualMachine

Guides

  • Virtual Machine Package

Symbols

  • VirtualMachineAdd
  • VirtualMachineDefinition
  • VirtualMachineExecute
  • VirtualMachineList
  • VirtualMachine
  • VirtualMachineObject
  • VirtualMachineObjectQ
  • $VirtualMachines

Other

  • Intel4004
  • MOS6502
  • NFA
  • PDP1
  • PDP8
  • RegisterMachine
"Intel4004"
​
"Intel4004" an emulator of Intel's 4004 (MCS-4) computer architecture.
​
▪
Creating a virtual machine instance:
VirtualMachine
["Intel4004"]
create a new instance of the Intel 4004 virtual machine
VirtualMachine
["Intel4004",<|"ROMChipCount"roms,"RAMChipCount"rams|>]
create an Intel 4004 instance with
roms
number of ROM chips and
rams
number of RAM chips
▪
By default,
VirtualMachine
["Intel4004"]
creates an instance with one ROM chip and 4 RAM chips.
▪
For the
"Intel4004"
virtual machine, the following properties can be queried:
obj["CycleCount"]
the number of cycles the machine has run
obj["ProcessorState"]
an
Association
representing the state of the processor
obj["RAMBankCount"]
the number of RAM banks
obj["RAMChipCount"]
the number of RAM chips
obj["RAMState"]
an
Association
representing the state of the RAM
obj["ROMArrayVisualization",chip]
a visualization of the
chip
array
obj["ROMChipCount"]
the number of ROM chips
obj["ROMState"]
an
Association
representing the state of the ROM
obj["StepCount"]
the number of steps the machine has run
▪
For the
"Intel4004"
virtual machine, the following commands can be executed using
VirtualMachineExecute
:
VirtualMachineExecute
[obj,"Debugger"]
return an interactive debugger
VirtualMachineExecute
[obj,"ProcessorReset",org]
reset the state of the processor, setting the program counter to
org
VirtualMachineExecute
[obj,"RAMReset",bank,chip]
reset the specified RAM
chip
in the given RAM
bank
VirtualMachineExecute
[obj,"Reset"]
reset the machine
VirtualMachineExecute
[obj,"ROMLoad",chip,bin]
load the binary
bin
into the specified ROM
chip
VirtualMachineExecute[obj,"ROMReset",chip]
reset the specified ROM
chip
VirtualMachineExecute
[obj,"Run",n]
run
n
steps of the machine
VirtualMachineExecute
[obj,"RunTrace",n]
run
n
steps of the machine and return a trace of the evaluation
Examples
MoreExamples⊳
Create a new instance of the
"Intel4004"
virtual machine:
In[1]:=
intel4004=
VirtualMachine
["Intel4004"]
Out[1]=
VirtualMachineObject
Machine: Intel4004
StepCount: 0
Instruction: NOP
ROM chips: 1
RAM chips: 4

Get information about the object:
In[2]:=
Information[intel4004]
Out[2]=
VirtualMachineObject
Machine Name
Intel4004
Properties
{CycleCount,Machine,ProcessorState,RAMBankCount,RAMChipCount,RAMState,ROMArrayVisualization,ROMChipCount,ROMState,StepCount}
Commands
{Debugger,ProcessorReset,RAMReset,Reset,ROMLoad,ROMReset,Run,RunTrace}
Functions
{Information,Normal}
Obtain the state of the processor:
In[3]:=
intel4004["ProcessorState"]//Dataset
Out[3]=
Load a program (in the first ROM chip) that tests RAM related instructions:
In[4]:=
VirtualMachineExecute
intel4004,"ROMLoad",0,ByteArray
256 bytes

Out[4]=
VirtualMachineObject
Machine: Intel4004
StepCount: 0
Instruction: NOP
ROM chips: 1
RAM chips: 4

Verify the program has correctly loaded:
In[5]:=
intel4004["ROMArrayVisualization",0]
Out[5]=
Get the state of the registers of the first RAM chip in the first RAM bank:
In[6]:=
intel4004["RAMState"][0][0]["Register"]//Dataset
Out[6]=
Run the machine for 1000 steps:
In[7]:=
VirtualMachineExecute
[intel4004,"Run",1000]
Out[7]=
VirtualMachineObject
Machine: Intel4004
StepCount: 1000
Instruction: JUN$020
ROM chips: 1
RAM chips: 4

The program has correctly modified the contents of the RAM array:
In[8]:=
intel4004["RAMState"][0][0]["Register"]//Dataset
Out[8]=
Basic Examples
Interactive Examples
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com