Skip to content

Commit

Permalink
Merge branch 'master' into doc_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLuperini committed Apr 22, 2022
2 parents 433e850 + 234b5cf commit f04a584
Show file tree
Hide file tree
Showing 30 changed files with 1,093 additions and 178 deletions.
3 changes: 3 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ set(GVSOC_ENGINE_CXX_SRCS
"src/trace/vcd.cpp"
"src/clock/clock.cpp"
"src/vp.cpp"
"src/block.cpp"
"src/signal.cpp"
"src/queue.cpp"
"src/proxy.cpp"
"src/power/power_table.cpp"
"src/power/power_engine.cpp"
Expand Down
2 changes: 1 addition & 1 deletion engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CFLAGS_SV += -DVP_TRACE_ACTIVE=1 -D__VP_USE_SYSTEMV=1
VP_SRCS = src/vp.cpp src/proxy.cpp src/trace/trace.cpp src/clock/clock.cpp src/trace/event.cpp \
src/trace/vcd.cpp src/trace/lxt2.cpp src/power/power_trace.cpp src/power/power_table.cpp src/power/power_source.cpp src/power/power_engine.cpp src/power/component_power.cpp src/trace/lxt2_write.c \
src/trace/fst/fastlz.c src/trace/fst/lz4.c src/trace/fst/fstapi.c src/trace/fst.cpp \
src/trace/raw.cpp src/trace/raw/trace_dumper.cpp src/launcher.cpp
src/trace/raw.cpp src/trace/raw/trace_dumper.cpp src/launcher.cpp src/block.cpp src/signal.cpp src/queue.cpp

VP_OBJS = $(patsubst src/%.cpp,$(ENGINE_BUILD_DIR)/%.o,$(patsubst src/%.c,$(ENGINE_BUILD_DIR)/%.o,$(VP_SRCS)))
VP_DBG_OBJS = $(patsubst src/%.cpp,$(ENGINE_BUILD_DIR)/dbg/%.o,$(patsubst src/%.c,$(ENGINE_BUILD_DIR)/dbg/%.o,$(VP_SRCS)))
Expand Down
5 changes: 5 additions & 0 deletions engine/include/vp/clock/component_clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,17 @@ namespace vp {

inline time_engine *get_engine();

void add_clock_event(clock_event *);

protected:
clock_engine *clock = NULL;

clk_slave clock_port;
vp::wire_slave<bool> reset_port;

std::vector<clock_event *> events;


};

};
Expand Down
20 changes: 19 additions & 1 deletion engine/include/vp/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace vp {
class config;
class clock_engine;
class component;
class signal;

class regfield
{
Expand Down Expand Up @@ -392,8 +393,25 @@ namespace vp {
};


class block
{
public:
block(block *parent);
virtual void reset(bool active) {}
void add_signal(vp::signal *signal);

protected:
void reset_all(bool active);
void add_block(block *block);

private:
block *parent;
std::vector<block *> subblocks;
std::vector<signal *> signals;
};


class component : public component_clock
class component : public component_clock, public block
{

friend class component_clock;
Expand Down
57 changes: 57 additions & 0 deletions engine/include/vp/queue.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2020 GreenWaves Technologies, SAS
*
* 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 <string.h>

namespace vp {

class queue_elem;
class block;

class queue : public block
{
public:
queue(block *parent);
void push(queue_elem *elem);
queue_elem *head();
queue_elem *pop();
bool empty();
void reset(bool active);
private:
static void cancel_callback(void *__this, vp::queue_elem *elem);
queue_elem *first=NULL;
queue_elem *last;
};

class queue_elem
{
friend class queue;

public:
void cancel();

protected:
queue_elem *next;
void *cancel_this;
void (*cancel_callback)(void *, vp::queue_elem *);
};
};
38 changes: 38 additions & 0 deletions engine/include/vp/signal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 GreenWaves Technologies, SAS
*
* 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])
*/

#include <stdint.h>

namespace vp {

class signal
{
public:
signal(block *parent, int64_t reset);
void set(int64_t value) { this->value = value; }
void setu(uint64_t value) { this->value = value; }
int64_t get() { return this->value; }
uint64_t getu() { return this->value; }
void reset(bool active);
private:
int64_t value;
int64_t reset_value;
};
};
2 changes: 1 addition & 1 deletion engine/python/gv/gvsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def exec(self):

os.environ['PULP_CONFIG_FILE'] = self.gvsoc_config_path

if gvsoc_config.get("debug-mode"):
if gvsoc_config.get_bool("debug-mode"):
launcher = gvsoc_config.get_str('launchers/debug')
else:
launcher = gvsoc_config.get_str('launchers/default')
Expand Down
59 changes: 59 additions & 0 deletions engine/src/block.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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])
*/

#include <vp/vp.hpp>
#include <vp/signal.hpp>

vp::block::block(block *parent)
: parent(parent)
{
if (parent)
{
parent->add_block(this);
}
}


void vp::block::reset_all(bool active)
{
for (block *block: this->subblocks)
{
block->reset_all(active);
}

for (signal *signal: this->signals)
{
signal->reset(active);
}

this->reset(active);
}


void vp::block::add_block(block *block)
{
this->subblocks.push_back(block);
}

void vp::block::add_signal(vp::signal *signal)
{
this->signals.push_back(signal);
}
98 changes: 98 additions & 0 deletions engine/src/queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* 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])
*/

#include <vp/vp.hpp>
#include <vp/queue.hpp>

vp::queue::queue(block *parent)
: block(parent)
{

}

void vp::queue::cancel_callback(void *__this, vp::queue_elem *elem)
{
vp::queue *_this = (vp::queue *)__this;
vp::queue_elem *current = _this->first, *prev=NULL;

while(current && current != elem)
{
prev = current;
current = current->next;
}

if (prev)
{
prev->next = current->next;
}
else
{
_this->first = current->next;
}
}

bool vp::queue::empty()
{
return this->first == NULL;
}

void vp::queue::reset(bool active)
{
this->first = NULL;
}

void vp::queue::push(queue_elem *elem)
{
if (this->first)
{
this->last->next = elem;
}
else
{
this->first = elem;
}

this->last = elem;
elem->next = NULL;

elem->cancel_callback = &vp::queue::cancel_callback;
elem->cancel_this = this;
}

vp::queue_elem *vp::queue::head()
{
return this->first;
}

vp::queue_elem *vp::queue::pop()
{
vp::queue_elem *result = this->first;
if (result)
{
this->first = result->next;
}
return result;
}

void vp::queue_elem::cancel()
{
this->cancel_callback(this->cancel_this, this);
}
37 changes: 37 additions & 0 deletions engine/src/signal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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])
*/

#include <vp/vp.hpp>
#include <vp/signal.hpp>

vp::signal::signal(block *parent, int64_t reset)
{
this->reset_value = reset;
parent->add_signal(this);
}

void vp::signal::reset(bool active)
{
if (active)
{
this->value = this->reset_value;
}
}
Loading

0 comments on commit f04a584

Please sign in to comment.