// // SuperBus.C // // Description: // Bus for sign-extension and shifting // // Version: // $Id$ // // Revision: // $Log$ // // Author: // Brian J. Alliet // Jonathon W. Donaldson // #include "includes.h" SuperBus::SuperBus(const char *id, int numbits, long mask, int shift) : CPUObject(id,numbits), Bus(id,numbits), m_mask(mask), // specifies which bits user wants from input (and then sign extend only those) m_shift(shift) // used to multiply by four for branch operations { } SuperBus::~SuperBus() { } long SuperBus::computeValue() { long val = Bus::computeValue() & m_mask; // sign-extend given value if( val&(~m_mask>>1) ) { val |= ~m_mask; } // only display debug if we are actually performing a sign-extension if(~m_mask != 0 && CPUObject::debug&CPUObject::trace) { cout << "--signext-->" << val; } // shift the value val = m_shift < 0 ? val >> -m_shift : val << m_shift; // only display debug if we are actually performing a shift if(m_shift != 0 && CPUObject::debug&CPUObject::trace) { cout << "--<<"<" << val; } return val; }