Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.

Slides:



Advertisements
Similar presentations
An Introduction to Verilog: Transitioning from VHDL
Advertisements

Verilog.
Chap. 6 Dataflow Modeling
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Table 7.1 Verilog Operators.
Chapter 4 Register Transfer and Microoperations
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Combinational Comparators
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Part 2: DESIGN CIRCUIT. LOGIC CIRCUIT DESIGN x y z F F = x + y’z x y z F Truth Table Boolean Function.
each of these is an instantiation of “full_adder”
Chapter 4: Operators Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills /1436.
Chapter 6. Dataflow Modeling. Continuous Assignments The left hand side always be a scalar or vector net or a concatenation of scalar and vector nets.
Introduction to Verilog Tahir Muhammad FPGA Based System Design.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
ECE 2372 Modern Digital System Design
Workshop Topics - Outline
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
Digital Logic Design Week 3
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Multiplexers XOR gates. Multiplexers A multiplexer is a digital switch - it connects data from one of n sources to its output. An n-input and b-bit multiplexer.
EEE2243 Digital System Design Chapter 3: Verilog HDL (Combinational) by Muhazam Mustapha, January 2011.
4. Computer Maths and Logic 4.2 Boolean Logic Logic Circuits.
15-Nov-15 All the Operators. operators.ppt 2 Precedence An operator with higher precedence is done earlier (precedes) one with lower precedence A higher.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Digital Logic Design.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Logic Gates Informatics INFO I101 February 3, 2003 John C. Paolillo, Instructor.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
Introduction to ASIC flow and Verilog HDL
1 ECE 545—Digital System Design with VHDL Lecture 1 Digital Logic Refresher Part A – Combinational Logic Building Blocks.
Chapter 4 Register Transfer and Microoperations Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
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.
Introduction to Verilog
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Sequential Logic Design.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
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.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
Digital System Design Verilog ® HDL Dataflow Modeling Maziar Goudarzi.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Combinational Circuits
University of Central Florida COP 3330 Object Oriented Programming
Chapter 4 Register Transfer and Microoperations
Introduction to Verilog
University of Central Florida COP 3330 Object Oriented Programming
TODAY’S OUTLINE Testbench Circuit Verilog Operators
Chapter 4 Combinational Logic
Introduction to Verilog
Operators and Expressions
Behavioral Modeling in Verilog
Chapter 3: Dataflow Modeling
COE 202 Introduction to Verilog
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Introduction to Programming – 4 Operators
Introduction to Verilog
Combinational Circuits
Introduction to Verilog
Introduction to Verilog
Supplement on Verilog combinational circuit examples
COE 202 Introduction to Verilog
Presentation transcript:

Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5

Abstract Today’s class:  Data-flow modeling  Examples

Data-Flow Modelling-Operators Arithmetic operators: –Operators: ‘+’::= addition, ‘-’::=subtraction, ‘*’::= multiplication, ‘/’::= division, ‘%’::=modulus. –Example: parameter n=4; reg [3:0] a, b, f, g, count; f=a+c; g=c-n; count=(count+1)%16 //count 0 through 15 Relational operators: –Compare two operands and return a single bit 1 or 0 –Operators: ‘ ’::= greater than, ‘>=’::= greater than or equal to, ‘==‘::= equal to, ‘!=‘::= not equal to. –Example: if (x==y) e=1; else e=0; // equivalent to e = (x==y)

Data-Flow Modelling-Operators Bit-wise operators: –A bit-by-bit comparison between two operands and return an operand vector –Operators: ‘~’::= bitwise NOT, ‘&’::= bitwise AND, ‘|’::= bitwise OR, ‘^’::= bitwise XOR, ‘~^’ or ‘^~’::= bitwise XNOR. –Example: module bit_wise_test(a,b,c); input[1:0] a,b; output[1:0] c; assign c = (a&b); // return c[0], c[1 c = (s) ? b:c; // condition expression of bitwise endmodule

Data-Flow Modelling-Operators Reduction operators: –Operate on all the bits of an operand vector (compare to all elements of a bus variable) and return a single-bit value. –These are unary (one argument) form of the bit-wise operators. –Operators: ‘&’::= reduction AND, ‘|’::= reduction OR, ‘~&’::= reduction NAND, ‘~|’::= reduction NOR, ‘^’::= reduction XOR, ‘~^’ or ‘^~’:: XNOR. –Example: module chk_zero(a,z); input [2:0] a; // an input bus output z; // a single output variable assign z = ~| a; // reduction NOR, z=1 for a=000 endmodule

