Digital Logic: Moore's Law, Logic Gates, and Number Systems

Classified in Computers

Written at on English with a size of 708.55 KB.

Lecture 1: Moore's Law

Moore's Law: The number of transistors on microchips doubles every two years.

Lecture 2: Logic Gates

I7WgAAAABJRU5ErkJggg==

i3AAAAABJRU5ErkJggg==

+NnQQWHnrkU5hEgARmEjCXFieBuVQxHFZoESCBhRZfu1ongdmFNPtxFQIkMFepI+jBkMCCho4VvYwACczL2qMNLDy0x6cIGoEjR45Iq1atZNWqVbqNnTt3SpUqVYJujxWdQYArMGdwZ68OI4AY19dff10GDBggbdu2lblz50p8fLzDo2L3ZhEggZlFjOXDBgEEmaekpEhcXBzJy6NaJYF5VHEcNhEgAiIkMM4CIkAEPIsACcyzquPAiQARIIFxDhABIuBZBEhgnlUdB04EiAAJjHOACBABzyJAAvOs6jhwIkAESGCcA0SACHgWARKYZ1XHgRMBIkAC4xwgAkTAswiQwDyrOg6cCBABEhjnABEgAp5FgATmWdVx4ESACJDAOAeIABHwLAIkMM+qjgMnAkSABMY5QASIgGcRIIF5VnUcOBEgAiQwzgEiQAQ8iwAJzLOq48CJABEggXEOEAEi4FkESGCeVR0HTgSIAAmMc4AIEAHPIkAC86zqOHAiQAT+DyAtVcWtdpgpAAAAAElFTkSuQmCC

PKhJg4vKJJngcj4CICTBwugs1dMQJeQYCJwyua5HkwAi4iwMThItjcFSPgFQSYOLyiSZ4HI+AiAkwcLoLNXTECXkGAicMrmuR5MAIuIsDE4SLY3BUj4BUEmDi8okmeByPgIgJMHC6CzV0xAl5BgInDK5rkeTACLiLAxOEi2NwVI+AVBJg4vKJJngcj4CICTBwugs1dMQJeQYCJwyua5HkwAi4iwMThItjcFSPgFQSYOLyiSZ4HI+AiAkwcLoLNXTECXkGAicMrmuR5MAIuIsDE4SLY3BUj4BUEmDi8okmeByPgIgJMHC6CzV0xAl5BgInDK5rkeTACLiLAxOEi2NwVI+AVBP4HSdmP4LA25GYAAAAASUVORK5CYII=

5hQAAAAASUVORK5CYII=

eg8CIAACIAACfhGAQPiFDYVAAARAAARAwNkEIBDOjj96DwIgAAIgAAJ+EYBA+IUNhUAABEAABEDA2QT+D4sjTswCubX7AAAAAElFTkSuQmCC

o3LOcXr2Tof4HmKwTSBU6n03g8Hv9jfn5+pseNz2fo4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXaBf18koFmMFdorAAAAAElFTkSuQmCC

wFbJNthuSOezwAAAABJRU5ErkJggg==

AND, OR, and NOT gates are universal.

Logic word problem steps:

Example: In a bank, there were four employees: the bank manager, assistant manager, teller, and the security guard. The bank has a single vault for the storage of their money. This vault was designed so that it needs four signals to open it. These four signals are from the bank manager, assistant manager, teller, and the security guard. For the vault to open, it needs the following conditions:

  1. No single employee can open the vault.
  2. It can be opened with three employees as long as one of them is the manager.
  3. It can be opened by the manager together with the assistant manager.

Step 1: Assign logic symbols to the output:

  • Vault Open (Logic 1 = V)
  • Vault Closed (Logic 0 = /V)

Step 2: Assign logic symbols to the inputs:

  • A = Manager (Logic 1 = A, Logic 0 = /A)
  • B = Assistant Manager (Logic 1 = B, Logic 0 = /B)
  • C = Teller (Logic 1 = C, Logic 0 = /C)
  • D = Security Guard (Logic 1 = D, Logic 0 = /D)

Step 3: Formulate all functions that would result in Logic 1 or opening of the vault.

Condition 1: No single employee can open the vault. This condition does not result in opening the vault.

Condition 2: Can be opened with three employees as long as one of them is the manager.

  • A/BCD = (assistant manager did not open)
  • AB/CD = (teller did not open)
  • ABC/D = (security guard did not open)
  • ABCD = (all employees open it)

GtwABkAAJkAAJkAAJkAAJkAAJkAAJkAAJkIB3BGg+eceWK5MACZAACZAACZAACZAACZAACZAACZCA8QT+Hx6sRngtdAkuAAAAAElFTkSuQmCC

cUAwAAAAASUVORK5CYII=

wOyiDGSSxFnQwAAAABJRU5ErkJggg==

Verilog Operators

Verilog operators and meanings

