32 void validateSize(
const int size)
35 throw std::invalid_argument(
"Register size must be greater than 1");
43 unsigned short dataBusSize(
const std::string& inputType,
const int size)
48 unsigned short registerOutputBusSize(
const std::string& outputType,
const int size)
63 const auto initialDataSize = data.
size();
64 const auto initialOutputSize = output.
size();
66 inputs = {std::move(data), {std::move(clock)}, {std::move(enable)}, {std::move(clear)}};
69 const int inferredSize =
static_cast<int>(std::max(initialDataSize, initialOutputSize));
71 setProperty(
"inputType", initialDataSize == 1 && initialOutputSize > 1
74 setProperty(
"outputType", initialOutputSize == 1 && initialDataSize > 1
118 const int size = std::get<int>(value);
125 const std::string inputType = std::get<std::string>(value);
131 const std::string outputType = std::get<std::string>(value);
141 if (
state.size() !=
static_cast<std::size_t
>(size))
165 const std::string& outputType)
167 std::vector<Bus> newInputs =
inputs;
177 std::vector<Bus> newOutputs =
outputs;
178 newOutputs.resize(1);
182 if (
state.size() !=
static_cast<std::size_t
>(size))
247 for (std::size_t bit = 0; bit <
state.size(); ++bit)
256 for (std::size_t bit = 0; bit <
state.size(); ++bit)
260 for (std::size_t bit = 0; bit + 1 <
state.size(); ++bit)
268 if (!
state.empty()) {
269 for (std::size_t bit = 0; bit + 1 <
state.size(); ++bit)
static constexpr unsigned int busIndex(Enum value)
Converts a component-local bus enum to its storage index.
Wire_ptr outputWire(unsigned int output, unsigned short bit=0) const
State inputState(unsigned int input, unsigned short bit=0) const
void setOutputs(const std::vector< Bus > &newOutputs)
Replaces all output buses.
std::optional< T > getPropertyValue(std::string_view key) const
Gets a property value with type deduction.
std::vector< Bus > outputs
Output buses produced by this component.
void setInputs(const std::vector< Bus > &newInputs)
Replaces all input buses.
void setProperty(std::string_view key, const PropertyValue &value)
Sets a property value.
void defineUnconnectedInputDefault(unsigned int input, State value)
Defines the state read from an input when its wire is unconnected.
std::vector< Bus > inputs
Input buses connected to this component.
void defineStringListProperty(std::string key, std::string defaultValue, StringPropertyOptions allowedValues, PropertyCallback callback=nullptr)
Defines a string property constrained to a fixed set of values.
void setPropertyCallback(std::string_view key, PropertyCallback callback)
Sets a callback for property validation/transformation.
Wire_ptr inputWire(unsigned int input, unsigned short bit=0) const
void defineProperty(std::string key, T &&defaultValue, PropertyCallback callback=nullptr)
Defines a property with a default value and optional callback.
std::size_t outputBusSize(unsigned int output) const
std::string setInputType(std::string inputType)
std::vector< State > state
void driveOutput(SILICON::simulation::Simulator &sim)
int configuredSize() const
void simulate(SILICON::simulation::Simulator &sim, const SILICON::simulation::Context &context) override
Executes the component's logic with simulator scheduling context.
static constexpr std::string_view SERIAL_TYPE
std::string setOutputType(std::string outputType)
void initializeProperties()
bool parallelOutput() const
bool parallelInput() const
static constexpr std::string_view PARALLEL_TYPE
std::string configuredOutputType() const
std::string configuredInputType() const
Executes event-driven simulation of a Circuit.
static EdgeType edgeType(const Context &context, const Wire_ptr &wire)
Classifies one wire's transition in a simulation context.
void updateWire(const Wire_ptr &target, State newState, uint64_t delay, const Component_weakPtr &source)
Updates a wire with a new state and optional delay.
std::shared_ptr< Wire > Wire_ptr
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.
PropertyValue requireNonNegative(const std::string_view name, const PropertyValue &value)
Validates that an integer property value is non-negative.
State normalizeBinaryOrUnknown(const State state)
Normalizes non-binary states for stored binary elements.
Context describing why a component is being evaluated.
bool initialEvaluation
True for initial or otherwise full-plan evaluation.