chapter 6. dataflow modeling. continuous assignments the left hand side always be a scalar or vector...

25
Chapter 6. Dataflow Modeling

Upload: edwin-harrington

Post on 20-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

Chapter 6. Dataflow Modeling

Page 2: 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

Continuous AssignmentsThe left hand side always be a scalar or vector

net or a concatenation of scalar and vector nets. It cannot be a scalar or vector register.

Continuous assignments are always active.

right-hand side can be registers or nets or function calls.

Delay values can be specified for assignments in terms of time units. It is very useful in modeling timing behavior in real circuits.

Page 3: 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

Example 6-1 Examples of Continuous Assignment

Page 4: 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

Implicit Continuous Assignment

Page 5: 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

Regular Assignment Delayassign #10 out = in1 & in2; // Delay in a

continuous assign

Page 6: 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

Net Declaration Delay

Page 7: 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

Expressions

Page 8: 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

Operands

Page 9: 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

OperatorsOperator Type

Operator Symbol

Operation Performed

Number of Operands

Arithmetic */+-%**

multiplydivideaddsubtractmoduluspower (exponent)

twotwotwotwotwotwo

Logical !&&||

logical negationlogical andlogical or

onetwotwo

Relational ><>=<=

greater thanless thangreater than or equalless than or equal

twotwotwotwo

Equality ==!====!==

equalityinequalitycase equalitycase inequality

twotwotwotwo

Page 10: 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

OperatorsOperator Type Operator Symbol Operation Performed Number of OperandsBitwise ~

&|^^~ or ~^

bitwise negationbitwise andbitwise orbitwise xorbitwise xnor

onetwotwotwotwo

Reduction &~&|~|^^~ or ~^

reduction andreduction nandreduction orreduction norreduction xorreduction xnor

oneoneoneoneoneone

Shift >><<>>><<<

Right shiftLeft shiftArithmetic right shiftArithmetic left shift

TwoTwoTwoTwo

Concatenation { } Concatenation Any numberReplication { { } } Replication Any numberConditional ?: Conditional Three

Page 11: 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

If any operand bit has a value xin1 = 4'b101x; in2 = 4'b1010; sum = in1 + in2; // sum will be evaluated

to the value 4'bx

Page 12: 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

Logical operators

Page 13: 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

Equality Operators

// A = 4, B = 3 // X = 4'b1010, Y = 4'b1101 // Z = 4'b1xxz, M = 4'b1xxz, N = 4'b1xxx A == B // Results in logical 0 X != Y // Results in logical 1 X == Z // Results in x Z === M // Results in logical 1 (all bits match, including x and z) Z === N // Results in logical 0 (least significant bit does not

match) M !== N // Results in logical 1

Page 14: 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

Bitwise OperatorsBitwise operators are negation (~), and(&),

or (|), xor (^), xnor (^~, ~^).

Page 15: 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

Logical operators perform a logical operation// X = 4'b1010, Y = 4'b0000 X | Y // bitwise operation. Result is 4'b1010 X || Y // logical operation.

Equivalent to 1 || 0. Result is 1.

Page 16: 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

Reduction OperatorsReduction operators are and (&), nand

(~&), or (|), nor (~|), xor (^), and xnor (~^, ^~).

perform a bitwise operation on a single vector operand and yield a 1-bit result.

Page 17: 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

Shift OperatorsShift operators are right shift ( >>), left

shift (<<), arithmetic right shift (>>>), and arithmetic left shift (<<<).

Page 18: 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

Concatenation Operator

Page 19: 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

Replication Operator

Page 20: 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

Conditional Operator

Page 21: 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

Operator PrecedenceOperators Operator

SymbolsPrecedence

Unary + - ! ~ Highest precedence

Multiply, Divide, Modulus

* / %

Add, Subtract + - Shift << >> Relational < <= > >= Equality == != === !== Reduction &, ~&

^ ^~|, ~|

Logical &&||

Conditional ?: Lowest precedence

Page 22: 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

4-to-1 Multiplexer, Using Logic Equations

Page 23: 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

4-to-1 Multiplexer, Using Conditional Operators

Page 24: 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

4-bit Full Adder, Using Dataflow Operators

Page 25: 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

4-bit Full Adder with Carry Lookahead