112337Sjason@lowepower.com/* 212337Sjason@lowepower.com * Copyright (c) 2017 Jason Lowe-Power 312337Sjason@lowepower.com * All rights reserved. 412337Sjason@lowepower.com * 512337Sjason@lowepower.com * Redistribution and use in source and binary forms, with or without 612337Sjason@lowepower.com * modification, are permitted provided that the following conditions are 712337Sjason@lowepower.com * met: redistributions of source code must retain the above copyright 812337Sjason@lowepower.com * notice, this list of conditions and the following disclaimer; 912337Sjason@lowepower.com * redistributions in binary form must reproduce the above copyright 1012337Sjason@lowepower.com * notice, this list of conditions and the following disclaimer in the 1112337Sjason@lowepower.com * documentation and/or other materials provided with the distribution; 1212337Sjason@lowepower.com * neither the name of the copyright holders nor the names of its 1312337Sjason@lowepower.com * contributors may be used to endorse or promote products derived from 1412337Sjason@lowepower.com * this software without specific prior written permission. 1512337Sjason@lowepower.com * 1612337Sjason@lowepower.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712337Sjason@lowepower.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812337Sjason@lowepower.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912337Sjason@lowepower.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012337Sjason@lowepower.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112337Sjason@lowepower.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212337Sjason@lowepower.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312337Sjason@lowepower.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412337Sjason@lowepower.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512337Sjason@lowepower.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612337Sjason@lowepower.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712337Sjason@lowepower.com * 2812337Sjason@lowepower.com * Authors: Jason Lowe-Power 2912337Sjason@lowepower.com */ 3012337Sjason@lowepower.com 3112337Sjason@lowepower.com#ifndef __LEARNING_GEM5_GOODBYE_OBJECT_HH__ 3212337Sjason@lowepower.com#define __LEARNING_GEM5_GOODBYE_OBJECT_HH__ 3312337Sjason@lowepower.com 3412337Sjason@lowepower.com#include <string> 3512337Sjason@lowepower.com 3612337Sjason@lowepower.com#include "params/GoodbyeObject.hh" 3712337Sjason@lowepower.com#include "sim/sim_object.hh" 3812337Sjason@lowepower.com 3912337Sjason@lowepower.comclass GoodbyeObject : public SimObject 4012337Sjason@lowepower.com{ 4112337Sjason@lowepower.com private: 4212337Sjason@lowepower.com /** 4312337Sjason@lowepower.com * Fill the buffer with the next chunk of data 4412337Sjason@lowepower.com */ 4512337Sjason@lowepower.com void processEvent(); 4612337Sjason@lowepower.com 4712337Sjason@lowepower.com /// An event that wraps the above function 4812337Sjason@lowepower.com EventFunctionWrapper event; 4912337Sjason@lowepower.com 5012337Sjason@lowepower.com /** 5112337Sjason@lowepower.com * Fills the buffer for one iteration. If the buffer isn't full, this 5212337Sjason@lowepower.com * function will enqueue another event to continue filling. 5312337Sjason@lowepower.com */ 5412337Sjason@lowepower.com void fillBuffer(); 5512337Sjason@lowepower.com 5612337Sjason@lowepower.com /// The bytes processed per tick 5712337Sjason@lowepower.com float bandwidth; 5812337Sjason@lowepower.com 5912337Sjason@lowepower.com /// The size of the buffer we are going to fill 6012337Sjason@lowepower.com int bufferSize; 6112337Sjason@lowepower.com 6212337Sjason@lowepower.com /// The buffer we are putting our message in 6312337Sjason@lowepower.com char *buffer; 6412337Sjason@lowepower.com 6512337Sjason@lowepower.com /// The message to put into the buffer. 6612337Sjason@lowepower.com std::string message; 6712337Sjason@lowepower.com 6812337Sjason@lowepower.com /// The amount of the buffer we've used so far. 6912337Sjason@lowepower.com int bufferUsed; 7012337Sjason@lowepower.com 7112337Sjason@lowepower.com public: 7212337Sjason@lowepower.com GoodbyeObject(GoodbyeObjectParams *p); 7312337Sjason@lowepower.com ~GoodbyeObject(); 7412337Sjason@lowepower.com 7512337Sjason@lowepower.com /** 7612337Sjason@lowepower.com * Called by an outside object. Starts off the events to fill the buffer 7712337Sjason@lowepower.com * with a goodbye message. 7812337Sjason@lowepower.com * 7912337Sjason@lowepower.com * @param name the name of the object we are saying goodbye to. 8012337Sjason@lowepower.com */ 8112337Sjason@lowepower.com void sayGoodbye(std::string name); 8212337Sjason@lowepower.com}; 8312337Sjason@lowepower.com 8412337Sjason@lowepower.com#endif // __LEARNING_GEM5_GOODBYE_OBJECT_HH__ 85