verilog section 3.10 section 4.5. keywords keywords are predefined lowercase identifiers that define...

30
Verilog Section 3.10 Section 4.5

Upload: edward-roling

Post on 11-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Verilog

Section 3.10Section 4.5

Page 2: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Keywords• Keywords are predefined lowercase

identifiers that define the language constructs– Key example of keywords: module,

endmodule, input, output, and wire.

Page 3: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

assign

• The assignment is said to be sensitive to the variables in the RHS expression because anytime a variable in the RHS changes during the simulation, the RHS expression is reevaluated and the result is used to update the LHS.

Page 4: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Semicolon

• Each statement must end with a semicolon (;)

Page 5: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Bitwise Logic Operation

• Bitwise means 1 bit at a time

Bitwise logic operator Verilog

AND a&b

OR a|b

XOR a^b

INVERT ~a

NAND ~(a&b)

NOR ~(a|b)

XNOR !(a^b)

Page 6: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

wire

You can think of a wire as a wire in a circuit where actual voltages Could be measured.

Page 7: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Wire example

Use & for AND operationUse tilda (~) for the INVERT operationUse | for the OR operation

Page 8: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Waveform

Page 9: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Using Verilog Primitives

• Verilog also has keywords such as and or and not.

The output of a primitivemust be listed first.

Page 10: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Gate Delays

• In Verilog, the propagation delay of a gate is specified in terms of time units and is specified by the symbol #.

• `timescale 1ns/100ps– The first number specifies the unit of

measurement for time delays.– The second number specifies the

precisions for which the delays are rounded off.

Page 11: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Gate Delay

E is not defined until after 1 ns.

Page 12: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Gate Delay

E is not defined until 1 ns.W is not defined until 2 ns.This means that D is not defined until 3 ns.

Page 13: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Binary Addition Example

Page 14: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Derivation of ∑ (ES112 Slides)

Question: What primitive best implements ∑? • Inputs: A, B• Outputs: ∑=

B A ∑

0 0 0

1 0 1

0 1 1

1 1 0

Page 15: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Derivation of Carry Out(ES112 Slides)

Question: What primitive best implements Co? • Inputs: A, B• Outputs: Co =A∙B

B A Co

0 0 0

1 0 0

0 1 0

1 1 1

Page 16: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Implementation of a Half-Adder

Page 17: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Limitation of a Half Adder

A half-adder does not account for carry-in.

Page 18: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Truth Table for a Full Adder

carry-in

Page 19: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Karnaugh Map For the Sum Bit(ES112 Review)

= = =

Page 20: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Karnaugh Map For the Carry-Out Bit(ES112 Review)

C=𝑥 ′ 𝑦𝑧+𝑥 𝑦 ′ 𝑧+𝑥𝑦=𝑧 (𝑥⊕𝑦 )+𝑥𝑦

Page 21: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Implementation of a Full Adder

𝑆=𝑧 (𝑥⊕ 𝑦 )+𝑥𝑦C=𝑧⊕(𝑥⊕𝑦 )

(carry-in)

Page 22: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Schematic of a Full Adder

Half-adder(not including the bubble)

Half-adder

Page 23: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Build a Verilog Representation of a Full Adder Circuit

• Build a half adder circuit• Build a test bench for the adder

circuit• Assemble a full adder circuit• Build a test bench circuit to test the

full –adder• Write the code to implement the

adder circuit on FPGA

Page 24: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Build a Half-Adder Circuit

(Figure 4.5)

Page 25: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Build a Test Bench in VerilogIdeas: (page 112 of the textbook)1. reg2. Initial statement3. Assign value to a single bit4. $finish

1’b0=one binary digit with a value of 01’b1=one binary digit with a value of 1

Page 26: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Initial, $finish

• inital: keyword used with a set of statements that begin executing when simulation is initialized.

• $finish: specifies the termination of simulation.

Page 27: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Block statement

A block statement consists of severalstatements that are executed in sequencefrom top to bottom.

Page 28: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Build a Full-Adder Circuit

w1

w2 w3

M1 M2

Page 29: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Full-Adder Top Level Circuit

Page 30: Verilog Section 3.10 Section 4.5. Keywords Keywords are predefined lowercase identifiers that define the language constructs – Key example of keywords:

Build a FPGA Top Level Circuit

(x) (y) (z) (s) (c)

See gates2.pdf (available from the course website) for reference