[Driver] Properly invoke endpoint dtors

This commit is contained in:
David Biancolin 2018-12-12 02:08:33 -08:00
parent b64b87f5fb
commit 70f093fd8c
3 changed files with 10 additions and 8 deletions

@ -1 +1 @@
Subproject commit 3a1601fcb254936f6bdfc22e246d2d0fa65eeae7
Subproject commit ccb02888957ca79243b16f91cb0fcd04decef894

View File

@ -348,7 +348,7 @@ uint64_t host_mem_offset = -0x80000000LL;
bool firesim_top_t::simulation_complete() {
bool is_complete = false;
for (auto e: endpoints) {
for (auto &e: endpoints) {
is_complete |= e->terminate();
}
return is_complete;
@ -362,7 +362,7 @@ uint64_t firesim_top_t::profile_models(){
}
int firesim_top_t::exit_code(){
for (auto e: endpoints) {
for (auto &e: endpoints) {
if (e->exit_code())
return e->exit_code();
}
@ -371,11 +371,11 @@ int firesim_top_t::exit_code(){
void firesim_top_t::run() {
for (auto e: fpga_models) {
for (auto &e: fpga_models) {
e->init();
}
for (auto e: endpoints) {
for (auto &e: endpoints) {
e->init();
}
@ -394,7 +394,7 @@ void firesim_top_t::run() {
run_scheduled_tasks();
step(get_largest_stepsize(), false);
while(!done() && !simulation_complete()){
for (auto e: endpoints) e->tick();
for (auto &e: endpoints) e->tick();
}
}

View File

@ -1,6 +1,8 @@
#ifndef __FIRESIM_TOP_H
#define __FIRESIM_TOP_H
#include <memory>
#include "simif.h"
#include "endpoints/endpoint.h"
#include "endpoints/fpga_model.h"
@ -16,12 +18,12 @@ class firesim_top_t: virtual simif_t, public systematic_scheduler_t
protected:
void add_endpoint(endpoint_t* endpoint) {
endpoints.push_back(endpoint);
endpoints.push_back(std::unique_ptr<endpoint_t>(endpoint));
}
private:
// Memory mapped endpoints bound to software models
std::vector<endpoint_t*> endpoints;
std::vector<std::unique_ptr<endpoint_t> > endpoints;
// FPGA-hosted models with programmable registers & instrumentation
std::vector<FpgaModel*> fpga_models;