1 COMP541 Combinational Logic and Design Montek Singh Jan 30, 2007.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Part 4: combinational devices
Verilog.
Simulation executable (simv)
Decoder Mano Section 4.9 &4.12.
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Princess Sumaya University
Overview Part 2 – Combinational Logic Functions and functional blocks
Combinational Circuits
Functions and Functional Blocks
A Digital Circuit Toolbox
Verilog Intro: Part 1.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
Henry Hexmoor1 C hapter 4 Henry Hexmoor-- SIUC Rudimentary Logic functions: Value fixing Transferring Inverting.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Overview Part 2 – Combinational Logic
7-Segment LED Display DD: Section Mano: Section 3.10.
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 3 – Combinational Logic Design Part 2 –
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Overview Logistics Last lecture Today HW5 due today
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
Combinational Logic Chapter 4.
Combinational Logic in Verilog
Outline Analysis of Combinational Circuits Signed Number Arithmetic
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 3 – Combinational Logic Design Part 2 –
Figure 6.1. A 2-to-1 multiplexer.
Chap 3. Chap 3. Combinational Logic Design. Chap Combinational Circuits l logic circuits for digital systems: combinational vs sequential l Combinational.
Combinational Circuits
ECE 2372 Modern Digital System Design
CS1Q Computer Systems Lecture 8
1 COMP541 Hierarchical Design & Verilog Montek Singh Jan 28, 2010.
Combinational Logic. Digital Circuits Introduction Logic circuits for digital systems may be combinational or sequential. A combinational circuit.
1 COMP541 Combinational Logic - 3 Montek Singh Jan 21, 2010.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
ENG241 Digital Design Week #4 Combinational Logic Design.
1 COMP541 Combinational Logic - 4 Montek Singh Jan 30, 2012.
9/15/09 - L15 Decoders, Multiplexers Copyright Joanne DeGroat, ECE, OSU1 Decoders and Multiplexer Circuits.
Combinational Design, Part 3: Functional Blocks
1 Combinational Logic Design Digital Computer Logic Kashif Bashir
1 COMP541 Verilog Primer Montek Singh Aug 28, 2015 (draft version  to be updated)
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
CO UNIT-I. 2 Multiplexers: A multiplexer selects information from an input line and directs the information to an output line A typical multiplexer has.
1 COMP541 Hierarchical Design & Verilog Montek Singh Aug 29, 2014.
1 COMP541 Combinational Logic - 3 Montek Singh Jan 23, 2012.
CS1Q Computer Systems Lecture 8
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 4: Testing, Dataflow Modeling Spring 2009.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
1 DLD Lecture 16 More Multiplexers, Encoders and Decoders.
Introduction to Verilog. Structure of a Verilog Program A Verilog program is structured as a set of modules, which may represent anything from a collection.
Chapter 3 Combinational Logic Design II
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Overview Part 2 – Combinational Logic Functions and functional blocks
Montek Singh Sep 16, 2016 (draft version  to be updated)
COMP541 Hierarchical Design & Verilog
Discussion 2: More to discuss
ENG2410 Digital Design “Combinational Logic Design”
CS221: Digital Logic Design Combinational Circuits 3
Combinational Logic Circuits
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Chapter 4 Combinational Logic
Introduction to Verilog
Behavioral Modeling in Verilog
COE 202: Digital Logic Design Combinational Circuits Part 3
The Verilog Hardware Description Language
Digital System Design Combinational Logic
Presentation transcript:

1 COMP541 Combinational Logic and Design Montek Singh Jan 30, 2007

2 Homework 1  On web page  Due next Thursday

3Topics  Common Logic Functions Decoders Decoders Encoders Encoders Multiplexers Multiplexers  A little more Verilog syntax  Verilog for creating test vectors

4 Comb. Logic in Context  Typically part of system with storage  Computer looks like this at high level

5Enable  Enable is a common input to logic functions  See it in memories and today’s logic blocks

6Decoders  Typically n inputs and 2n outputs  Drives high the output corresponding to binary code of input 74139

7 2-to-4 Line Decoder

8 2-to-4 with Enable

9 Truth Table, 3-to-8 Decoder  Notice they are minterms

10Schematic

11 Multi-Level 3-to-8

12 Enable Used for Expansion

13 Multi-Level 6-to-64

14 Uses for Decoders  Binary number might serve to select some operation  Computer op codes are encoded Decoder lines might select add, or subtract, or multiply, etc. Decoder lines might select add, or subtract, or multiply, etc.  Memory address lines

