Skip to content

Commit

Permalink
Merge pull request #296 from GreenWaves-Technologies/4.8_dev
Browse files Browse the repository at this point in the history
4.8 dev
  • Loading branch information
Yaooooo authored Dec 20, 2021
2 parents ef6b7e9 + db984bc commit eb89bfe
Show file tree
Hide file tree
Showing 113 changed files with 4,657 additions and 1,819 deletions.
4 changes: 4 additions & 0 deletions configs/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,7 @@ else
export XCSIM_PLATFORM=$XCSIM_PATH
fi
fi

if [ -f "$GAP_SDK_HOME/configs/wsl.sh" ]; then
source $GAP_SDK_HOME/configs/wsl.sh
fi
2 changes: 1 addition & 1 deletion examples/autotiler/BilinearResize/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RESIZE_KER_PATH = $(TILER_BILINEAR_RESIZE_KERNEL_PATH)
APP_SRCS += Bilinear_Resize.c ImgIO.c
APP_SRCS += ResizeKernels.c $(RESIZE_KER_PATH)/ResizeBasicKernels.c

APP_INC += . $(TILER_EMU_INC) $(TILER_INC) $(RESIZE_KER_PATH)
APP_INC += . $(TILER_EMU_INC) $(TILER_INC) $(RESIZE_KER_PATH) $(TILER_DSP_KERNEL_PATH) $(TILER_CNN_KERNEL_PATH_FP16)

APP_CFLAGS += -O3 -mno-memcpy -fno-tree-loop-distribute-patterns $(USER_FLAGS)
APP_CFLAGS += -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable
Expand Down
5 changes: 4 additions & 1 deletion examples/nntool/mnist_gru/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ PULP_APP = mnist
APP = mnist
APP_SRCS += $(MODEL_PREFIX).c $(MODEL_GEN_C) $(MODEL_COMMON_SRCS) $(CNN_LIB)

APP_CFLAGS += -g -O3 -mno-memcpy -fno-tree-loop-distribute-patterns
ifeq '$(TARGET_CHIP_FAMILY)' 'GAP8'
APP_CFLAGS += -march=rv32imcxgap8
endif
APP_CFLAGS += -g -O3 -mno-memcpy -fno-tree-loop-distribute-patterns
APP_CFLAGS += -I. -I$(MODEL_COMMON_INC) -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) -I$(MODEL_BUILD)
APP_CFLAGS += -DPERF -DAT_MODEL_PREFIX=$(MODEL_PREFIX) $(MODEL_SIZE_CFLAGS)
APP_CFLAGS += -DSTACK_SIZE=$(CLUSTER_STACK_SIZE) -DSLAVE_STACK_SIZE=$(CLUSTER_SLAVE_STACK_SIZE)
Expand Down
3 changes: 3 additions & 0 deletions examples/nntool/mnist_rnn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ PULP_APP = mnist
APP = mnist
APP_SRCS += $(MODEL_PREFIX).c $(MODEL_GEN_C) $(MODEL_COMMON_SRCS) $(CNN_LIB)

