atomic.hh revision 3192
1803SN/A/* 21363SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 3803SN/A * All rights reserved. 4803SN/A * 5803SN/A * Redistribution and use in source and binary forms, with or without 6803SN/A * modification, are permitted provided that the following conditions are 7803SN/A * met: redistributions of source code must retain the above copyright 8803SN/A * notice, this list of conditions and the following disclaimer; 9803SN/A * redistributions in binary form must reproduce the above copyright 10803SN/A * notice, this list of conditions and the following disclaimer in the 11803SN/A * documentation and/or other materials provided with the distribution; 12803SN/A * neither the name of the copyright holders nor the names of its 13803SN/A * contributors may be used to endorse or promote products derived from 14803SN/A * this software without specific prior written permission. 15803SN/A * 16803SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17803SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18803SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19803SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20803SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21803SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22803SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23803SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24803SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25803SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26803SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Steve Reinhardt 292665SN/A */ 302665SN/A 31803SN/A#ifndef __CPU_SIMPLE_ATOMIC_HH__ 32768SN/A#define __CPU_SIMPLE_ATOMIC_HH__ 331730SN/A 34773SN/A#include "cpu/simple/base.hh" 35768SN/A 36768SN/Aclass AtomicSimpleCPU : public BaseSimpleCPU 37773SN/A{ 38773SN/A public: 39768SN/A 40768SN/A struct Params : public BaseSimpleCPU::Params { 41768SN/A int width; 42768SN/A bool simulate_stalls; 434762Snate@binkert.org }; 44768SN/A 456658Snate@binkert.org AtomicSimpleCPU(Params *params); 462542SN/A virtual ~AtomicSimpleCPU(); 473540Sgblack@eecs.umich.edu 483540Sgblack@eecs.umich.edu virtual void init(); 493540Sgblack@eecs.umich.edu 503540Sgblack@eecs.umich.edu public: 513348SN/A // 523348SN/A enum Status { 532542SN/A Running, 542542SN/A Idle, 55768SN/A SwitchedOut 56768SN/A }; 572107SN/A 582107SN/A protected: 59773SN/A Status _status; 605606Snate@binkert.org 615606Snate@binkert.org Status status() const { return _status; } 625606Snate@binkert.org 631817SN/A private: 64772SN/A 65772SN/A struct TickEvent : public Event 664762Snate@binkert.org { 675606Snate@binkert.org AtomicSimpleCPU *cpu; 685606Snate@binkert.org 69768SN/A TickEvent(AtomicSimpleCPU *c); 703846Shsul@eecs.umich.edu void process(); 71909SN/A const char *description(); 72803SN/A }; 73803SN/A 74803SN/A TickEvent tickEvent; 75771SN/A 76777SN/A const int width; 77777SN/A const bool simulate_stalls; 78773SN/A 79773SN/A // main simulation loop (one cycle) 801634SN/A void tick(); 811634SN/A 821634SN/A class CpuPort : public Port 832539SN/A { 841634SN/A 851634SN/A AtomicSimpleCPU *cpu; 862542SN/A 873349SN/A public: 88768SN/A 892641SN/A CpuPort(const std::string &_name, AtomicSimpleCPU *_cpu) 90768SN/A : Port(_name), cpu(_cpu) 912641SN/A { } 92865SN/A 932641SN/A protected: 942641SN/A 95771SN/A virtual bool recvTiming(Packet *pkt); 962630SN/A 972539SN/A virtual Tick recvAtomic(Packet *pkt); 982641SN/A 99803SN/A virtual void recvFunctional(Packet *pkt); 1001817SN/A 1011817SN/A virtual void recvStatusChange(Status status); 1022630SN/A 1032539SN/A virtual void recvRetry(); 1041817SN/A 1052630SN/A virtual void getDeviceAddressRanges(AddrRangeList &resp, 1062539SN/A AddrRangeList &snoop) 107865SN/A { resp.clear(); snoop.clear(); snoop.push_back(RangeSize(0,-1)); } 108865SN/A 109865SN/A }; 110865SN/A CpuPort icachePort; 1112630SN/A CpuPort dcachePort; 1122539SN/A 113865SN/A Request *ifetch_req; 114865SN/A Packet *ifetch_pkt; 1152630SN/A Request *data_read_req; 1162539SN/A Packet *data_read_pkt; 1171817SN/A Request *data_write_req; 1185635Sgblack@eecs.umich.edu Packet *data_write_pkt; 1192542SN/A 1201817SN/A bool dcache_access; 1215635Sgblack@eecs.umich.edu Tick dcache_latency; 1222542SN/A 1231817SN/A public: 1245635Sgblack@eecs.umich.edu 1252539SN/A virtual Port *getPort(const std::string &if_name, int idx = -1); 126803SN/A 1275392Sgblack@eecs.umich.edu virtual void serialize(std::ostream &os); 1282539SN/A virtual void unserialize(Checkpoint *cp, const std::string §ion); 1291817SN/A virtual void resume(); 1305635Sgblack@eecs.umich.edu 1312630SN/A void switchOut(); 1321817SN/A void takeOverFrom(BaseCPU *oldCPU); 1332630SN/A 1342539SN/A virtual void activateContext(int thread_num, int delay); 135803SN/A virtual void suspendContext(int thread_num); 1362641SN/A 137803SN/A template <class T> 1382641SN/A Fault read(Addr addr, T &data, unsigned flags); 1392539SN/A 1402630SN/A template <class T> 1412539SN/A Fault write(T data, Addr addr, unsigned flags, uint64_t *res); 1422539SN/A}; 1432641SN/A 1442539SN/A#endif // __CPU_SIMPLE_ATOMIC_HH__ 1452641SN/A