Skip to content

Commit

Permalink
target: Allow verilator build with musl libc (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
zero9178 authored May 14, 2024
1 parent bac76fd commit d7828ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion target/common/test/tb_bin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

#include <printf.h>
#include <stdio.h>

#include "sim.hh"

Expand Down
10 changes: 5 additions & 5 deletions target/common/test/tb_lib.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace sim {

struct GlobalMemory {
static constexpr size_t ADDR_SHIFT = 12;
static constexpr size_t PAGE_SIZE = (size_t)1 << ADDR_SHIFT;
static constexpr size_t SIZE_OF_PAGE = (size_t)1 << ADDR_SHIFT;

std::unordered_map<uint64_t, std::unique_ptr<uint8_t[]>> pages;
std::set<uint64_t> touched;
Expand Down Expand Up @@ -49,8 +49,8 @@ struct GlobalMemory {
if (!page) {
// std::cout << "[TB] Allocate page " << std::hex << (addr <<
// ADDR_SHIFT) << "\n";
page = std::make_unique<uint8_t[]>(PAGE_SIZE);
std::fill(&page[0], &page[PAGE_SIZE], 0);
page = std::make_unique<uint8_t[]>(SIZE_OF_PAGE);
std::fill(&page[0], &page[SIZE_OF_PAGE], 0);
}
// std::cout << "[TB] Write to page " << std::hex << (addr <<
// ADDR_SHIFT)
Expand All @@ -67,7 +67,7 @@ struct GlobalMemory {
if (host) {
*host = data[data_idx];
} else {
page[i % PAGE_SIZE] = data[data_idx];
page[i % SIZE_OF_PAGE] = data[data_idx];
any_changed = true;
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ struct GlobalMemory {
if (page) {
// std::cout << "[TB] Read byte " << std::hex << i <<
// "\n";
data[data_idx] = page[i % PAGE_SIZE];
data[data_idx] = page[i % SIZE_OF_PAGE];
} else {
data[data_idx] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion target/common/test/verilator_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

#include <printf.h>
#include <stdio.h>

#include "Vtestharness.h"
#include "Vtestharness__Dpi.h"
Expand Down

0 comments on commit d7828ed

Please sign in to comment.