Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1...

23
2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 – Digital Electronics 1 There are 10 kinds of people in this world: © Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission Those who understand binary, and those who don’t. 2/26/20 2 2

Transcript of Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1...

Page 1: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

1

Lecture-1Number Systems

Dr. Sajid Muhaimin ChoudhuryDept of EEE, BUET

EEE 303 – Digital Electronics

1

There are 10 kinds of people in this world:

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

Those who understand binary, and those who don’t.

2/26/20 2

2

Page 2: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

2

Number system: DecimalDecimal: Deca (ten)

Each subsequent digit a multiplier of 10

Base: 10

Symbols:0123456789

7651107650

765

1N/10 Q R

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

765/10 76 5

76/10 7 67/10 0 7

7 6 5 1|102/26/20 3

3

61.255✕10-22✕10-11✕1006✕101

1✕100

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 4

4

Page 3: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

3

Number of Fingers

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 5

5

Number system: Binary

Binary: Bi (two)Each subsequent digit a multiplier of 2Base: 2

Symbols:01, TF

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

N/2 Q R13/2 6 1

6/2 3 03/2 1 11/2 0 1

13|10 = 1101|2

2/26/20 6

6

Page 4: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

4

Base-n Number system

• The system uses n different symbols• Each subsequent digit: n-times • For this course we denote a number, N with it’s base as N|n, n is denoted in decimal

• For n<10, we use symbols as 0-9, and for n>10 we use symbols as ABCD…

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 7

7

Base-8 and Base-16

• Base-8• Octal• Symbols: 01234567

• Base-16• Hexadecimal• Symbols: 0123456789ABCDEF

• F|16 = 15|10

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 8

8

Page 5: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

5

Base conversion from Decimal

230/8 28 328/8 3 13/8 0 3

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

N/8 Q R

230|10

230|10 = 313|8

Octal

230/16 14 314/16 0 14(E)

N/16 Q R

230|10 = E3|16 = E3H

Hexadecimal

2/26/20 9

9

Base conversion to Decimal

0 ✕ 80 = 03 ✕ 81 = 242 ✕ 82 = 128

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

230|8

230|8 = 152|10

Octal Hexadecimal

152

4 ✕ 160 = 415 ✕ 161 = 2401 ✕ 162 = 256

1F4|16

1F4|16 = 500|10

500

2/26/20 10

10

Page 6: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

6

Table of ValuesDec Bin Oct Hex

0 0000 0 0

1 0001 1 1

2 0010 2 2

3 0011 3 3

4 0100 4 4

5 0101 5 5

6 0110 6 6

7 0111 7 7

8 1000 10 8

9 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F© Dr. S. M. Choudhury, EEE, BUET. Please do

not redistribute without prior permission

10|8 = 001 000|2

11|8 = 001 001|2

2/26/20 11

11

For Oct, each digit represents 3 bits, and for Hex each digit represent 4 bits. Can be used to compactly visualize digital data

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

001101010|2

001 101 010|2 = 152|81 5 2

0110 1010|2 = 6A|86 A

2/26/20 12

12

Page 7: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

7

Binary Addition, Subtraction, Multiplication and Division

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 13

13

Signed number

• A signed binary number consists of both sign and magnitude information.

• Three formats:• sign-magnitude• 1’s complement• 2’s complement.

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 14

14

Page 8: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

8

Signed Number

• Sign-Magnitude Format

• 1’s Complement Format

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 15

15

• 2’s Complement Format• 1’s Complement + 1

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

+10 1 0 0 1 1 1 0

2/26/20 16

16

Page 9: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

9

Floating Point Number

• Binary floating point number

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

mantissa exponent

2/26/20 17

17

• Single Precision Representation

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 18

18

Page 10: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

10

Binary Codes

• Binary Coded Decimal (BCD)• Grey Code• Hamming Code

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 19

19

Grey Code

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

exhibits only a single bit change from one code word to the next in sequence

2/26/20 20

20

Page 11: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

11

ASCII

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 21

21

Hardware Description Languages

22

Page 12: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

12

Hardware Description Language

• Describes structure and behaviorof electronic circuits

• Two most popular HDL are Verilog and VHDL

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 23

23

Verilog vs VHDLVerilog VHDLMore “C” like Non “C” like. Ada basedPartially deterministic Very deterministicLow verbosity High verbosityWeakly typed Strongly typedASIC Design FPGA DesignMore common in large firms

More common in hobbistcommunity

Standardized by Cadence Developed by US DOD

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 24

24

Page 13: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

13

Verilog Compiler Suite

• Proprietary:

• Open Source:

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

• Expensive or free with limitation

• Device support• Vendor locking

• Free to use (commercially and university wide)

• Community support• No Vendor locking

2/26/20 25

25

Intel Quartus

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 26

26

Page 14: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

14

• Install the Intel Quartus Prime Lite edition from the website: https://fpgasoftware.intel.com/?edition=lite

• Version I am using here is 18.1(Please use the version that is shown in your lab sheet)

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 27

27

Click on new Project

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 28

28

Page 15: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

15

Click through the steps

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission

1 2

3

2/26/20 29

29

Select Device (please consult your labsheet for details)

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 30

30

Page 16: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

16

[Important!] Select the tools for simulating the code

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 31

31

Click Finish

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 32

32

Page 17: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

17

Click New, and select Verilog HDL file

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 33

33

Code for the Verilog file

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 34

34

Page 18: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

18

Save the file and click “StartCompilation”

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 35

35

On the left side, you can see the compilation progress

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 36

36

Page 19: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

19

After compilation, click File>New and select “VWF” file

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 37

37

The VWF editor will open

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 38

38

Page 20: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

20

Click Edit>Grid Size, set Period to 1us

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 39

39

Click Edit>Set End Time, set End Time to 16us

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 40

40

Page 21: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

21

Right Click on the “Name” region and select “Insert Node or Bus”

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 41

41

Click List, select d and press >, again select q and press >

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 42

42

Page 22: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

22

Click and select d, and right click on the waveform. Click “Value”>”Count Value”

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 43

43

Set Count every 1us, and click okay

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 44

44

Page 23: Lecture-1 Number Systemssajid.buet.ac.bd/courses/EEE_303_2020/Lecture_2-3.pdf · 2/26/20 1 Lecture-1 Number Systems Dr. Sajid Muhaimin Choudhury Dept of EEE, BUET EEE 303 –Digital

2/26/20

23

Input of the circuit is created. Now click on Run Functional Simulation

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 45

45

Simulation result is shown. The code converts input into 2’s complement

© Dr. S. M. Choudhury, EEE, BUET. Please do not redistribute without prior permission2/26/20 46

46