Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside the ALU module, it is not allowed to use sequential process. so I tried to use one method from herehere:

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside the ALU module, it is not allowed to use sequential process. so I tried to use one method from here:

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside the ALU module, it is not allowed to use sequential process. so I tried to use one method from here:

Corrected base notation for clarity
Source Link
user1155120
user1155120

Here is an simple way to do it by hand. Since 1 = 22 mod 3, we get 1 = 22n mod 3 for every positive integer. Furthermore 2 = 22n+1 mod 3. Hence one can determine if an integer is divisible by 3 by counting the 1 bits at odd bit positions, multiply this number by 2, add the number of 1-bits at even bit posistions add them to the result and check if the result is divisible by 3.

Example: 5710=11100125710=1110012. There are 2 bits at odd positions, and 2 bits at even positions. 2*2 + 2 = 6 is divisible by 3. Hence 57 is divisible by 3.

Here is an simple way to do it by hand. Since 1 = 22 mod 3, we get 1 = 22n mod 3 for every positive integer. Furthermore 2 = 22n+1 mod 3. Hence one can determine if an integer is divisible by 3 by counting the 1 bits at odd bit positions, multiply this number by 2, add the number of 1-bits at even bit posistions add them to the result and check if the result is divisible by 3.

Example: 5710=1110012. There are 2 bits at odd positions, and 2 bits at even positions. 2*2 + 2 = 6 is divisible by 3. Hence 57 is divisible by 3.

Here is an simple way to do it by hand. Since 1 = 22 mod 3, we get 1 = 22n mod 3 for every positive integer. Furthermore 2 = 22n+1 mod 3. Hence one can determine if an integer is divisible by 3 by counting the 1 bits at odd bit positions, multiply this number by 2, add the number of 1-bits at even bit posistions add them to the result and check if the result is divisible by 3.

Example: 5710=1110012. There are 2 bits at odd positions, and 2 bits at even positions. 2*2 + 2 = 6 is divisible by 3. Hence 57 is divisible by 3.

added 5 characters in body
Source Link
manpmanp
  • 59
  • 2
  • 6

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside the ALU madulemodule, it is not allowed to use sequential process. so I tried to use one method from here:

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside ALU madule it is not allowed to use sequential process. so I tried to use one method from here:

I am working on a project which one part pivots around finding X mod 3 with and FPGA spartan 3 (Xilinx), inside a combinatorial process. in fact in this project there are some other modules which are sequential, before this ALU module. but inside the ALU module, it is not allowed to use sequential process. so I tried to use one method from here:

Source Link
manpmanp
  • 59
  • 2
  • 6
Loading