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

cpp_transpiler should emit DSLX constants #1610

Open
mikex-oss opened this issue Sep 17, 2024 · 0 comments
Open

cpp_transpiler should emit DSLX constants #1610

mikex-oss opened this issue Sep 17, 2024 · 0 comments
Labels
enhancement New feature or request 🧦 sox

Comments

@mikex-oss
Copy link
Collaborator

What's hard to do? (limit 100 words)

Currently the cpp_transpiler only converts type definitions for use in C++:

XLS_ASSIGN_OR_RETURN(std::unique_ptr<CppTypeGenerator> generator,
CppTypeGenerator::Create(def, type_info, import_data));

It would be useful to also convert constants so that the C++ is aware of the parametrization of DSLX types.

Current best alternative workaround (limit 100 words)

In some cases, you could make fake types in the DSLX library that would generate what you want as a side effect. For example:

const FOO = u32:32;  // constant I care about

type FooBits = bits[FOO];

would generate something like

using FooBits = uint32_t;
constexpr int64_t kFooBitsWidth = 32;  // hurray!

Alternatively, the constants can be redefined in the consumer C++ library, but this creates multiples sources of truth.

Your view of the "best case XLS enhancement" (limit 100 words)

Emit DSLX const definitions in the C++ generated library.

@mikex-oss mikex-oss added enhancement New feature or request 🧦 sox labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🧦 sox
Projects
Status: No status
Development

No branches or pull requests

1 participant