/* * Copyright (c) 2014-2015 ARM Limited * All rights reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Authors: Andreas Sandberg */ #ifndef _LIBNOMALIMODEL_GPUBLOCK_HH #define _LIBNOMALIMODEL_GPUBLOCK_HH #include "types.hh" namespace NoMali { class GPU; /** * Base class for GPU function blocks providing common access * functions. */ class GPUBlock { public: GPUBlock(GPU &_gpu); GPUBlock(GPU &_gpu, RegVector::size_type no_regs); GPUBlock(GPUBlock &&rhs); virtual ~GPUBlock() = 0; /** * Reset the function block. * * This method is called to simulated a hard reset of the GPU. It * resets all registers to their default state and resets any * block-specific state. The default implementation resets all * registers to 0. */ virtual void reset(); /** * @{ * @name Register Interface */ /** * Read a register within a function block. * * @param addr Function-block relative address. * @return Register value (32-bits) */ virtual uint32_t readReg(RegAddr addr); /** * Write to a register within a function block. * * @param addr Function-block relative address. * @param value New value (32-bits) */ virtual void writeReg(RegAddr addr, uint32_t value); /** * Read a register within a function block without side effects. * * Unlike a normal read (readReg()), this method does not include * any side effects and reads straight from the register file. It * is primarily intended for things checkpointing. * * @param addr Function-block relative address. * @return Register value (32-bits) */ virtual uint32_t readRegRaw(RegAddr addr); /** * Write to a register within a function block without side * effects. * * Unlike a normal write (writeReg()), this method does not * include any side effects and writes straight into the register * file. It is primarily intended for things checkpointing. * * @param addr Function-block relative address. * @param value New value (32-bits) */ virtual void writeRegRaw(RegAddr addr, uint32_t value); /** @} */ protected: /** Reference to the top-level GPU component */ GPU &gpu; /** GPU block register file */ RegVector regs; private: /** Disable the default constructor */ GPUBlock(); /** Disable the copy constructor */ GPUBlock(GPUBlock &_rhs); /** Disable the assignment operator */ GPUBlock &operator=(GPUBlock &_rhs); }; /** * Base class for interrupt enabled GPU function blocks. * * Function blocks with interrupt functionality implement four * different registers controlling interrupts: *