2023-09-08 11:35:18 +02:00
|
|
|
/* Block RAM IP.
|
2018-06-25 17:03:09 +02:00
|
|
|
*
|
2023-01-07 17:20:15 +01:00
|
|
|
* Author: Daniel Krebs <github@daniel-krebs.net>
|
2023-09-08 11:35:18 +02:00
|
|
|
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2023-01-07 17:20:15 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-09-08 11:35:18 +02:00
|
|
|
*/
|
2018-06-25 17:03:09 +02:00
|
|
|
|
2022-11-11 06:36:20 -05:00
|
|
|
#include <villas/exceptions.hpp>
|
2018-08-21 11:07:53 +02:00
|
|
|
#include <villas/fpga/ips/bram.hpp>
|
2018-04-13 15:30:12 +02:00
|
|
|
|
2022-12-02 18:46:00 +01:00
|
|
|
using namespace villas;
|
2020-06-14 22:11:15 +02:00
|
|
|
using namespace villas::fpga::ip;
|
2018-04-13 15:30:12 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
void BramFactory::parse(Core &ip, json_t *cfg) {
|
|
|
|
CoreFactory::parse(ip, cfg);
|
|
|
|
|
|
|
|
auto &bram = dynamic_cast<Bram &>(ip);
|
|
|
|
|
|
|
|
json_error_t err;
|
|
|
|
int ret = json_unpack_ex(cfg, &err, 0, "{ s: i }", "size", &bram.size);
|
|
|
|
if (ret != 0)
|
|
|
|
throw ConfigError(cfg, err, "", "Cannot parse BRAM config");
|
2018-04-13 15:30:12 +02:00
|
|
|
}
|
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
bool Bram::init() {
|
|
|
|
allocator = std::make_unique<LinearAllocator>(getAddressSpaceId(memoryBlock),
|
|
|
|
this->size, 0);
|
2018-04-13 15:30:12 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
return true;
|
2018-04-13 15:30:12 +02:00
|
|
|
}
|
|
|
|
|
2022-12-02 18:46:00 +01:00
|
|
|
static BramFactory f;
|