SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
wireUtils.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <cstddef>
21
#include <vector>
22
23
#include <
core/wire.hpp
>
24
25
namespace
SILICON::wireUtils
{
26
28
[[nodiscard]]
bool
busValueOverflowsWidth
(
const
core::BusValue
& value, std::size_t width);
29
31
[[nodiscard]]
bool
fitsUnsigned
(
const
core::BusValue
& value, std::size_t width);
32
34
[[nodiscard]]
bool
fitsSigned
(
const
core::BusValue
& value, std::size_t width);
35
42
[[nodiscard]]
core::BusValue
normalizeBusValue
(
const
core::BusValue
& value,
43
std::size_t width,
44
core::State
extension =
core::State::LOW
);
45
52
[[nodiscard]]
bool
busWillChangeToValue
(
const
core::Bus& bus,
53
const
core::BusValue
& value);
54
60
[[nodiscard]]
bool
isKnownBinary
(
core::State
state);
61
68
[[nodiscard]]
bool
mayBe
(
core::State
actual,
core::State
expected);
69
75
[[nodiscard]]
core::State
normalizeBinaryOrUnknown
(
core::State
state);
76
77
}
// namespace SILICON::wireUtils
SILICON::core::State
State
Definition
wire.hpp:37
SILICON::core::State::LOW
@ LOW
Definition
wire.hpp:38
SILICON::core::BusValue
std::vector< State > BusValue
Definition
wire.hpp:120
SILICON::wireUtils
Definition
wire.cpp:90
SILICON::wireUtils::busWillChangeToValue
bool busWillChangeToValue(const Bus &bus, const BusValue &value)
Checks whether assigning a binary value would change any driven bus wire.
Definition
wire.cpp:131
SILICON::wireUtils::normalizeBusValue
BusValue normalizeBusValue(const BusValue &value, const std::size_t width, const State extension)
Resize an LSB-first value to an exact bus width.
Definition
wire.cpp:121
SILICON::wireUtils::normalizeBinaryOrUnknown
State normalizeBinaryOrUnknown(const State state)
Normalizes non-binary states for stored binary elements.
Definition
wire.cpp:146
SILICON::wireUtils::fitsUnsigned
bool fitsUnsigned(const BusValue &value, const std::size_t width)
Tests whether an LSB-first value is representable as an unsigned value.
Definition
wire.cpp:97
SILICON::wireUtils::fitsSigned
bool fitsSigned(const BusValue &value, const std::size_t width)
Tests whether an LSB-first two's-complement value fits a signed width.
Definition
wire.cpp:105
SILICON::wireUtils::busValueOverflowsWidth
bool busValueOverflowsWidth(const BusValue &value, const std::size_t width)
True when truncating to width would discard a non-low bit.
Definition
wire.cpp:94
SILICON::wireUtils::mayBe
bool mayBe(const State actual, const State expected)
Tests whether an actual state could represent an expected binary state.
Definition
wire.cpp:141
SILICON::wireUtils::isKnownBinary
bool isKnownBinary(const State state)
Tests whether a state is a concrete binary logic value.
Definition
wire.cpp:136
wire.hpp
src
core
wireUtils.hpp
Generated by
1.17.0