#include "memory_if.h"

namespace iss {
namespace mmio {
void memory_hierarchy::prepend(memory_elem& e) {
    hierarchy.push_front(e);
    update_chain();
}
void memory_hierarchy::append(memory_elem& e) {
    hierarchy.push_back(e);
    update_chain();
}
void memory_hierarchy::insert_before(memory_elem&) {}
void memory_hierarchy::insert_after(memory_elem&) {}
void memory_hierarchy::replace_last(memory_elem&) {}
void memory_hierarchy::update_chain() {
    bool tail = false;
    for(size_t i = 0; i < hierarchy.size(); ++i) {
        hierarchy[i].get().register_csrs();
        if(i)
            hierarchy[i - 1].get().set_next(hierarchy[i].get().get_mem_if());
    }
}

} // namespace mmio
} // namespace iss