15Variations  At right Enable not Enable not Inverted outputs Inverted outputs

16Verilog

17Encoder  Encoder is the opposite of decoder  2 n inputs (or less – maybe BCD in)  n outputs

18 Truth Table

19 Inputs are Minterms  Can OR them together appropriately  A 0 = D 1 + D 3 + D 5 + D 7

20 What’s the Problem?  What if D3 and D6 both high?  Simple OR circuit will set A to 7

21 Priority Encoder  Chooses one with highest priority Largest number, usually Largest number, usually  Note “don’t cares” What if all inputs are zero?

22 Need Another Output  A “Valid” output

23 Valid is OR of inputs

24 Multiplexer (or Mux)  Selects one of a set of inputs to pass on to output  Binary control code, n lines Choose from 2 n inputs Choose from 2 n inputs  Useful for choosing from sets of data Memory or register to ALU Memory or register to ALU  Very common 74153

25 Two Input Mux

26Logic

27 Logic is Decoder Plus

28 Structural Verilog module mux_4_to_1_line_structural(S, D, Y); input [1:0] S; input [3:0] D; output Y; wire [1:0] not_S; wire [0:3] N; not(not_S[0], S[0]); not(not_S[1], S[1]); and(N[0], not_S[1], not_S[0], D[0]); and(N[1], not_S[1], S[0], D[1]); and(N[2], S[1], not_S[0], D[2]); and(N[3], S[1], S[0], D[3]); or(Y, N[0], N[1], N[2], N[3]); endmodule We can do better with dataflow (next)

29 Dataflow Verilog module mux_4_to_1_df(S, D, Y); input [1:0] S; input [1:0] S; input [3:0] D; input [3:0] D; output Y; output Y; assign Y = (~ S[1] & ~ S[0] & D[0])| assign Y = (~ S[1] & ~ S[0] & D[0])| (~ S[1] & S[0] & D[1]) | (~ S[1] & S[0] & D[1]) | ( S[1] & ~ S[0] & D[2]) | ( S[1] & ~ S[0] & D[2]) | ( S[1] & S[0] & D[3]); ( S[1] & S[0] & D[3]);endmodule Can do even better (next)

30 But First an Aside  Verilog constants  Conditional assignment

31 Constants in Verilog  Syntax [size][‘radix]constant  Radix can be d, b, h, or o (default d)  Examples assign Y = 10;// Decimal 10 assign Y = ‘b10;// Binary 10, decimal 2 assign Y = ‘h10;// Hex 10, decimal 16 assign Y = 8‘b0100_0011 // Underline ignored  Binary values can be 0, 1, or x

32 Conditional Assignment  Equality test S == 2'b00  Assignment assign Y = (S == 2'b00)?‘b0:‘b1; If true, assign 0 to Y If true, assign 0 to Y If false, assign 1 to Y If false, assign 1 to Y

