Answered

How to encapsulate circuit built with logic gates

The factoring example shows how to build a multiplication circuit with logic gates.

I've written a program that builds a circuit with xor gates to compute an 8-bit cyclic redundancy check.  The input bits can be specified and the output bits left unfixed to run the circuit forward, or the output bits can be specified and the input bits left unfixed to run the circuit backward.  It works with a single input octet.

I'd like to encapsulate the circuit so that I can chain multiple circuits together, feeding output of one to input of another, and thereby calculate CRC8 of multiple input data octets.

Could the developers offer any advice about how to encapsulate the circuit?

I'm studying the implementations of logic gates in dwavebinarycsp / dwavebinarycsp / factories / constraint / gates.py and of the multiplication circuit in dwavebinarycsp / dwavebinarycsp / factories / csp / circuits.py.

I would love to see the multiplication circuit code in circuits.py annotated more extensively to explain exactly what is going on.  Ditto for one of the logic gate functions in gates.py.

Thank you.

1

Comments

5 comments
  • Building a circuit with logic gates involves naming the input and output bits, which are mapped to logical qubits and then to physical qubits.  Values can be extracted by name from the unembedded responses from the QPU.  I've been a bit puzzled about how to encapsulate a circuit so that it can be used more than once in a program.  Now I think I see how.  The function that constructs the circuit needs to take the names of the inputs and outputs as parameters, and the caller needs to specify different names each time the function is called.  E.g.:

    For the circuit that takes the first input data octet (call it d) and computes the first crc8 octet (call it c), the bit/qubit names could be:

    ['d0.0', 'd0.1', ... 'd0.7', 'c0.0', 'c0.1', ... 'c0.7']

    For the circuit that processes the second octet, the names could be:

    ['d1.0', 'd1.1', ... 'd1.7', 'c1.0', 'c1.1', ... 'c1.7']

    Does this make sense?  I'm going to try it.

    1
    Comment actions Permalink
  • Hi Scott,

    I believe you are on the right track. Let us know how it goes!

    I also agree with your comment that the circuits/gates need better documentation. I have made a github issue to that effect https://github.com/dwavesystems/dwavebinarycsp/issues/51 

    Alex

    1
    Comment actions Permalink
  • Hi Alex,

    The approach I hinted at above works beautifully. I plan to put code and a writeup on my GitHub page in case it's helpful to others.

    Cheers,

    Scott

    1
    Comment actions Permalink
  • Hi Scott,

    Have you achieved success in this task?

     

    0
    Comment actions Permalink
  • Hi Jacob,

    Yes.  For an example, please look at this project I published on GitHub.

    https://github.com/myriagon/quantum_crc8

    I'd like to know what you think of it.

    Scott

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post