Skip to content

Commit

Permalink
Merge branch 'power' into 'master'
Browse files Browse the repository at this point in the history
Power

See merge request gwt_sdk_developer/gvsoc!21
  • Loading branch information
GERMAIN HAUGOU committed Nov 24, 2021
2 parents a351a4d + 3e48a10 commit de2cbf4
Show file tree
Hide file tree
Showing 25 changed files with 1,339 additions and 2,425 deletions.
5 changes: 4 additions & 1 deletion engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ set(GVSOC_ENGINE_CXX_SRCS
"src/clock/clock.cpp"
"src/vp.cpp"
"src/proxy.cpp"
"src/power/power.cpp"
"src/power/power_engine.cpp"
"src/power/component_power.cpp"
"src/power/power_trace.cpp"
"src/power/power_source.cpp"
"src/launcher.cpp"
)

Expand Down
393 changes: 393 additions & 0 deletions engine/include/gv/power.hpp

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions engine/include/vp/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "vp/itf/clk.hpp"
#include "vp/clock/component_clock.hpp"
#include "vp/trace/component_trace.hpp"
#include "vp/power/component_power.hpp"
#include "gv/power.hpp"
#include "json.hpp"
#include <functional>

Expand Down Expand Up @@ -424,7 +424,7 @@ namespace vp {

void dump_traces_recursive(FILE *file);


component *get_parent() { return this->parent; }
inline js::config *get_js_config() { return comp_js_config; }

js::config *get_vp_config();
Expand Down Expand Up @@ -457,6 +457,7 @@ namespace vp {
config *import_config(const char *config_string);

void reg_step_pre_start(std::function<void()> callback);
void register_build_callback(std::function<void()> callback);

void post_post_build();

Expand Down Expand Up @@ -525,7 +526,7 @@ namespace vp {
virtual std::string handle_command(Gv_proxy *proxy, FILE *req_file, FILE *reply_file, std::vector<std::string> args, std::string req) { return ""; }

component_trace traces;
component_power power;
vp::power::component_power power;

trace warning;

Expand Down Expand Up @@ -557,6 +558,7 @@ namespace vp {
component *parent = NULL;

vector<std::function<void()>> pre_start_callbacks;
vector<std::function<void()>> build_callbacks;
vector<vp::reg *> regs;

bool reset_done_from_itf;
Expand Down
70 changes: 0 additions & 70 deletions engine/include/vp/power/component_power.hpp

This file was deleted.

125 changes: 0 additions & 125 deletions engine/include/vp/power/power.hpp

This file was deleted.

33 changes: 22 additions & 11 deletions engine/include/vp/power/power_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

/*
/*
* Authors: Germain Haugou, GreenWaves Technologies ([email protected])
*/

Expand All @@ -24,24 +24,35 @@

#include "vp/vp_data.hpp"
#include "vp/component.hpp"
#include "vp/power/power.hpp"
#include "gv/power.hpp"
#include <pthread.h>
#include <thread>

namespace vp {
namespace vp
{

namespace power
{

class engine
{
public:
engine(vp::component *top);

void start_capture();

class power_engine : public component
{
public:
power_engine(js::config *config);
void stop_capture();

virtual void start_capture() {}
void reg_trace(vp::power::power_trace *trace);

virtual void stop_capture() {}
private:
std::vector<vp::power::power_trace *> traces;

virtual void reg_trace(vp::power_trace *trace) {}
};
vp::component *time_engine;

vp::component *top;
};
};
};

#endif
71 changes: 71 additions & 0 deletions engine/include/vp/power/power_source.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2020 GreenWaves Technologies, SAS, ETH Zurich and
* University of Bologna
*
* 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: Germain Haugou, GreenWaves Technologies ([email protected])
*/


#pragma once

#include "vp/vp_data.hpp"
#include "vp/power/power_engine.hpp"


inline void vp::power::power_source::leakage_power_start()
{
if (!this->is_on && this->leakage != -1)
{
this->trace->inc_leakage_power(this->leakage);
}
this->is_on = true;
}

inline void vp::power::power_source::leakage_power_stop()
{
if (this->is_on && this->leakage != -1)
{
this->trace->inc_leakage_power(-this->leakage);
}
this->is_on = false;
}

inline void vp::power::power_source::dynamic_power_start()
{
if (!this->is_on && this->background_power != -1)
{
this->trace->inc_dynamic_power(this->background_power);
}
this->is_on = true;
}

inline void vp::power::power_source::dynamic_power_stop()
{
if (this->is_on && this->background_power != -1)
{
this->trace->inc_dynamic_power(-this->background_power);
}
this->is_on = false;
}

inline void vp::power::power_source::account_energy_quantum()
{
if (this->quantum != -1)
{
this->trace->inc_dynamic_energy(this->quantum);
}
}
Loading

0 comments on commit de2cbf4

Please sign in to comment.