Skip to content

Add templated bitwise AND block with tests #536

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

alexhojinpark
Copy link

@alexhojinpark alexhojinpark commented Mar 24, 2025

Refs #161

Ported the bitwise AND functionality from GNU Radio 3.10 to GNU Radio 4 as a templated And block, enabling support for multiple integer types via templates.

The implementation is covered by Boost.UT unit tests, validating basic operations, edge cases, and boundary conditions.

Changes:

  • Added: blocks/basic/include/gnuradio-4.0/basic/And.hpp, blocks/basic/test/qa_And.cpp
  • Updated: blocks/basic/CMakeLists.txt, blocks/basic/test/CMakeLists.txt

The current tests cover key scenarios. Should I extend them to include additional bit patterns?

Updated (2025-04-18):

  • Added More Blocks: AndConst.hpp, Not.hpp, Or.hpp, and Xor.hpp
  • Added Test for Blocks: qa_AndConst.cpp, qa_Not.cpp, qa_Or.cpp, and qa_Xor.cpp
  • Updated: blocks/basic/CMakeLists.txt, blocks/basic/test/CMakeLists.txt

Copy link
Member

@RalphSteinhagen RalphSteinhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexhojinpark thanks for your interest in and first contribution to GR4! 👍

The code already looks good as is and seems to be well tested. There are some minor comments (see above).

If you'd be willing, would you implement the full set of 'Boolean Operators' (5 blocks) outlined in the EPIC#161?

i.e.

This would go a long way! I like the approach of templating like done, for example, in here but this is not a must.

In any case, thanks for your PR and let me know if you are OK with implementing the other similar functions as well. Much appreciated.

Otherwise, I'd merge this as is (+ the small changes outlined above).


namespace gr::basic {

GR_REGISTER_BLOCK(gr::basic::And, [uint8_t, int16_t, int32_t])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, maybe it might be worthwhile to expand this compared to the GR3 version to cover all signed and unsigned integral types?

@mormj what do you think? #GSoC

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would expand this out to at least the types supported in GR3

@alexhojinpark
Copy link
Author

alexhojinpark commented Mar 25, 2025

@RalphSteinhagen Thank you for the feedback! Yes, I’d be happy to continue working on implementing the full set of 'Boolean Operators' for EPIC#161.

Let me know if there are any specific considerations I should keep in mind. Looking forward to contributing more!

@RalphSteinhagen
Copy link
Member

@alexhojinpark just carry on. 😊

@RalphSteinhagen
Copy link
Member

@alexhojinpark could you perhaps rebase and (force-)push (possibly with your other additions) again? I changed the restyled bot to (hopefully) accept external public PRs. The previous rule was a bit too restrictive. To become active, you'd need to rebase to the present head in 'main' though. Thanks in advance.

@alexhojinpark
Copy link
Author

@RalphSteinhagen Thanks for the update, I’ve rebased and force-pushed accordingly. No new additions yet, all tests pass locally!

@RalphSteinhagen
Copy link
Member

@alexhojinpark thanks for the rebase ... at least shows that the restyled CI step is now also working for remote public forks...

... it also shows that you maybe need to apply the code formatter. ;-)

See here and the CI check for details:

image

Can be done with your next pushes though...

@codblack789
Copy link

@alexhojinpark how did u build the gnuradio4 locally.. and set it up, can u explain ?

@alexhojinpark
Copy link
Author

@codblack789 Hi, For setting up GNURadio4, I’d check the Building section in the README. It walks you through dependencies and CMake setup.

Once you’ve got the build dir ready (gnuradio4/build/), you can run make there to build it locally. Hope it answered your question!

@codblack789
Copy link

codblack789 commented Mar 28, 2025

@alexhojinpark
Yeah I followed the same steps

  1. Clone
  2. cd gnuradio4
    3.mkdir build
    4.cd build

5.cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DENABLE_BLOCK_PLUGINS=ON -DENABLE_BLOCK_REGISTRY=ON ..
6 --build . -- -j$(nproc)

After that when i open the same in VS code, I get Errors near header files !!

No idea where am I going wrong !!

@RalphSteinhagen
Copy link
Member

@alexhojinpark Yeah I followed the same steps

  1. Clone
  2. cd gnuradio4
    3.mkdir build
    4.cd build

5.cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DENABLE_BLOCK_PLUGINS=ON -DENABLE_BLOCK_REGISTRY=ON .. 6 --build . -- -j$(nproc)

After that when i open the same in VS code, I get Errors near header files !!

No idea where am I going wrong !!

@KrxGu
Copy link
Contributor

KrxGu commented Apr 15, 2025

@alexhojinpark

Hey there! I noticed the CI checks are failing for formatting (Restyled) and Sonar. Since I don’t have permission to push changes to your branch(@RalphSteinhagen :( ), I wanted to offer some pointers:

Restyled (clang-format): You can apply the suggested formatting locally by running something like:

clang-format -i blocks/basic/include/gnuradio-4.0/basic/And.hpp blocks/basic/test/qa_And.cpp
git commit -am "Apply clang-format suggestions"
git push

This should resolve the restyled check.

Sonar: Sometimes forks can’t access Sonar credentials, so it may be normal for that check to fail from an external PR. You might ask the maintainers(@mormj, @wirew0rm) if it can be ignored or if they have a workaround.

Let me know if you need more details—happy to help walk you through the steps!

@RalphSteinhagen
Copy link
Member

@KrxGu and @alexhojinpark alternatively you can check the GitHub restyled action output that indicates what and how to apply missing restyled diff.

Small edits aside, we cannot fix remote branches (N.B. @alexhojinpark is pushing from his forked repo). That's normal ...

@alexhojinpark
Copy link
Author

@KrxGu @RalphSteinhagen

Thank you for the suggestions. I'll make sure to follow the restyled format, and push with all other Boolean Operators (5 blocks) which I am working on right now. :)

KrxGu added a commit to KrxGu/gnuradio4 that referenced this pull request Apr 16, 2025
@alexhojinpark alexhojinpark force-pushed the alexhp branch 2 times, most recently from e15a9a6 to ca09fd4 Compare April 18, 2025 19:07
@RalphSteinhagen
Copy link
Member

@alexhojinpark do you plan to continue working on this PR? If yes, you may need to rebase against the latest main commit.

Add new logical blocks (AndConst, Not, Or, Xor) to CMakeLists.

Update test files to include new blocks.

Signed-off-by: alexhojinpark <[email protected]>
…d Xor with corresponding tests.

Update CMakeLists to include new tests for these blocks.

Signed-off-by: alexhojinpark <[email protected]>
@alexhojinpark
Copy link
Author

@RalphSteinhagen Yes, I’ve rebased and force-pushed accordingly!

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

Successfully merging this pull request may close these issues.

5 participants