ifeq '$(TARGET_CHIP_FAMILY)' 'GAP8'
APP_CFLAGS += -march=rv32imcxgap8
endif
APP_CFLAGS += -g -O3 -mno-memcpy -fno-tree-loop-distribute-patterns
APP_CFLAGS += -I. -I$(MODEL_COMMON_INC) -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) -I$(MODEL_BUILD)
APP_CFLAGS += -DPERF -DAT_MODEL_PREFIX=$(MODEL_PREFIX) $(MODEL_SIZE_CFLAGS)
Expand Down
4 changes: 3 additions & 1 deletion examples/pmsis/periph/i2s/wav_out_long/wav_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static int fs_write_from_L3(void *file, void *data, int size_total, struct pi_de
if(rest_size >= INTER_BUFF_SIZE)
size = INTER_BUFF_SIZE;
else
size = INTER_BUFF_SIZE - rest_size;
size = rest_size;

pi_ram_read(ram, (_l3_buff+l3_index), _tmp_buffer, (uint32_t) size);
pi_fs_write(file, _tmp_buffer, size);
Expand All @@ -59,6 +59,8 @@ static int fs_write_from_L3(void *file, void *data, int size_total, struct pi_de
rest_size = rest_size - size;
} while (rest_size);

pmsis_l2_malloc_free(_tmp_buffer, (uint32_t) INTER_BUFF_SIZE);

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions gvsoc/gvsoc/bin/pulp-pc-info
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import os
from subprocess import Popen, PIPE
import sys


parser = argparse.ArgumentParser(description='Generate PC debug info')
Expand Down Expand Up @@ -125,6 +126,11 @@ for f in functions:

# And finally generate the output files

if args.allFile is None and args.pcFile is None and args.debugFile is None and args.inlineFile is None:
for f in functions:
f.dumpAll(sys.stdout)


# PC oriented file
if args.allFile != None:
with open(args.allFile, 'w') as file:
Expand Down
2 changes: 1 addition & 1 deletion gvsoc/gvsoc/engine/include/gv/gvsoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace gv {
* @param id ID of the VCD event.
* @param value The new value.
*/
virtual void event_update_logical(int64_t timestamp, int id, uint8_t value) = 0;
virtual void event_update_logical(int64_t timestamp, int id, uint64_t value) = 0;

/**
* Called by GVSOC to update the value of a bitfield VCD event.
Expand Down
1 change: 1 addition & 0 deletions gvsoc/gvsoc/engine/python/gv/gvsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def gen_config(args, config):

for binary in debug_binaries:
full_config.set('**/debug_binaries', binary + '.debugInfo')
full_config.set('**/binaries', binary)


gvsoc_config_path = os.path.join(config.get_str('gapy/work_dir'), 'gvsoc_config.json')
Expand Down
26 changes: 23 additions & 3 deletions gvsoc/gvsoc/engine/src/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void vp::component_trace::new_trace_event_string(std::string name, trace *trace)
trace->name = name;
trace->path = top.get_path() + "/" + name;

trace->width = 0;
trace->is_real = false;
trace->is_string = true;
trace->pending_timestamp = -1;
trace->bytes = 0;
Expand Down Expand Up @@ -409,15 +411,33 @@ void vp::trace_engine::flush_event_traces(int64_t timestamp)
}
else if (current->is_string)
{
//this->vcd_user->event_update_logical(int id, uint8_t *value, uint8_t *flags);
this->vcd_user->event_update_string(timestamp, current->id, (char *)current->buffer);
}
else if (current->width > 1)
else if (current->width > 8)
{
if (current->width <= 16)
{
this->vcd_user->event_update_logical(timestamp, current->id, *(uint16_t *)current->buffer);
}
else if (current->width <= 32)
{
this->vcd_user->event_update_logical(timestamp, current->id, *(uint32_t *)current->buffer);
}
else if (current->width <= 64)
{
this->vcd_user->event_update_logical(timestamp, current->id, *(uint64_t *)current->buffer);
}
else
{
// Use bitfield
}

}
else
{
this->vcd_user->event_update_logical(timestamp, current->id, *current->buffer);
uint64_t value = (uint64_t)*(current->buffer);

this->vcd_user->event_update_logical(timestamp, current->id, value);
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion gvsoc/gvsoc/engine/vp/trace_domain_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void trace_domain::check_trace_active(vp::trace *trace, int event)
{
for (auto &x : events_path_regex)
{
if (x.second->is_path || regexec(x.second->regex, full_path.c_str(), 0, NULL, 0) == 0)
if ((x.second->is_path && x.second->path == full_path) || regexec(x.second->regex, full_path.c_str(), 0, NULL, 0) == 0)
{
std::string file_path = x.second->file_path;
vp::Event_trace *event_trace;
Expand Down Expand Up @@ -462,6 +462,7 @@ void trace_domain::conf_trace(int event, std::string path_str, bool enabled)
const char *file_path = "all.vcd";
const char *path = path_str.c_str();
char *delim = (char *)::index(path, '@');

if (delim)
{
*delim = 0;
Expand Down
1 change: 1 addition & 0 deletions gvsoc/gvsoc/models/cpu/iss/vp/include/iss_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class iss_wrapper : public vp::component, vp::Gdbserver_core
vp::trace inline_trace_event;
vp::trace line_trace_event;
vp::trace file_trace_event;
vp::trace binaries_trace_event;
vp::trace pcer_trace_event[32];
vp::trace insn_trace_event;

Expand Down
2 changes: 1 addition & 1 deletion gvsoc/gvsoc/models/cpu/iss/vp/include/platform_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static inline int iss_fetch_req_common(iss_t *_this, uint64_t addr, uint8_t *dat
if (err != vp::IO_REQ_OK)
{
if (err == vp::IO_REQ_INVALID)
_this->trace.fatal("Invalid fetch request (addr: 0x%x, size: 0x%x)\n", addr, size);
_this->trace.force_warning("Invalid fetch request (addr: 0x%x, size: 0x%x)\n", addr, size);
else
{
iss_exec_insn_stall(_this);
Expand Down
8 changes: 8 additions & 0 deletions gvsoc/gvsoc/models/cpu/iss/vp/src/iss_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ int iss_wrapper::build()
traces.new_trace_event_string("func", &func_trace_event);
traces.new_trace_event_string("inline_func", &inline_trace_event);
traces.new_trace_event_string("file", &file_trace_event);
traces.new_trace_event_string("binaries", &binaries_trace_event);
traces.new_trace_event("line", &line_trace_event, 32);

traces.new_trace_event_real("ipc_stat", &ipc_stat_event);
Expand Down Expand Up @@ -1423,6 +1424,13 @@ void iss_wrapper::start()
iss_register_debug_info(this, x->get_str().c_str());
}

if (this->get_js_config()->get("**/binaries") != NULL)
{
for (auto x:this->get_js_config()->get("**/binaries")->get_elems())
{
this->binaries_trace_event.event_string("static enable " + x->get_str());
}
}

trace.msg("ISS start (fetch: %d, is_active: %d, boot_addr: 0x%lx)\n", fetch_enable_reg.get(), is_active_reg.get(), get_config_int("boot_addr"));

Expand Down
5 changes: 5 additions & 0 deletions gvsoc/gvsoc_gap/models/pulp/udma/hyper/udma_hyper_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Hyper_periph::Hyper_periph(udma *top, int id, int itf_id) : Udma_periph(top, id)
this->read_req_waiting = new Udma_queue<Hyper_read_request>(-1);
this->read_req_ready = new Udma_queue<Hyper_read_request>(-1);

memset((void *)&this->ca, 0, sizeof(this->ca));

}


Expand Down Expand Up @@ -191,6 +193,9 @@ void Hyper_periph::reset(bool active)
{
Udma_periph::reset(active);

this->rx_channel->reset(active);
this->tx_channel->reset(active);

if (!active)
{
this->pending_tx = false;
Expand Down
3 changes: 3 additions & 0 deletions gvsoc/gvsoc_gap/models/pulp/udma/i2c/v4/udma_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ void I2c_periph::reset(bool active)
{
Udma_periph::reset(active);

this->foll_rx_channel->reset(active);
this->foll_tx_channel->reset(active);

if (active)
{
}
Expand Down
15 changes: 9 additions & 6 deletions gvsoc/gvsoc_gap/models/pulp/udma/i2s/udma_i2s_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,29 +239,32 @@ void I2s_periph::handle_sdo(bool no_restart)
{
this->tx_wait_data_init &= ~(1 << this->active_channel);
data = this->tx_fifo[this->active_channel].front();

this->tx_fifo[this->active_channel].pop();
}
else
{
if (((this->tx_wait_data_init >> this->active_channel) & 1) == 0)
{
this->trace.msg(vp::trace::LEVEL_DEBUG, "Generating TX error (slot: %d)\n", this->active_channel);
this->regmap.err_status.set(this->regmap.err_status.get() | (1 << (this->active_channel + 16)));
}
}

this->tx_pending_value = this->handle_tx_format(channel, data);

this->trace.msg(vp::trace::LEVEL_DEBUG, "Got new TX sample (value: 0x%x, width: %d)\n", this->tx_pending_value, this->tx_pending_bits);

this->trace.msg(vp::trace::LEVEL_DEBUG, "Got new TX sample (slot: %d, value: 0x%x, width: %d)\n", this->active_channel, this->tx_pending_value, this->tx_pending_bits);

// Now ask the next sample to the channel so that it is ready for the
// next frame.
// The channel id is pushed now since we the samples are received in order
// and we don't know what is the slot when we receive the sample from the channel

this->tx_fifo_slot_id.push(this->active_channel);
channel->get_data(channel->slot_cfg->tx_dsize_get() + 1, channel->slot_cfg->tx_id_get());
if (channel->is_active() || channel->slot_cfg->tx_id_get() >= 0xe0)
{
this->tx_fifo_slot_id.push(this->active_channel);

channel->get_data(channel->slot_cfg->tx_dsize_get() + 1, channel->slot_cfg->tx_id_get());
}
}

if (this->tx_pending_bits > 0)
Expand Down Expand Up @@ -1065,7 +1068,7 @@ void I2s_tx_channel::push_data(uint8_t *data, int size)
uint32_t value = 0;
memcpy((void *)&value, (void *)data, size);

this->periph->trace.msg(vp::trace::LEVEL_INFO, "Received TX sample from memory (value: 0x%x)\n", value);
this->periph->trace.msg(vp::trace::LEVEL_INFO, "Received TX sample from memory (slot: %d, value: 0x%x)\n", this->periph->tx_fifo_slot_id.front(), value);

this->periph->tx_fifo[this->periph->tx_fifo_slot_id.front()].push(value);
this->periph->tx_fifo_slot_id.pop();
Expand Down
3 changes: 3 additions & 0 deletions gvsoc/gvsoc_gap/models/pulp/udma/mram/udma_mram_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ void Mram_periph::reset(bool active)

this->read_fifo->reset(active);

this->rx_channel->reset(active);
this->tx_channel->reset(active);

if (!active)
{
this->pending_transfer_size = 0;
Expand Down
22 changes: 15 additions & 7 deletions gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_addrgens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Udma_addrgen_linear::check_pending_transfer()
{
if (!this->active_transfer && this->nb_pending_transfers)
{
trace.msg(vp::trace::LEVEL_TRACE, "Starting new buffer (addr: 0x%x, size: 0x%x)\n", this->pending_addr, this->pending_size);
trace.msg(vp::trace::LEVEL_TRACE, "Starting new buffer (addr: 0x%x, size: 0x%x, pending: %d)\n", this->pending_addr, this->pending_size, this->nb_pending_transfers);

this->nb_pending_transfers--;
this->set_active_transfer(true);
Expand All @@ -101,17 +101,25 @@ void Udma_addrgen_linear::cfg_ctrl_req(uint64_t reg_offset, int size, uint8_t *v
}
else if (this->regmap.cfg_ctrl.en_get())
{
this->trace.msg(vp::trace::LEVEL_TRACE, "Enqeueing transfer (pending: %d)\n", this->nb_pending_transfers);

if (this->nb_pending_transfers > 0)
if (this->nb_pending_transfers == 1)
{
this->remaining_size -= this->pending_size;
this->trace.force_warning("Trying to enqueue while alreay 2 transfers are enqueued\n");
}
else
{
if (this->nb_pending_transfers > 0)
{
this->remaining_size -= this->pending_size;
}

this->pending_addr = this->regmap.cfg_sa_buf0.get();
this->pending_size = this->regmap.cfg_size.get();
this->remaining_size += this->pending_size;
this->pending_addr = this->regmap.cfg_sa_buf0.get();
this->pending_size = this->regmap.cfg_size.get();
this->remaining_size += this->pending_size;

this->nb_pending_transfers++;
this->nb_pending_transfers++;
}

this->check_pending_transfer();

Expand Down
8 changes: 8 additions & 0 deletions gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,14 @@ void udma::start()

void udma::reset(bool active)
{
for (auto x: this->periphs)
{
if (x)
{
x->reset(active);
}
}

for (auto x: this->addrgen_linear)
{
x->reset(active);
Expand Down
3 changes: 1 addition & 2 deletions gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_rx_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ void Udma_rx_channels::handle_pending(void *__this, vp::clock_event *event)

if (addr == 0)
{
fflush(NULL);
abort();
_this->top->trace.fatal("UDMA trying to access NULL\n");
}

if (err == vp::IO_REQ_OK)
Expand Down
5 changes: 2 additions & 3 deletions gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_tx_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Udma_tx_channel::get_data(int size, int channel)
{
this->requested_size_queue.push_back(size);
this->requested_size += size;
if (this->requested_size_queue.size() == 1 && this->is_active() && !this->enqueued)
if (this->requested_size_queue.size() > 0 && this->is_active() && !this->enqueued)
{
this->top->tx_channels->push_ready_channel(this);
this->check_state();
Expand Down Expand Up @@ -243,7 +243,7 @@ void Udma_tx_channels::handle_pending(void *__this, vp::clock_event *event)
channel->requested_size_queue.push_front(requested_size_queue - size);
}

if (channel->requested_size_queue.size() && !channel->enqueued)
if (channel->requested_size_queue.size() && !channel->enqueued && channel->is_active())
{
_this->push_ready_channel(channel);
}
Expand Down Expand Up @@ -307,7 +307,6 @@ void Udma_tx_channels::check_state()
{
if (!this->send_reqs_event->is_enqueued())
{
if (!this->pending_channels.empty() && !this->l2_free_reqs->is_empty())
if (!this->pending_channels.empty() && !this->l2_free_reqs->is_empty() && this->pending_channels.front()->is_active())
{
this->top->event_enqueue(this->send_reqs_event, 1);
Expand Down
Loading

0 comments on commit eb89bfe

Please sign in to comment.