#include <mima.h>
Public Member Functions | |
| void | clock () |
| execute a single instruction | |
| int | get_acc () const |
| Get accumulator value. | |
| bool | get_breakpoint (int address) |
| Returns true if a breakpoint is set at address. | |
| type_breakpoint_list | get_breakpoints () const |
| Get all breakpoint's addresses. | |
| Cli * | get_cli () |
| int | get_counter () const |
| Get current value of the instruction counter. | |
| int | get_iar () const |
| Get the address of the next instruction to be executed. | |
| int | get_memory (int address) |
| Get a stored value from memory. | |
| type_memory_map | get_memory_map (int start=0, int end=-1) const |
| Get all nonzero values from memory in a given address range. | |
| int | get_memsize () const |
| Get current (maximum) memory size. | |
| Mima (int memsize=DEFAULT_MEMSIZE) | |
| void | quit () |
| Send quit signal. | |
| void | reset (bool full=false) |
| Reset Mima. | |
| void | reset_counter () |
| Set instruction counter to 0. | |
| void | run (int steps=-1) |
| Start running. | |
| void | set_acc (int value) |
| Set accumulator to new value. | |
| void | set_iar (int value) |
| Set instruction address register to new value. | |
| void | set_memory (int address, int value) |
| Store a value in memory. | |
| void | set_memsize (int size) |
| Resize memory (all values will be lost). | |
| type_signal_void_int | signal_acc_changed () |
| Emitted when the accumulator has changed its value. | |
| type_signal_void_int | signal_counter_changed () |
| Emitted when the instruction counter has changed its value. | |
| type_signal_void_int | signal_iar_changed () |
| Emitted when the instruction address register has changed its value. | |
| type_signal_char_int_termcollect | signal_in () |
| Emitted when Mima reads a value from an input device. | |
| type_signal_void_int_bool | signal_memory_breakpoint_changed () |
| Emitted when a breakpoint has been toggled. | |
| type_signal_void | signal_memory_clear () |
| Emitted when the memory has been cleared. | |
| type_signal_void_int_int | signal_memory_value_changed () |
| Emitted when a value in the memory has changed. | |
| type_signal_void_int | signal_memsize_changed () |
| Emitted when the memsize has been changed. | |
| type_signal_void_int_char | signal_out () |
| Emitted when Mima sends a value to an output device. | |
| type_signal_void | signal_quit () |
| Emitted when the 'quit' command is invoked. | |
| type_signal_void_state | signal_state_changed () |
| Emitted when Mima has entered a new State. | |
| void | stop () |
| Stop running. | |
| bool | toggle_breakpoint (int address) |
| (Un)set a breakpoint | |
| ~Mima () | |
Protected Member Functions | |
| void | decrement_iar () |
| Decrement the instruction address register. | |
| void | increment_counter () |
| Increment the instruction counter. | |
| void | increment_iar () |
| Increment the instruction address register. | |
| void | set_state (State state) |
| Set current state. | |
| int | sign_extend (int arg) |
| sign extend 20 Bit value to 24 Bit | |
Protected Attributes | |
| type_signal_char_int_termcollect | m_signal_in |
| type_signal_void_int_char | m_signal_out |
| type_signal_void | m_signal_quit |
| type_signal_void_state | m_signal_state_changed |
Classes | |
| class | Counter |
| The instruction counter for the microprocessor system. | |
| class | Memory |
| The memory for the microprocessor system. | |
| class | Register |
| A register for the microprocessor system. | |
| struct | TermCollect |
| Collect all return values from multiple input devices. | |
The Mima class represents the actual microprocessor simulator. It provides functions to read or manipulate its memory and execute the instructions that are stored there.
Each word has 24 Bit and is interpreted as
| op code | address |
| 4 Bit | 20 Bit |
| op code | arg |
| 8 Bit | 16 Bit |
The Mima supports the following instructions:
| op code | Mnemonic | Description |
|---|---|---|
| 0x0 | ADD addr | ACC += mem[addr] |
| 0x1 | AND addr | ACC &= mem[addr] |
| 0x2 | OR addr | ACC |= mem[addr] |
| 0x3 | XOR addr | ACC ^= mem[addr] |
| 0x4 | LDV addr | ACC = mem[addr] |
| 0x5 | STV addr | mem[addr] = ACC |
| 0x6 | LDC s | ACC = s |
| 0x7 | JMP addr | IAR = addr |
| 0x8 | JMN addr | IAR = (ACC < 0) ? addr : IAR++ |
| 0x9 | EQL addr | ACC = (ACC == mem[addr]) ? -1 : 0 |
| Extended commands | ||
| 0xf0 | HLT | Halt machine |
| 0xf1 | NOT | ACC = ~ACC |
| 0xf2 | RAR | ACC = ((ACC & 0x1) << 23) | (ACC >> 1) |
| 0xf3 | OUT addr | out[addr] = ACC & 0xff |
| 0xf4 | IN addr | ACC = (ACC & 0xffff00) | (in[addr] & 0xff) |
| Mima::Mima | ( | int | memsize = DEFAULT_MEMSIZE |
) |
| memsize | holds the size of Mima's memory (default is 1,048,576 = 0x100000 words) |
| Mima::~Mima | ( | ) |
| void Mima::clock | ( | ) |
execute a single instruction
| void Mima::decrement_iar | ( | ) | [protected] |
Decrement the instruction address register.
| int MimaSim::Mima::get_acc | ( | ) | const [inline] |
Get accumulator value.
| bool MimaSim::Mima::get_breakpoint | ( | int | address | ) | [inline] |
Returns true if a breakpoint is set at address.
| type_breakpoint_list MimaSim::Mima::get_breakpoints | ( | ) | const [inline] |
Get all breakpoint's addresses.
| Cli* MimaSim::Mima::get_cli | ( | ) | [inline] |
| int MimaSim::Mima::get_counter | ( | ) | const [inline] |
Get current value of the instruction counter.
| int MimaSim::Mima::get_iar | ( | ) | const [inline] |
Get the address of the next instruction to be executed.
| int MimaSim::Mima::get_memory | ( | int | address | ) | [inline] |
Get a stored value from memory.
| type_memory_map MimaSim::Mima::get_memory_map | ( | int | start = 0, |
|
| int | end = -1 | |||
| ) | const [inline] |
Get all nonzero values from memory in a given address range.
| start | The start address (default start = 0) | |
| end | The end address (default = -1) |
| int MimaSim::Mima::get_memsize | ( | ) | const [inline] |
Get current (maximum) memory size.
| void Mima::increment_counter | ( | ) | [protected] |
Increment the instruction counter.
| void Mima::increment_iar | ( | ) | [protected] |
Increment the instruction address register.
| void Mima::quit | ( | ) |
Send quit signal.
| void Mima::reset | ( | bool | full = false |
) |
Reset Mima.
| full | If false, ACC, IAR and instruction counter are set to 0; else the memory ist cleared as well |
| void Mima::reset_counter | ( | ) |
Set instruction counter to 0.
| void Mima::run | ( | int | steps = -1 |
) |
Start running.
| steps | Execute steps instructions, or keep on running, if steps<0 |
| void Mima::set_acc | ( | int | value | ) |
Set accumulator to new value.
| void Mima::set_iar | ( | int | value | ) |
Set instruction address register to new value.
| void Mima::set_memory | ( | int | address, | |
| int | value | |||
| ) |
Store a value in memory.
| void Mima::set_memsize | ( | int | size | ) |
Resize memory (all values will be lost).
| void Mima::set_state | ( | State | state | ) | [protected] |
Set current state.
| int Mima::sign_extend | ( | int | arg | ) | [protected] |
sign extend 20 Bit value to 24 Bit
| type_signal_void_int MimaSim::Mima::signal_acc_changed | ( | ) | [inline] |
Emitted when the accumulator has changed its value.
| type_signal_void_int MimaSim::Mima::signal_counter_changed | ( | ) | [inline] |
Emitted when the instruction counter has changed its value.
| type_signal_void_int MimaSim::Mima::signal_iar_changed | ( | ) | [inline] |
Emitted when the instruction address register has changed its value.
| type_signal_char_int_termcollect MimaSim::Mima::signal_in | ( | ) | [inline] |
Emitted when Mima reads a value from an input device.
| type_signal_void_int_bool MimaSim::Mima::signal_memory_breakpoint_changed | ( | ) | [inline] |
Emitted when a breakpoint has been toggled.
| type_signal_void MimaSim::Mima::signal_memory_clear | ( | ) | [inline] |
Emitted when the memory has been cleared.
| type_signal_void_int_int MimaSim::Mima::signal_memory_value_changed | ( | ) | [inline] |
Emitted when a value in the memory has changed.
| type_signal_void_int MimaSim::Mima::signal_memsize_changed | ( | ) | [inline] |
Emitted when the memsize has been changed.
| type_signal_void_int_char MimaSim::Mima::signal_out | ( | ) | [inline] |
Emitted when Mima sends a value to an output device.
| type_signal_void MimaSim::Mima::signal_quit | ( | ) | [inline] |
Emitted when the 'quit' command is invoked.
| type_signal_void_state MimaSim::Mima::signal_state_changed | ( | ) | [inline] |
Emitted when Mima has entered a new State.
| void Mima::stop | ( | ) |
Stop running.
| bool MimaSim::Mima::toggle_breakpoint | ( | int | address | ) | [inline] |
(Un)set a breakpoint
type_signal_char_int_termcollect MimaSim::Mima::m_signal_in [protected] |
type_signal_void_int_char MimaSim::Mima::m_signal_out [protected] |
type_signal_void MimaSim::Mima::m_signal_quit [protected] |
type_signal_void_state MimaSim::Mima::m_signal_state_changed [protected] |
1.4.7