# MyHDL and the NEXYS 2 Board/Basics of Digital Logic

People love to talk about the fact that computers (and more generally, all logic circuits) deal in ones and zeros. With a few provisos (mostly historical by now), that's true, but it doesn't offer too much insight by itself.

In the 19th century, George Boole became interested in what he called the "universal laws of thought which are the basis of all reasoning". He wanted to create mathematics to explore this idea, and devised what we now call Boolean algebra. As with normal algebra, there are variables that can take different values, but the only values they can take are TRUE and FALSE. If we have two boolean variables X and Y, there are only four possible sets of values for them. You should look at the table below and satisfy yourself that you cannot think of any other set of values for X and Y besides those listed.

X | Y |

FALSE | FALSE |

FALSE | TRUE |

TRUE | FALSE |

TRUE | TRUE |

Boolean algebra defines a number of simple operations on these variables. Let's begin by looking at some simple ones, AND, OR, and NOT.

X | Y | X and Y | X or Y | not X | not Y |

FALSE | FALSE | FALSE | FALSE | TRUE | TRUE |

FALSE | TRUE | FALSE | TRUE | TRUE | FALSE |

TRUE | FALSE | FALSE | TRUE | FALSE | TRUE |

TRUE | TRUE | TRUE | TRUE | FALSE | FALSE |

If this table makes sense to you, you are well on your way to a complete understanding of digital logic. There are a few more basic things to know.

- There are other operations, but they are all simple combinations of AND, OR, and NOT. An interesting exercise is to find a "minimal" set of logic operations that can universally define any others. One small set of operations contains only one operator, NAND, which works like this: NAND(X,Y) = NOT(AND(X,Y)). You can define all logic operations in terms of NAND.
- If we assign a voltage for TRUE and another voltage for FALSE, we can build electronic circuits that perform these simple logic operations. These circuits are called "logic gates" or simply "gates".
- If gates are arranged in a larger circuit with all the signals going from left to right (what a mathematician would call an acyclic directed graph), then the circuit as a whole has no memory of the past, and its outputs are purely a function of its inputs in the moment. The computer science equivalent is a purely functional language.
- If we build a larger circuit with cycles, we can store boolean values in circuits called flip flops, and they will persist over time.