element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Gering Up with PYNQ-Z2 ! - Logic Gates
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: navadeepganeshu
  • Date Created: 12 May 2020 10:56 AM Date Created
  • Views 1295 views
  • Likes 1 like
  • Comments 0 comments
  • pynq-z2
  • fpga
  • logic design
  • verilog
  • pynqstarter
  • pynqrunner
  • workshop
Related
Recommended

Gering Up with PYNQ-Z2 ! - Logic Gates

navadeepganeshu
navadeepganeshu
12 May 2020

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 image 

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

 

image

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

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

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

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

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube