cpprisc16  June 16, 2020
Namespaces | Functions | Variables
cpprisc16.cpp File Reference

Instructions set of RiSC16. More...

#include "cpprisc16.hpp"
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
Include dependency graph for cpprisc16.cpp:

Go to the source code of this file.

Namespaces

 cpprisc16
 

Functions

void cpprisc16::i_add (unsigned int result, unsigned int a, unsigned int b)
 R[result] <– R[a] + R[b]. More...
 
void cpprisc16::i_addi (unsigned int result, unsigned int a, immed_t immed6)
 (ADD Immediate) R[result] <– R[a] + immed6 More...
 
void cpprisc16::i_jalr (unsigned int result, unsigned int a)
 (Jump And Link using Register) In the real RiSC16: R[result] <– PC + 1 (where PC = Program Counter), PC <– R[a] (jump to R[a]) but impossible to implement that in this C++ library. More...
 
void cpprisc16::i_lui (unsigned int result, immed_t immed10)
 (Load Upper Immediate) R[result] <– immed10 << 6 More...
 
void cpprisc16::i_lw (unsigned int result, unsigned int a, immed_t immed6)
 (Load Word) R[result] <– Memory[R[a] + immed6] More...
 
void cpprisc16::i_nand (unsigned int result, unsigned int a, unsigned int b)
 R[result] <– R[a] NAND R[b] (== ~(a & b)) More...
 
void cpprisc16::i_sw (unsigned int a, unsigned int result, immed_t immed6)
 (Store Word) Memory[R[result] + immed6] <– R[a] More...
 
void cpprisc16::p_halt (bool print=true)
 If print then call println_all() More...
 
void cpprisc16::p_movi (unsigned int result, immed_t immed)
 (MOV Immediate) R[result] <– immed More...
 
void cpprisc16::p_nop ()
 Do nothing. More...
 
void cpprisc16::p_reset ()
 In the real RiSC16: R[result] <– PC + 1 (where PC = Program Counter), PC <– 0 (jump to 0) but impossible to implement that in this C++ library. More...
 
void cpprisc16::clear_memory ()
 Reset to 0 all memory items and mark them as not used. More...
 
void cpprisc16::clear_nb_executed ()
 Reset the number of executed instructions. More...
 
void cpprisc16::clear_registers ()
 Reset to 0 all registers. More...
 
void cpprisc16::print_mem (unsigned int i)
 Print ith memory item M[i] (without newline). More...
 
void cpprisc16::print_reg (unsigned int a)
 Print the register R[a] (without newline). More...
 
void cpprisc16::print_reg2 (unsigned int a2, unsigned int a1)
 Print the 32 bits value of R[a2]:R[a1] (without newline). More...
 
void cpprisc16::print_value16 (std::uint16_t n)
 Print to stdout the 16 bits value n: hexadecimal representation = binary = decimal = signed decimal (without newline). More...
 
void cpprisc16::print_value32 (std::uint32_t n)
 Print to stdout the 32 bits value n: hexadecimal representation = binary = decimal = signed decimal (without newline). More...
 
void cpprisc16::println_all ()
 Print infos, registers and memory (if used). More...
 
void cpprisc16::println_infos ()
 Print to stdout the number of executed instructions. More...
 
void cpprisc16::println_mem (unsigned int i)
 Print ith memory item M[i]. More...
 
void cpprisc16::println_memory (unsigned int size=0)
 Print memory items. More...
 
void cpprisc16::println_reg (unsigned int a)
 Print the register R[a]. More...
 
void cpprisc16::println_reg2 (unsigned int a2, unsigned int a1)
 Print the 32 bits value of R[a2]:R[a1]. More...
 
void cpprisc16::println_registers ()
 Print all registers items. More...
 
void cpprisc16::println_value16 (std::uint16_t n)
 Print to stdout the 16 bits value n: hexadecimal representation = binary = decimal = signed decimal. More...
 
void cpprisc16::println_value32 (std::uint32_t n)
 Print to stdout the 32 bits value n: hexadecimal representation = binary = decimal = signed decimal. More...
 

Variables

const unsigned int cpprisc16::nb_registers = 8
 Number of registers: 8 word16_t items. More...
 
const unsigned int cpprisc16::size_memory = 256
 Size of the memory: 256 word16_t items. More...
 
unsigned int cpprisc16::after_last_memory_acceded = 0
 Index following the last memory item used. More...
 
word16_t cpprisc16::memory [256]
 Memory items. More...
 
uint64_t cpprisc16::nb_executed = 0
 Number of instructions executed. More...
 
word16_t cpprisc16::registers [8] = {0}
 Registers. More...
 

Detailed Description

Instructions set of RiSC16.

(March 15, 2017) Piece of cpprisc16. https://bitbucket.org/OPiMedia/cpprisc16

GPLv3 — Copyright (C) 2017 Olivier Pirson http://www.opimedia.be/

Definition in file cpprisc16.cpp.