Pages created and updated by Terry Sturtevant Date Posted: May 12, 2017

# PC/CP220 Digital Electronics Lab

## Introduction to Logic Analysis using a Computer Algebra System

In this tutorial, we will show you how you can verify logic equations using a Computer Algebra System.

### The Problem

We are designing a circuit for an automatic door like those you see at supermarkets. The door should open only when a person is detected walking through or when a person presses a switch (such as the wheelchair button) to have the door open. The door should only operate if it has been unlocked.

• output: f = 1 (Opens Door)
• inputs
• p = 1 Person Detected
• h = 1 Switch Holding the Door Open
• c = 1 Door Closed/Locked
• Want door to open when
• the door is unlocked and person walking through (c=0 and p=1)
• the door is unlocked and the switch is set to hold it open (c=0 and h=1)
The resulting logic equation is:
f = hc' + pc'

We can verify that this equations works using a CAS (computer algebra system) such as Maple or Maxima. A related system is Wolfram Alpha truth tables.

### Computer Algebra Systems

There are several computer algebra systems. Two common ones are Maple and Maxima. Either one of these can be used for this exercise, although the syntax will be slightly different.
Maple is available on campus, but it's commercial so elsewhere you'd have to pay to use it. Maxima is free, so you can use it at home. There's also a website where you can use it online without downloading anything.
In either system, once you've typed in the equation, you can simply edit the line to substitute values for the inputs for each of the possible combinations without retyping the original equation. This prevents a lot of errors.

#### Maple syntax

At the prompt, type in the the command as shown:
```  f:= (h and not c) or (p and not c);

(h and not c) or (p and not c)

```
You can substitute in specific component values:
``` subs( h=false, c=false, p=false, f);
false
```

Edit and re-execute the previous line for each input combination.

#### Maxima syntax

```
f:(h and not c) or (p and not c);
(h and not c)) or (p and not c)

f,h=false,c=false,p=false;
false
```

Edit and re-execute the previous line for each input combination.

Demonstrate the results to the lab demonstrator.
(Note: If you do it outside the lab, you can print out a transcript of your session and bring it to the lab or save the session and load it in the lab.)

## Resources

If you need to update a browser, you might try Firefox which is
• free
• open source
• available for several platforms

Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is
• free
• open source
• available for several platforms

Go to the main page for the Department of Physics and Computer Science.

Wilfrid Laurier University