// Copyright © 2019-2023 // // 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. #include "ram.h" #include "memsim.h" RAM::RAM() { ram_.clear(); is_rsp_active_ = false; is_rsp_stall_ = false; } bool RAM::check_duplicate_req(req_t req) { for(int i = 0; i < ram_.size(); i++) { if (ram_[i].addr == req.addr) { std::cout<<"RAM: Duplicate entry. Do not insert..."< 0) { ram_[i].cycles_left -= 1; } } std::cout<<"RAM: # cycles left: "<check_duplicate_req(req)) && req.valid && !req.rw) { req_t r; r.valid = req.valid; r.rw = req.rw; r.byteen = req.byteen; r.addr = req.addr; r.data = req.data; r.tag = req.tag & 0b11; // Store metadata r.cycles_left = MEM_LATENCY; std::cout<<"RAM: Insert entry... "<simulate_cycle_delay(); if (!is_rsp_active_) { if (dequeue_index != -1) { std::cout<<"RAM: Scheduling response... "<