SILICON
Loading...
Searching...
No Matches
tests.hpp
Go to the documentation of this file.
1#pragma once
2#include <cassert>
3#include <core/gates.hpp>
4#include <core/wire.hpp>
5#include <gtest/gtest.h>
6#include <memory>
8
9using namespace SILICON::core;
10
11inline BusValue valueFor(const Bus& bus, const std::uint64_t value)
12{
13 return busValueFromInteger(value, bus.size());
14}
15
16inline BusValue valueFor(const std::size_t width, const std::uint64_t value)
17{
18 return busValueFromInteger(value, width);
19}
20
21extern "C" {
22inline void __ubsan_on_report()
23{
24 FAIL() << "Encountered an undefined behavior sanitizer error";
25}
26
27inline void __asan_on_error()
28{
29 FAIL() << "Encountered an address sanitizer error";
30}
31
32inline void __tsan_on_report()
33{
34 FAIL() << "Encountered a thread sanitizer error";
35}
36} // extern "C"
37
38inline void PrintTo(const State& s, std::ostream* os)
39{
40 switch (s) {
41 case State::HIGH: *os << "HIGH"; break;
42 case State::LOW: *os << "LOW"; break;
43 case State::ERROR: *os << "ERROR"; break;
44 case State::UNKNOWN: *os << "UNKNOWN"; break;
45 default: assert(false);
46 }
47}
BusValue busValueFromInteger(const BigInt &value, const std::size_t width)
Builds an LSB-first BusValue from the low width bits of an integer. Negative values use two's complem...
std::vector< State > BusValue
Definition wire.hpp:120
void __asan_on_error()
Definition tests.hpp:27
void PrintTo(const State &s, std::ostream *os)
Definition tests.hpp:38
void __tsan_on_report()
Definition tests.hpp:32
BusValue valueFor(const Bus &bus, const std::uint64_t value)
Definition tests.hpp:11
void __ubsan_on_report()
Definition tests.hpp:22