Arithmetic Operators (Basic Math Operations)

  • + → Addition (Example: y = a + b; // Adds a and b)
  • - → Subtraction (Example: y = a - b; // Subtracts b from a)
  • * → Multiplication (Example: y = a * b; // Multiplies a and b)
  • / → Division (Example: y = a / b; // Divides a by b)
  • % → Modulus (Remainder) (Example: y = a % b; // Gives remainder of a / b)

Bitwise Operators (Operate on Individual Bits)

  • & → Bitwise AND (Example: y = a & b; // 1 only if both bits are 1)
  • | → Bitwise OR (Example: y = a | b; // 1 if at least one bit is 1)
  • ^ → Bitwise XOR (Exclusive OR) (Example: y = a ^ b; // 1 if bits are different)
  • ~ → Bitwise NOT (Inversion) (Example: y = ~a; // Flips all bits)

Logical Operators (Used in Conditions: True/False Evaluations)

  • && → Logical AND (Example: if (a && b) // True only if both a and b are nonzero)
  • || → Logical OR (Example: if (a || b) // True if at least one is nonzero)
  • ! → Logical NOT (Example: if (!a) // True if a is 0)

Shift Operators (Move Bits Left or Right)

  • >> → Right Shift (Example: y = a >> 2; // Moves bits right, dividing by 2²)

Lecture 4: Number Systems

Decimal Numbers

3FPYnQWFojIAAAAASUVORK5CYII=

Binary Numbers

6oDuf8+avGAAAAAASUVORK5CYII=

Binary Numbers (Base 2)

  • Prefix: 0b Example: 0b0010_1101 Subscript: 2 Example with Subscript: 0010_1101₂

Decimal Numbers (Base 10)

  • Prefix: 0d (or blank) Example in Verilog: 0d45 or 45 Example with Subscript: 45₁₀

If there is no prefix or subscript, the default is decimal.

Binary To Decimal: (base 10 decimal)

ex. 0b1101 = (1*2^3)+(1*2^2)+(0*2^1)+(1*2^0)

(1*8)+(1 × 4) + (0 × 2) + (1 × 1) = 8 + 4 + 0 + 1 = 13

0b1101 = 13₁₀

Decimal To Binary: (base 2 binary)

ex. 30₁₀ to binary

30 ÷ 2 = 15, remainder 0 | 15 ÷ 2 = 7, remainder 1 | 7 ÷ 2 = 3, remainder 1 |

3 ÷ 2 = 1, remainder 1 | 1 ÷ 2 = 0, remainder 1 === 0b11110 (add 0b at the end and make sure to list the binaries from bottom to top)

Binary to Hex - (base 16 hex)

ex. 30₁₀ to hex

Successive Division method -

30/16 = 1 remainder 14(E)

1/16 = 0 remainder 1

list from bottom to top

=0x1E or 1E base 16

Convert binary to decimal

Convert 1100 base 2 to decimal

1 * 2^3 + 1 * 2^2 + 0 * 2^1 + 0*2^0 = 8 + 4 = 12

Convert hex to decimal

Convert 0x2F (2F base 16) to decimal

(2 * 16^1) + (F(15)*16^0)

2 x 16 + 15 x 1 = 47

Signed bit to decimal

convert signed (0b11101) to Decimal

the MSB is the sign bit - 0 = positive 1 = negative 0b11101

ignore the sign bit (focus on 1101 base 2)

(1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0)

= 8 + 4 + 0 + 1 = 13

since 1 was the msb, we turn it into -13

Hex | Decimal | Binary
------------------------
0x0 | 0 | 0000
0x1 | 1 | 0001
0x2 | 2 | 0010
0x3 | 3 | 0011
0x4 | 4 | 0100
0x5 | 5 | 0101
0x6 | 6 | 0110
0x7 | 7 | 0111
0x8 | 8 | 1000
0x9 | 9 | 1001
0xA | 10 | 1010
0xB | 11 | 1011
0xC | 12 | 1100
0xD | 13 | 1101
0xE | 14 | 1110
0xF | 15 | 1111

MSB and LSB

Most Significant Bit (MSB) - This bit has the highest value (greatest weight) and is located at the far left of the bit string

Least Significant Bit (LSB) - This bit has the lowest value (bit position zero) and is located at the far right of the bit string.

Bit width: Number of binary digits (bits) used to represent a value in a computer system.

D9URGKY4KhRhgAAAABJRU5ErkJggg==

Hex digits = Nibbles = 4 bits

Bytes = 8 bits

Words = 32 bits = 4 bytes

Two's Complement:

0b10011 to decimal

-2^4 + 0 + 0 + 2^2 + 2^1 + 2^0

-16 + 3 = -13

Example: What is -7 in Two’s Complement Binary?

"take the two's complement of a number"

firstly convert the number to binary

Step 1: 0b0111 ---- starting point

Step 2: 0b1000 ----- switch the 1s and zeros (negate)
Step 3: 0b1001 ----- add a 1 at the end

Example: Perform 26-7 in binary

26 = 0b01_1010

7 = 0b00_0111

-7 = 0b11_1000 → 0b11_1001 (Negative 7 in 2’s comp)

011010 + 111001(this number is the 7 converted to -7 in binary) = 010011 (19)

remember when adding binary numbers 1 + 1 = 0

Entradas relacionadas: