1. Trang chủ
  2. » Giáo án - Bài giảng

Discrrete mathematics for computer science 07logic and computers

12 126 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 12
Dung lượng 871,5 KB

Nội dung

Logic and computers 2/6/12 Binary Arithmetic Only two digits: the bits and (Think: = F, = T) +0 -0 2/6/12 +1 -1 +0 -1 +1 -10 Logic and Computers  A half adder:  Two bits in (A, B: to be added together)  Two bits out (S, C: sum and carry)  0+0=0, carry  0+1=1, carry  1+0=1, carry  1+1=0, carry  S := A⊕B  C := A∧B 2/6/12 NOT 2/6/12 OR NOR AND NAND XOR NXOR (EQUIV) Logic and Computers • S := A⊕B A S B • C := A∧B 2/6/12 C Half Adder A S B HA C A S B C 2/6/12 A Longer Addition 11 11 +11 110 2/6/12 Full Adder • Need a third input to create a component of a ripple-carry adder: the carry from the previous bit position • Inputs: A, B, Cin • Outputs: S, Cout 2/6/12 A B Cin S Cout 0 0 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 Full Adder Cin S HA A B HA 2/6/12 A B Cin S Cout 0 0 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 Cout Full Adder Cin S A Cin S FA B C out HA A HA B 2/6/12 Cout Ripple carry adder • 2-bit adder: a1a2+b1b2 = c1c2 with carryout c2 a2 b2 FA a1 b1 FA c1 carryout • Generalizes to n-bit addition • How does the time delay through the circuit depend on n, the number of bits to be added? 2/6/12 Simplifying Circuits • Simpler formulas turn into circuits that use less hardware! • E.g p ⋁ q ⋁ (p⋀q) is equivalent to p ⋁ q but would use more logic gates • But the P=NP? question means that it may be hard to simplify formulas as much as possible – Any tautology is equivalent to p ⋁ ¬p so if we could easily simplify formulas we could easily determine whether a formula is a tautology 2/6/12 ... digits: the bits and (Think: = F, = T) +0 -0 2/6/12 +1 -1 +0 -1 +1 -10 Logic and Computers  A half adder:  Two bits in (A, B: to be added together)  Two bits out (S, C: sum and carry)  0+0=0,...  1+0=1, carry  1+1=0, carry  S := A⊕B  C := A∧B 2/6/12 NOT 2/6/12 OR NOR AND NAND XOR NXOR (EQUIV) Logic and Computers • S := A⊕B A S B • C := A∧B 2/6/12 C Half Adder A S B HA C A S B C 2/6/12... Simpler formulas turn into circuits that use less hardware! • E.g p ⋁ q ⋁ (p⋀q) is equivalent to p ⋁ q but would use more logic gates • But the P=NP? question means that it may be hard to simplify formulas

Ngày đăng: 22/03/2019, 10:41

TỪ KHÓA LIÊN QUAN