diff --git a/docs/1b/ece124.md b/docs/1b/ece124.md index 398bd02..7cf64e5 100644 --- a/docs/1b/ece124.md +++ b/docs/1b/ece124.md @@ -255,6 +255,17 @@ A **field-programmable gate array** (FPGA) is hardware that does not come with f - logic blocks (that are user-programmed to behave like gates) - lookup tables (LUTs) inside the logic gates, which are a small amount of memory +## Gray code + +The Gray code is a binary number system that has any two adjacent numbers differing by **exactly one bit**. It is used to optimise the number of gates in a function. + +The 1-bit Gray code is $0, 1$. To convert an $n$-bit Gray code to an $n+1$-bit Gray code: + +- Mirror the code: $0,1,1,0$ +- Add $0$ to the original and $1$ to the new ones: $00, 01, 11, 10$ + +Sorting truth table inputs in the order of the Gray code makes optimisation easier to do. + ## VHDL VHDL is a hardware schematic language.