III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Working with combinational logic Simplification  two-level.

Slides:



Advertisements
Similar presentations
Chapter 3 Gate-Level Minimization
Advertisements

Boolean Algebra and Reduction Techniques
ECE C03 Lecture 31 Lecture 3 Two-Level Logic Minimization Algorithms Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Boolean Algebra and Combinational Logic
ECE C03 Lecture 21 Lecture 2 Two Level Minimization Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
ECE 331 – Digital System Design
Gate-Level Minimization
Chapter # 3: Multi-Level Combinational Logic
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 6 Dr. Shi Dept. of Electrical and Computer Engineering.
CS 151 Digital Systems Design Lecture 11 NAND and XOR Implementations.
CSE 370 – Winter 2002 – Logic minimization - 1 Overview zLast lecture yExamples of Karnaugh maps, including Don’t cares zToday yDesign Examples yPrime.
Chapter 3 Simplification of Switching Functions
ENGIN112 L11: NAND and XOR Implementation September 26, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 11 NAND and XOR Implementations.
Lecture 5 Multilevel Logic Synthesis
Give qualifications of instructors: DAP
Gate Logic: Two Level Canonical Forms
Contemporary Logic Design Two-Level Logic © R.H. Katz Transparency No. 3-1 Chapter #2: Two-Level Combinational Logic Section 2.1, Logic Functions.
Contemporary Logic Design Two-Level Logic © R.H. Katz Transparency No. 4-1 Chapter #2: Two-Level Combinational Logic Section 2.3, Switches and Tools.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 3 – Combinational Logic Design Part 1 –
بهينه سازي با نقشة کارنو Karnaugh Map. 2  Method of graphically representing the truth table that helps visualize adjacencies 2-variable K-map 3-variable.
Overview Part 1 – Design Procedure 3-1 Design Procedure
Chapter 2: Boolean Algebra and Logic Functions
Unit 7 Multi-Level Gate Circuits / NAND and NOR Gates Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information.
CSET 4650 Field Programmable Logic Devices
Chapter # 3: Multi-Level Combinational Logic
Overview of Chapter 3 °K-maps: an alternate approach to representing Boolean functions °K-map representation can be used to minimize Boolean functions.
KU College of Engineering Elec 204: Digital Systems Design
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Lecture 12 – Design Procedure.
BOOLEAN ALGEBRA Saras M. Srivastava PGT (Computer Science)
1 Lecture 10 PLDs  ROMs Multilevel logic. 2 Read-only memories (ROMs) Two dimensional array of stored 1s and 0s  Input is an address  ROM decodes all.
Boolean Algebra and Digital Circuits
B-1 Appendix B - Reduction of Digital Logic Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Digital Electronics Tutorial: Combinational Logic Design Examples
1 Simplification of Boolean Functions:  An implementation of a Boolean Function requires the use of logic gates.  A smaller number of gates, with each.
Chapter 3 Simplification of Switching Functions. Simplification Goals Goal -- minimize the cost of realizing a switching function Cost measures and other.
Department of Computer Engineering
Combinational Logic Design BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
9/16/04UCB EECS150 D. Culler Fa04 1 EECS Components and Design Techniques for Digital Systems Lec 06 – Minimizing Boolean Logic 9/16-04 David Culler.
Gate-Level Minimization Chapter 3. Digital Circuits The Map Method The complexity of the digital logic gates the complexity of the algebraic expression.
Two-Level Simplification Approaches Algebraic Simplification: - algorithm/systematic procedure is not always possible - No method for knowing when the.
October 29, 2015 EASTERN MEDITERRANEAN UNIVERSITY1 Digital Logic Design I Gate-Level Minimization Mustafa Kemal Uyguroğlu.
Module 1.2 Introduction to Verilog
2-1 Introduction Gate Logic: Two-Level Simplification Design Example: Two Bit Comparator Block Diagram and Truth Table A 4-Variable K-map for each of the.
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 4: Logic Optimization Chapter 4.
Gate-Level Minimization
Chapter 2 Two- Level Combinational Logic. Chapter Overview Logic Functions and Switches Not, AND, OR, NAND, NOR, XOR, XNOR Gate Logic Laws and Theorems.
Multi-Level Gate Networks NAND and NOR Gates
LOGIC GATES & BOOLEAN ALGEBRA
1 K-Maps, Multi-level Circuits, Time Response Today: Reminder: Test #1, Thu 7-9pm K-map example, espressoFirst Hour: K-map example, espresso –Section 2.3.
Lecture 09 NAND and XOR Implementations. Overview °Developing NAND circuits °Two-level implementations Convert from AND/OR to NAND (again!) °Multi-level.
Computer Arithmetic, K-maps Prof. Sin-Min Lee Department of Computer Science.
1 Chapter 3 working with combinational logic. 2 Working with combinational logic Simplification  two-level simplification  exploiting don’t cares 
Boolean Algebra and Reduction Techniques
No. 3-1 Chapter # 3: Multi-Level Combinational Logic.
Digital Logic (Karnaugh Map). Karnaugh Maps Karnaugh maps (K-maps) are graphical representations of boolean functions. One map cell corresponds to a row.
Chapter 3 Simplification of Switching Functions. Simplification Goals Goal -- minimize the cost of realizing a switching function Cost measures and other.
1 CS 352 Introduction to Logic Design Lecture 4 Ahmed Ezzat Multi-level Gate Circuits and Combinational Circuit Design Ch-7 + Ch-8.
©2010 Cengage Learning SLIDES FOR CHAPTER 8 COMBINATIONAL CIRCUIT DESIGN AND SIMULATION USING GATES Click the mouse to move to the next page. Use the ESC.
K-maps and Decoders Prof. Sin-Min Lee Department of Computer Science.
Digital Systems Design 1 Signal Expressions Multiply out: F = ((X + Y)  Z) + (X  Y  Z) = (X  Z) + (Y  Z) + (X  Y  Z)
Hardware Description Languages: Verilog
Combinational Logic Implementation
Boolean Algebra and Combinational Logic
Hardware Description Languages: Verilog
BASIC & COMBINATIONAL LOGIC CIRCUIT
Overview Last Lecture Conversion of two-level logic to NAND or NOR forms Multilevel logic AOI and OAI gates Today Timing and hazards Multiplexers and demultiplexers.
Digital Logic & Design Dr. Waseem Ikram Lecture 13.
CSE 370 – Winter Combinational Implementation - 1
Digital Logic Design I Gate-Level Minimization
Spring Combinational Logic - 1
Presentation transcript:

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Working with combinational logic Simplification  two-level simplification  exploiting don’t cares  algorithm for simplification Logic realization  two-level logic and canonical forms realized with NANDs and NORs  multi-level logic, converting between ANDs and ORs Time behavior Hardware description languages

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 2 we'll need a 4-variable Karnaugh map for each of the 3 output functions Design example: two-bit comparator block diagram LT EQ GT A B C D A B C D N1 N2 ABCDLTEQGT and truth table

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 3 A' B' D + A' C + B' C D B C' D' + A C' + A B D' LT= EQ= GT= K-map for EQK-map for LTK-map for GT Design example: two-bit comparator (cont’d) D A B C D A B C D A B C = (A xnor C) (B xnor D) LT and GT are similar (flip A/C and B/D) A' B' C' D' + A' B C' D + A B C D + A B' C D’

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 4 two alternative implementations of EQ with and without XOR XNOR is implemented with at least 3 simple gates Design example: two-bit comparator (cont’d)

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 5 block diagram and truth table 4-variable K-map for each of the 4 output functions A2A1B2B1P8P4P2P Design example: 2x2-bit multiplier P1 P2 P4 P8 A1 A2 B1 B2

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 6 K-map for P8 K-map for P4 K-map for P2K-map for P1 Design example: 2x2-bit multiplier (cont’d) B1 A A1 B B1 A A1 B B1 A A1 B B1 A A1 B2 P8 = A2A1B2B1 P4= A2B2B1' + A2A1'B2 P2= A2'A1B2 + A1B2B1' + A2B2'B1 + A2A1'B1 P1= A1B1

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 7 I8I4I2I1O8O4O2O XXXX 1011XXXX 1100XXXX 1101XXXX 1110XXXX 1111XXXX block diagram and truth table 4-variable K-map for each of the 4 output functions O1 O2 O4 O8 I1 I2 I4 I8 Design example: BCD increment by 1

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 8 O8 = I4 I2 I1 + I8 I1' O4 = I4 I2' + I4 I1' + I4’ I2 I1 O2 = I8’ I2’ I1 + I2 I1' O1 = I1' O8 O4 O2 O1 Design example: BCD increment by 1 (cont’d) 00 X1X0X1X0 I1 I XX I4 I2 01 X0X0X0X0 I1 I801 XX I4 I X0X0X0X0 I1 I XX I4 I2 10 X1X0X1X0 I1 I801 XX I4 I2

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 9 Definition of terms for two-level simplification Implicant  single element of ON-set or DC-set or any group of these elements that can be combined to form a subcube Prime implicant  implicant that can't be combined with another to form a larger subcube Essential prime implicant  prime implicant is essential if it alone covers an element of ON-set  will participate in ALL possible covers of the ON-set  DC-set used to form prime implicants but not to make implicant essential Objective:  grow implicant into prime implicants (minimize literals per term)  cover the ON-set with as few prime implicants as possible (minimize number of product terms)

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 10 0X110X D A B C 5 prime implicants: BD, ABC', ACD, A'BC, A'C'D Examples to illustrate terms D A B C 6 prime implicants: A'B'D, BC', AC, A'C'D, AB, B'CD minimum cover: AC + BC' + A'B'D essential minimum cover: 4 essential implicants essential

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 11 Algorithm for two-level simplification Algorithm: minimum sum-of-products expression from a Karnaugh map  Step 1: choose an element of the ON-set  Step 2: find "maximal" groupings of 1s and Xs adjacent to that element consider top/bottom row, left/right column, and corner adjacencies this forms prime implicants (number of elements always a power of 2)  Repeat Steps 1 and 2 to find all prime implicants  Step 3: revisit the 1s in the K-map if covered by single prime implicant, it is essential, and participates in final cover 1s covered by essential prime implicant do not need to be revisited  Step 4: if there remain 1s not covered by essential prime implicants select the smallest number of prime implicants that cover the remaining 1s

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 12 X101X D A 0X010X01 X001X001 B C 3 primes around AB'C'D' Algorithm for two-level simplification (example) X101X D A 0X010X01 X001X001 B C 2 primes around A'BC'D' X101X D A 0X010X01 X001X001 B C 2 primes around ABC'D X101X D A 0X010X01 X001X001 B C minimum cover (3 primes) X101X D A 0X010X01 X001X001 B C X101X D A 0X010X01 X001X001 B C 2 essential primes X101X D A 0X010X01 X001X001 B C

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 13 Activity X001X001 X0X1X0X1 D A 0XX10XX1 X011X0111 B C BC BD AB AC’D CD’ BDCD’AC’D BDCD’AC’D List all prime implicants for the following K-map: Which are essential prime implicants? What is the minimum cover? X001X001 X0X1X0X1 D A 0XX10XX1 X011X0111 B C

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 14 Implementations of two-level logic Sum-of-products  AND gates to form product terms (minterms)  OR gate to form sum Product-of-sums  OR gates to form sum terms (maxterms)  AND gates to form product

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 15 Two-level logic using NAND gates Replace minterm AND gates with NAND gates Place compensating inversion at inputs of OR gate

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 16 Two-level logic using NAND gates (cont’d) OR gate with inverted inputs is a NAND gate  de Morgan’s:A’ + B’ = (A B)’ Two-level NAND-NAND network  inverted inputs are not counted  in a typical circuit, inversion is done once and signal distributed

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 17 Two-level logic using NOR gates Replace maxterm OR gates with NOR gates Place compensating inversion at inputs of AND gate

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 18 Two-level logic using NOR gates (cont’d) AND gate with inverted inputs is a NOR gate  de Morgan’s:A’ B’ = (A + B)’ Two-level NOR-NOR network  inverted inputs are not counted  in a typical circuit, inversion is done once and signal distributed

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 19 Two-level logic using NAND and NOR gates NAND-NAND and NOR-NOR networks  de Morgan’s law:(A + B)’= A’ B’(A B)’ = A’ + B’  written differently: A + B= (A’ B’)’(A B) = (A’ + B’)’ In other words ––  OR is the same as NAND with complemented inputs  AND is the same as NOR with complemented inputs  NAND is the same as OR with complemented inputs  NOR is the same as AND with complemented inputs

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 20 A B C D Z A B C D Z NAND Conversion between forms Convert from networks of ANDs and ORs to networks of NANDs and NORs  introduce appropriate inversions ("bubbles") Each introduced "bubble" must be matched by a corresponding "bubble"  conservation of inversions  do not alter logic function Example: AND/OR to NAND/NAND

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 21 Z = [ (A B)’ (C D)’ ]’ = [ (A’ + B’) (C’ + D’) ]’ = [ (A’ + B’)’ + (C’ + D’)’ ] = (A B) + (C D) Conversion between forms (cont’d) Example: verify equivalence of two forms A B C D Z A B C D Z NAND

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 22 Step 2 conserve "bubbles" Step 1 conserve "bubbles" NOR \A \B \C \D Z NOR A B C D Z Conversion between forms (cont’d) Example: map AND/OR network to NOR/NOR network A B C D Z

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 23 Z = { [ (A’ + B’)’ + (C’ + D’)’ ]’ }’ = { (A’ + B’) (C’ + D’) }’ = (A’ + B’)’ + (C’ + D’)’ = (A B) + (C D) Conversion between forms (cont’d) Example: verify equivalence of two forms A B C D Z NOR \A \B \C \D Z

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 24 ABCDEFGABCDEFG X Multi-level logic x = A D F + A E F + B D F + B E F + C D F + C E F + G  reduced sum-of-products form – already simplified  6 x 3-input AND gates + 1 x 7-input OR gate (that may not even exist!)  25 wires (19 literals plus 6 internal wires) x = (A + B + C) (D + E) F + G  factored form – not written as two-level S-o-P  1 x 3-input OR gate, 2 x 2-input OR gates, 1 x 3-input AND gate  10 wires (7 literals plus 3 internal wires)

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 25 Level 1Level 2Level 3Level 4 original AND-OR network A C D B B \C F introduction and conservation of bubbles A C D B B \C F redrawn in terms of conventional NAND gates A C D \B B \C F Conversion of multi-level logic to NAND gates F = A (B + C D) + B C’

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 26 Level 1Level 2Level 3Level 4 A C D B B \C F original AND-OR network introduction and conservation of bubbles A C D B B \C F redrawn in terms of conventional NOR gates \A \C \D B \B C F Conversion of multi-level logic to NORs F = A (B + C D) + B C’

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 27 Conversion between forms Example

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 28 & & + 2x2 AOI gate symbol & & + 3x2 AOI gate symbol NAND Invert possible implementation A B C D Z AND ORInvert logical concept A B C D Z AND-OR-invert gates AOI function: three stages of logic — AND, OR, Invert  multiple gates "packaged" as a single circuit block

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 29 & & + A’ B’ A B F Conversion to AOI forms General procedure to place in AOI form  compute the complement of the function in sum-of-products form  by grouping the 0s in the Karnaugh map Example: XOR implementation  A xor B = A’ B + A B’  AOI form: F = (A’ B’ + A B)’

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 30 each implemented in a single 2x2 AOI gate Examples of using AOI gates Example:  F = A B + A C’ + B C’  F = (A’ B’ + A’ C + B’ C)’  Implemented by 2-input 3-stack AOI gate  F = (A + B) (A + C’) (B + C’)  F = [(A’ + B’) (A’ + C) (B’ + C)]’  Implemented by 2-input 3-stack OAI gate Example: 4-bit equality function  Z = (A0 B0 + A0’ B0’)(A1 B1 + A1’ B1’)(A2 B2 + A2’ B2’)(A3 B3 + A3’ B3’)

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 31 high if A0  B0 low if A0 = B0 if all inputs are low then Ai = Bi, i=0,...,3 output Z is high conservation of bubbles Examples of using AOI gates (cont’d) Example: AOI implementation of 4-bit equality function

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 32 Summary for multi-level logic Advantages  circuits may be smaller  gates have smaller fan-in  circuits may be faster Disadvantages  more difficult to design  tools for optimization are not as good as for two-level  analysis is more complex

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 33 Time behavior of combinational networks Waveforms  visualization of values carried on signal wires over time  useful in explaining sequences of events (changes in value) Simulation tools are used to create these waveforms  input to the simulator includes gates and their connections  input stimulus, that is, input signal waveforms Some terms  gate delay — time for change at input to cause change at output min delay – typical/nominal delay – max delay careful designers design for the worst case  rise time — time for output to transition from low to high voltage  fall time — time for output to transition from high to low voltage  pulse width — time that an output stays high or stays low between changes

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 34 F is not always 0 pulse 3 gate-delays wide D remains high for three gate delays after A changes from low to high F ABCD Momentary changes in outputs Can be useful — pulse shaping circuits Can be a problem — incorrect circuit operation (glitches/hazards) Example: pulse shaping circuit  A’ A = 0  delays matter

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 35 initially undefined close switch open switch + resistor A B C D Oscillatory behavior Another pulse shaping circuit

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 36 Hardware description languages Describe hardware at varying levels of abstraction Structural description  textual replacement for schematic  hierarchical composition of modules from primitives Behavioral/functional description  describe what module does, not how  synthesis generates circuit for module Simulation semantics

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 37 HDLs Abel (circa 1983) - developed by Data-I/O  targeted to programmable logic devices  not good for much more than state machines ISP (circa 1977) - research project at CMU  simulation, but no synthesis Verilog (circa 1985) - developed by Gateway (absorbed by Cadence)  similar to Pascal and C  delays is only interaction with simulator  fairly efficient and easy to write  IEEE standard VHDL (circa 1987) - DoD sponsored standard  similar to Ada (emphasis on re-use and maintainability)  simulation semantics visible  very general but verbose  IEEE standard

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 38 Verilog Supports structural and behavioral descriptions Structural  explicit structure of the circuit  e.g., each logic gate instantiated and connected to others Behavioral  program describes input/output behavior of circuit  many structural implementations could have same behavior  e.g., different implementation of one Boolean function We’ll mostly be using behavioral Verilog in Aldec ActiveHDL  rely on schematic when we want structural descriptions

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 39 module xor_gate (out, a, b); input a, b; output out; wire abar, bbar, t1, t2; inverter invA (abar, a); inverter invB (bbar, b); and_gate and1 (t1, a, bbar); and_gate and2 (t2, b, abar); or_gate or1 (out, t1, t2); endmodule Structural model

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 40 module xor_gate (out, a, b); input a, b; output out; reg out; assign #6 out = a ^ b; endmodule Simple behavioral model Continuous assignment delay from input change to output change simulation register - keeps track of value of signal

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 41 module xor_gate (out, a, b); input a, b; output out; reg out; or b) begin #6 out = a ^ b; end endmodule Simple behavioral model always block specifies when block is executed ie. triggered by which signals

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 42 module testbench (x, y); output x, y; reg [1:0] cnt; initial begin cnt = 0; repeat (4) begin #10 cnt = cnt + 1; $display time=%d, x=%b, y=%b, cnt=%b", $time, x, y, cnt); end #10 $finish; end assign x = cnt[1]; assign y = cnt[0]; endmodule Driving a simulation through a “testbench” 2-bit vector initial block executed only once at start of simulation directive to stop simulation print to a console

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 43 Complete simulation Instantiate stimulus component and device to test in a schematic a b z test-bench x y

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 44 module Compare1 (Equal, Alarger, Blarger, A, B); input A, B; output Equal, Alarger, Blarger; assign #5 Equal = (A & B) | (~A & ~B); assign #3 Alarger = (A & ~B); assign #3 Blarger = (~A & B); endmodule Comparator example

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 45 module life (n0, n1, n2, n3, n4, n5, n6, n7, self, out); input n0, n1, n2, n3, n4, n5, n6, n7, self; output out; reg out; reg [7:0] neighbors; reg [3:0] count; reg [3:0] i; assign neighbors = {n7, n6, n5, n4, n3, n2, n1, n0}; or self) begin count = 0; for (i = 0; i < 8; i = i+1) count = count + neighbors[i]; out = (count == 3); out = out | ((self == 1) & (count == 2)); end endmodule More complex behavioral model

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 46 Hardware description languages vs. programming languages Program structure  instantiation of multiple components of the same type  specify interconnections between modules via schematic  hierarchy of modules (only leaves can be HDL in Aldec ActiveHDL) Assignment  continuous assignment (logic always computes)  propagation delay (computation takes time)  timing of signals is important (when does computation have its effect) Data structures  size explicitly spelled out - no dynamic structures  no pointers Parallelism  hardware is naturally parallel (must support multiple threads)  assignments can occur in parallel (not just sequentially)

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 47 Hardware description languages and combinational logic Modules - specification of inputs, outputs, bidirectional, and internal signals Continuous assignment - a gate’s output is a function of its inputs at all times (doesn’t need to wait to be "called") Propagation delay- concept of time and delay in input affecting gate output Composition - connecting modules together with wires Hierarchy - modules encapsulate functional blocks

III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 48 Working with combinational logic summary Design problems  filling in truth tables  incompletely specified functions  simplifying two-level logic Realizing two-level logic  NAND and NOR networks  networks of Boolean functions and their time behavior Time behavior Hardware description languages Later  combinational logic technologies  more design case studies