33 4-to-1 Mux Truth Table-ish module mux_4_to_1_dataflow(S, D, Y); input [1:0] S; input [1:0] S; input [3:0] D; input [3:0] D; output Y; output Y; assign Y = (S == 2'b00) ? D[0] : assign Y = (S == 2'b00) ? D[0] : (S == 2'b01) ? D[1] : (S == 2'b01) ? D[1] : (S == 2'b10) ? D[2] : (S == 2'b10) ? D[2] : (S == 2'b11) ? D[3] : 1'bx ; (S == 2'b11) ? D[3] : 1'bx ;endmodule

34 Verilog for Decision Tree module mux_4_to_1_binary_decision(S, D, Y); input [1:0] S; input [1:0] S; input [3:0] D; input [3:0] D; output Y; output Y; assign Y = S[1] ? (S[0] ? D[3] : D[2]) : assign Y = S[1] ? (S[0] ? D[3] : D[2]) : (S[0] ? D[1] : D[0]) ; (S[0] ? D[1] : D[0]) ;endmodule

35 Binary Decisions  If S[1] == 1, branch one way assign Y = S[1] ? (S[0] ? D[3] : D[2]) assign Y = S[1] ? (S[0] ? D[3] : D[2]) and decide Y = either D[2] or D[3] based on S[0] and decide Y = either D[2] or D[3] based on S[0]  Else : (S[0] ? D[1] : D[0]) ; : (S[0] ? D[1] : D[0]) ; decide Y is either D[2] or D[3] based on S[0] decide Y is either D[2] or D[3] based on S[0]  Notice that conditional test is for ‘1’ condition like in C

36 Quad 2-to-4 Line Mux  Select one set of 4 lines  Can gang these  Select a whole 64-bit data bus

37 Three-State Implementation

38Demultiplexer  Takes one input  Out to one of 2 n possible outputs

39 Demux is a Decoder  With an enable

40 Code Converters  One code to another  Book puts seven-segment decoder in this category  Typically multiple outputs Each output has function or truth table Each output has function or truth table

41 Seven-Segment Decoder  This Friday’s lab: Verilog of hex to LEDs  Extended version of book example  You may want to work out mapping (truth table/function) before lab

42 Change Topics to  Verilog First a couple of syntax styles First a couple of syntax styles Help you program more efficiently Help you program more efficiently  Verilog test programs

43 Instance Port Names  Module module modp(output C, input A); module modp(output C, input A);  Ports referenced as modp i_name(conC, conA) modp i_name(conC, conA)  Also as modp i_name(.A(conA),.C(conC)); modp i_name(.A(conA),.C(conC));

44Parameter  Can set constant Like #define Like #define parameter SIZE = 16; parameter SIZE = 16;

45 Verilog for Simulation  Code more convenient than the GUI testbench Also more complex conditions Also more complex conditions Can test for expected result Can test for expected result

46ISE  Make Verilog Test Fixture  Will create a wrapper (a module) Instantiating your circuit Instantiating your circuit It’ll be called UUT (unit under test) It’ll be called UUT (unit under test)  You then add your test code  Example on next slides

47 Module and Instance UUT module syn_adder_for_example_v_tf(); // DATE: 21:22:20 01/25/2004 //...Bunch of comments // Instantiate the UUT syn_adder uut ( syn_adder uut (.B(B),.B(B),.A(A),.A(A),.C0(C0),.C0(C0),.S(S),.S(S),.C4(C4).C4(C4) ); );...endmodule

48Reg  It will create storage for the inputs to the UUT // Inputs reg [3:0] B; reg [3:0] B; reg [3:0] A; reg [3:0] A; reg C0; reg C0;  We’ll talk more about reg next class

49 Wires for Outputs  That specify bus sizes // Outputs wire [3:0] S; wire [3:0] S; wire C4; wire C4;

50Begin/End  Verilog uses begin and end for block  instead of curly braces

51Initial  Initial statement runs when simulation begins initial initialbegin B = 0; B = 0; A = 0; A = 0; C0 = 0; C0 = 0; end end

52 Procedural assignment  Why no “assign”?  Because it’s not a continuous assignment  Explain more next class when we look at storage/clocking

53 Initialize in Default Test File  There’s one in ISE generated file, but don’t think auto_init is defined // Initialize Inputs `ifdef auto_init `ifdef auto_init initial begin initial begin B = 0; B = 0; A = 0; A = 0; C0 = 0; C0 = 0; end end `endif `endif

54 What to Add?  Need to make simulation time pass  Use # command for skipping time  Example (note no semicolon after #50) initial begin begin B = 0; B = 0; #50 B = 1; #50 B = 1; end end

55For  Can use for loop in initial statement block initial begin begin for(i=0; i < 5; i = i + 1) for(i=0; i < 5; i = i + 1) begin begin #50 B = i; end end end

56Integers  Can declare for loop control variables Will not synthesize, as far as I know Will not synthesize, as far as I know integer i; integer j;  Can copy to input regs There may be problems with negative values There may be problems with negative values

57 There are also  While  Repeat  Forever

58Timescale  Need to tell simulator what time scale to use  Place at top of test fixture `timescale 1ns/10ps `timescale 1ns/10ps

59 System Tasks  Tasks for the simulator  $stop – end the simulation  $display – like C printf  $monitor – prints when arguments change (example next)  $time – Provides value of simulated time

60Monitor // set up monitoring initial initialbegin $monitor($time, " A=%b,B=%b\n", A, B); end // These statements conduct the actual test initialbegin Code... Code... end end

61Today  Common functions – should know these Decoder Decoder Priority encoder Priority encoder Multiplexer (mux) Multiplexer (mux) Demultiplexer Demultiplexer  A little more Verilog  Verilog test programs

62Next  Sequential Circuits Storing state Storing state Sections 6-1, 6-2, 6-3 Sections 6-1, 6-2, 6-3  We’ll put off the study of arithmetic circuits Chapter 5 Chapter 5