Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums

Recipe to Demonstrate some Digital Logic Gates

This Script demonstrates how an AND, OR, XOR, NOT, and digital counter work. All the Devices in this Recipe are Virtual Devices, so this Recipe will run on any system without adding additional hardware.

The Script is as follows:

# Builds an oscillator and sets its period to 5 seconds.
# Builds a 2 bit counter.
# Adds a bunch of different logic functions.
# Connects the oscillator to the counter, so counter counts.
# Connects logic inputs to counter outputs, so one can see how they function.

# set up some local constants
OSC_PERIOD = 5 # seconds

# add an oscillator
run_script("Scripts/Device/Virtual/Logic/Active/Oscillator", period:OSC_PERIOD, id:"oscillator")

# add a counter
run_script("Scripts/Device/Virtual/Logic/Sequential/Counter", inputs:"1,2", outputs:"1S,2S", id:"counter")

# add AND, OR, XOR, NOT functions    
run_script("Scripts/Device/Virtual/Logic/Combinational/And", inputs:"1,2", id:"and")
run_script("Scripts/Device/Virtual/Logic/Combinational/Or", inputs:"1,2", id:"or")
run_script("Scripts/Device/Virtual/Logic/Combinational/Xor", inputs:"1,2", id:"xor")
run_script("Scripts/Device/Virtual/Logic/Combinational/Not", id:"not")

# connect the oscillator to the counter
wire "oscillator:out", "counter:clk"

# hook the logic to the counter outputs
wire "counter:1S","and:1"
wire "counter:2S","and:2"
wire "counter:1S","not:in"
wire "counter:1S","or:1"
wire "counter:2S","or:2"
wire "counter:1S","xor:1"
wire "counter:2S","xor:2"

Running the Script

Run the Script above. It will not ask you for any parameters, because it requires none.

Device Explorer Display of Logic Gates Recipe
Logic Gates

After starting the Script got to the Device Explorer page. You will see an "oscillator", "counter", "and", "or", "xor" and "not" Device. Expand the Devices to see their terminals. Click on "Refresh" at the bottom of the page to see the terminal values change (they will update themselves every 5 seconds). If you are familiar with digital logic, you should see examples of the AND, OR, XOR, and NOT functions.

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2018)

Page last updated: Thu Apr 3 02:20:48 2014 (UTC)