Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor is-compatible ports with constexpr #93

Open
quesnel opened this issue Jun 23, 2022 · 0 comments
Open

refactor is-compatible ports with constexpr #93

quesnel opened this issue Jun 23, 2022 · 0 comments

Comments

@quesnel
Copy link
Member

quesnel commented Jun 23, 2022

We known the type of output/input for each ports. So we can provide a constant
expression is-compatible port for each model.

enum class value_port_type : i8 {
	continuous,
	discrete,
	both
};

class counter {
	input_port x[1];

	constexpr value_port_type x_type(int i) noexcept
	{
		return value_port_type::both;
	}

};

class abstract_cross{
	input_port x[4];
	output_port y[3];

	constexpr value_port_type x_type(int i) noexcept
	{
		return value_port_type::both;
	}

	constexpr value_port_type y_type(int i) noexcept
	{
		if (i == 0 || i == 1)
			return value_port_type::continuous;
		else
			return value_port_type::discrete;
	}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant