Hello World!

 

In this Blog, I would like to share my experience on PYNQ-Z2: Embedded Vision Workshop (Zero to Hero) Series with Adam Taylor!

Getting Started | Getting Up and Running  | Unlocking Your Inner PYNQ Hero  | Project14 | PYNQ Workshop  

and my getting started experience with the PYNQ-Z2 board.

 

Xilinx PYNQ - Z2 FPGA/SoC Board

 

PYNQ is an amazing framework and is an opensource project by Xilinx.

Reach PYNQ website at PYNQ - Python productivity for Zynq - Home

 

Now, coming to the core we'll see how we to create basic logic gates by using Python utility i.e, Jupyter Notebook.

Firstly, login to the Jupyter Notebook from your browser. You may have to assign static IP when connected your board to the computer directly via Ethernet cable. Else, the first boot must run hassle-free if your board is plugged to the router/switch directly(preferred).

 

Simulating Gates:

Logic gates are basic building blocks of digital electronics. Wonderful things happen when hundreds and thousands of them come together in an array. Time being, we'll see how it all starts.

 

1] AND gate

 

The AND gate is a basic digital logic gate that implements logical condition. A HIGH output (1) results only if all the inputs to the AND gate are HIGH (1). If none or not all inputs to the AND gate are HIGH, LOW output results. The function can be extended to any number of inputs.

Use the following commands on your Jupyter Notebook and run line by line.

 

from pynq.overlays.logictools import LogicToolsOverlay   #Initialisations
logictools_olay=LogicToolsOverlay('logictools.bit')
boolean_generator=logictools_olay.boolean_generator

function={'AND_gate':'LD2=PB3&PB0'} #Driver Logic

boolean_generator=logictools_olay.boolean_generator
boolean_generator.setup(function)

boolean_generator.run()

boolean_generator.stop()

 

 

PB0PB3

PB0 and PB3

      (LD2)

000
010
100
111

 

 

 

 

2] OR gate

 

The OR gate is a digital logic gate that implements logical disjunction. A HIGH output (1) results if one or both the inputs to the gate are HIGH (1). If neither input is high, a LOW output (0) results. In another sense, the function of OR effectively finds the maximum between two binary digits, just as the complementary AND function finds the minimum.

Use the following logic on your Jupyter Notebook and run line by line.

 

function={'OR_gate':'LD2=PB3|PB0'}

 

PB0PB3

PB0 or PB3

    (LD2)

000
011
101
111

 

 

 

 

3] NOT gate

 

A NOT Gate outputs a voltage representing the opposite logic-level to its input. Its main function is to invert the input signal applied. If the applied input is low then the output becomes high and vice versa.

Use the following logic on your Jupyter Notebook and run line by line.

 

function={'NOT_gate':'LD2=~~PB0'} #OFF to ON

 

 

PB0

not PB0

(LD2)

10
01

 

 

 

 

4] NAND gate

 

A NAND gate is a logic gate which produces an output which is false only if all its inputs are true; thus its output is a complement of that of an AND gate. LOW (0) output results only if all the inputs to the gate are HIGH (1); if any input is LOW (0), a HIGH (1) output results.

Use the following logic on your Jupyter Notebook and run line by line.

 

function={'NAND_gate':'LD2=~(PB3&PB0)'}

 

PB0PB3

PB0 and PB3

      (LD2)

001
011
101
110

 

 

 

 

5] NOR gate

 

The NOR gate is a digital logic that implements logical NOR. A HIGH output (1) results if both the inputs to the gate are LOW (0); if one or both input is HIGH (1), a LOW output (0) results.

Use the following logic on your Jupyter Notebook and run line by line.

 

function={'NOR_gate':'LD2=~(PB3|PB0)'}

 

PB0PB3

PB0 and PB3

       (LD2)

001
010
100
110

 

 

 

 

6] XOR gate

 

XOR or Exclusive OR is a digital logic gate that gives a true (1 or HIGH) output when the number of true inputs is odd. If both inputs are false (0/LOW) or both are true, false output results. XOR represents the inequality function, i.e., the output is true if the inputs are not alike otherwise the output is false. A way to remember XOR is "must have one or the other but not both".

Use the following logic on your Jupyter Notebook and run line by line.

 

function={'XOR_gate':'LD2=PB3^PB0'}

 

PB0PB3

PB0 and PB3

        (LD2)

000
011
101
110

 

 

 

Further, more complex units like Adders, Subtractors, Multiplexers, Latches, Flipflops etc can be built using these logics. We'll explore more soon. Till then, stay tuned !

 

For more resources, Check out the following:

PYNQ Community forum   @ PYNQ - Python productivity for Zynq - Community

Complete Source code       @ https://github.com/xilinx/pynq

PYNQ workshop resource @ https://github.com/Xilinx/PYNQ_Workshop

Learn all about ZYNQ         @ https://www.youtube.com/user/EMSUNIKL/playlists

                                              @ https://www.youtube.com/user/mamsadegh2/videos

 

 

---------------------------------------------- to be continued!!

 

Thanks to element14 and adamtaylorcengfiet for this thinkstriking  webinar!

 

Regards,

Navadeep Ganesh U