Data-Flow Modelling-Operators Logical operators: –Return a single bit 1 or 0. They are the same as bit-wise operators but is applied only for single bit operands. –Operators: ‘!’::= logical NOT, ‘&&’::= logical AND, ‘||’::= logical OR. –Example: wire [7:0] x, y, z; // declare multi-bit variables reg a; …….. if ((x==y) && (z)) a=1; // a=1 if x equals y, and z is nonzero else a =(!x); // a=0 if x is anything but zero.

Data-Flow Modelling-Operators Shift operators: –Shift the first operand by the number of bits specified by the second operand. –Vacated positions are filled with zeros for both left and right shifts. –Operators: ‘ >’::= shift right –Example: assign c = a<<2; /* c=a shifted left for 2 bits; vacant positions are filled with 0’s */ e.g., a=6’b  c=6’b100100

Data-Flow Modelling-Operators Concatenation operator: – Combine two or more operands to form a larger vector. – Operator: ‘{}’::= concatenation. – Example: {a,b[3:1],4’b0110,c} equivalent to {a,b[3],b[2],b[1],1’b0,1’b1,1’b1,1’b0,c}. Replication operator: – Make multiple copies of an item. – Operator: ‘{n{item}}’::= n fold replication of an item. – Example: a={4{2’b01}} equivalent to a=8’b w={a,2{a,b,c}} equivalent to w={a,a,b,c,a,b,c}

Data-Flow Modelling-Operators Conditional operator: – Evaluate one of the two expression based on a condition. It will synthesize to a multiplexer (MUX). – Operator: (cond)?(result if cond true) : result if cond false) – Examples: assign a=(g) ? y1 : y2; /* if (g) then a=y1 else a=y2 if g=(x or z), then (bitwise) a=0 if y1=y2=0, or a=1 if y1=y2=1 else a=x */ assign a=(inc==2) ? a+1:a-1; /* if inc=2, then a=a+1 else a=a-1 */

4-bit comparator: bit-wise operator

Check even parity and all zeros using bit-wise operator XOR and XNOR

A parity bit is a bit that is added to ensure that the number ofbit bits with value of one in a given set of bits is always even oroneeven odd. Parity bits are used as the simplest error detecting code.error detecting code As for binary digits, there are two variants of parity bits: even parity bit and odd parity bit: An even parity bit is set to 1 if the number of ones in a given set of bits is odd (making the total number of ones, including the parity bit, even). An odd parity bit is set to 1 if the number of ones in a given set of bits is even (making the total number of ones, including the parity bit, odd).

Examples: Ex1: Transmission sent using even parity: A transmits: 1001 A computes parity bit value: 1^0^0^1=0 (i.e. even number of ‘1’) A adds parity bit and sends:  error detecting code B receives: 1001 B computes parity: 1^0^0^1^0=0 (the same as the one computed by A) B reports correct transmission after observing expected even result. Ex2: transmission sent using odd parity: A transmits: 1001 A computes parity bit value: ~(1^0^0^1)=1 (i.e. even number of ‘1’) A adds parity bit and sends: B receives: B computes parity: 1^0^0^1^1=1 B reports correct transmission after observing expected odd result. Ex3: transmission sent using even parity: A transmits: 1001 A computes parity bit and sends: **** transmission error *** B receives: B computes parity: 1^1^0^1^0=1 (different from the one computed by A) B reports incorrect transmission after observing unexpected odd results ( cannot do the even number of corrupted bits, e.g.,  11011)

Test shift-right operator (shift right by 2 bits = divided by 2^2=4) (shift right by 3 bits = divided by 2^3=8) (shift right by 5 bits = divided by 2^5=32) P.S.: shift-left operator is for low active 3-8 decoder

∥ 4-bit 2-1 Multiplexer: 3-types (6 methods) 2-input and 1-output with 4-bit each

Vector sign extend Single-bit sign extend

Multi-bit concatenation (array) Single-bit concatenation

Shift right or left by 1 bit using concatenation operator =

1-bit half adder (unsigned) ∥ 1-bit full adder (unsigned)

∥ 4-bit ripple carry adder (unsigned) Method1: built-in adder Method2: Gate instan. using 1-bit full adder

Arithmetic operation rules: 1.option=ADD, result=a+b 2.option=SUB, result=a-b 3.option=AND, result= a&b 4.option=OR, result= a|b 5.option=XOR, result=a^b 6.default, result=a Arithmetic operation

Data-Flow Modelling-Operators Operator precedence: (see p.5-5 – 5-6) Logical and bit-wise NOT: !,~ Unary operators: &,~&,~|,^,~^ Arithmetic operators: +,-*,/,% Shift operators: > Relational operators:,>= Logic equality : ==,!=, Case operators: ===,!== Bitwise operators: &,~&,^,~^ Logical AND: && Logical OR: || Conditional operator: ?: high low