/* `Deep Thought', a softcore CPU implemented on a FPGA Copyright (C) 2010 Markus Hofstaetter Copyright (C) 2010 Martin Perner Copyright (C) 2010 Stefan Rebernig Copyright (C) 2010 Manfred Schwarz Copyright (C) 2010 Bernhard Urban This program 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 3 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, see . */ #include "../Iinstr.hpp" class Cor : public Iinstr { public: Cor(); void evalInstr(); void execInstr(); std::string toString(); Iinstr* getNew(); }; /** * Name: create_instruction * Purpose: if compiled as shared library, this functions creates the instruction object * Returns: pointer to instruction object */ extern "C" Iinstr* create_instruction() { return new Cor(); } Iinstr* Cor::getNew() { return new Cor(); } /** * Name: destroy_instruction * Purpose: if compiled as shared library, this functions destoys the instruction object * Parameter: IInstruction - the instruction object to delete */ extern "C" void destroy_instruction(Iinstr* p) { delete p; } Cor::Cor() { opcode = B5(00110); name = "or"; } void Cor::evalInstr() { this->m_d = argbits[0]; argbits >>= 11; m_rb = this->getRegister(argbits); argbits >>= 4; m_ra = this->getRegister(argbits); argbits >>= 4; m_rd = this->getRegister(argbits); } void Cor::execInstr() { //cout << "should exec " << this->toString() << endl; CDat ra = this->m_cpu->getRegister(m_ra); CDat rb = this->m_cpu->getRegister(m_rb); CDat val = ra | rb; this->m_cpu->setRegister(m_rd, val); if(!this->m_d) { this->m_cpu->updateFlags(val); } } std::string Cor::toString() { stringstream op; op << this->getName(); if(m_d) op << 'D'; if(m_c) op << 'C'; op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb; return op.str(); }