Electrical – Logic circuit equivalent of modulo function with fixed-size inputs and output

boolean-algebracircuit-designdigital-logiclogic-gates

Let \$q\$ be a \$Q\$ bit integer (with bits \$q_1 q_2, …, q_\text{Q}\$)

Let \$p\$ be a \$P\$-bit integer (with bits \$p_1, p_2, …, p_\text{P}\$)

\$Q > P\$ and \$q > p\$

Given \$P\$ and \$Q\$, how would one go about implementing a logic gate circuit to calculate the bits \$[r_1, r_2, …, r_\text{P}]\$ of \$r = q\mod p\$ ? i.e. what is the circuit-equivalent function with \$P+Q\$ binary inputs and \$P\$ binary outputs, i.e

$$[r_1, r_2, …, r_P] \leftarrow \text{moduloCircuit} \left([q_1, q_2, …, q_Q], [p_1, p_2, …, p_P]\right) $$

Does the circuit exist? If not, why not?

Note: We know that \$r\$ is going to have at most \$P\$ bits because the modulo forces \$r < p\$.

Best Answer

If that must be hardware, separate IC is acceptable and the parallel wiring, too, then consider to program a rom.

A gate version can be synthesized from the content of the rom by proper software. Manual synthesis is practical only for small bit counts, say 5 or less.

Surely this is implemented. It"s needed in data communication coding. Today we have incredibly effective processors available for software solutions, but at the highest speeds the coding hardware still has a place.

Related Topic