CDA 4253/CIS 6930 FPGA System Design Modeling of Combinational - - PowerPoint PPT Presentation

cda 4253 cis 6930 fpga system design modeling of
SMART_READER_LITE
LIVE PREVIEW

CDA 4253/CIS 6930 FPGA System Design Modeling of Combinational - - PowerPoint PPT Presentation

CDA 4253/CIS 6930 FPGA System Design Modeling of Combinational Circuits Hao Zheng Dept of Comp Sci & Eng USF Reading P. Chu, FPGA Prototyping by VHDL Examples Chapter 3, RT-level combinational circuit Sections 3.1 - 3.2, 3.5 -


slide-1
SLIDE 1

CDA 4253/CIS 6930 FPGA System Design Modeling of Combinational Circuits

Hao Zheng Dept of Comp Sci & Eng USF

slide-2
SLIDE 2

2

Reading

➜ P. Chu, FPGA Prototyping by VHDL Examples

➺Chapter 3, RT-level combinational circuit ➺Sections 3.1 - 3.2, 3.5 - 3.7.

➜XST User Guide for Virtex-6, Spartan-6, and 7

Series Devices

➺Chapter 3 and 7

slide-3
SLIDE 3

3

VHDL Model Template: Recap

library library ieee ieee; use ieee.std_logic_1164.all; use ieee.std_logic_1164.all; entity entity entity_name entity_name is is port declarations port declarations end [entity] end [entity] entity_name entity_name; ARCHITECTURE ARCHITECTURE architecture_name OF OF entity_name IS IS Signal & component declarations Signal & component declarations BEGIN BEGIN Concurrent statements Concurrent statements END [ARCHITECTURE] END [ARCHITECTURE] architecture_name;

slide-4
SLIDE 4

4

➜Simple concurrent signal assignment

➺ z <= a xor b

➜Conditional signal assignment (when-else) ➜selected concurrent signal assignment (with-

select-when)

➜Process statements

➺To be covered later

Concurrent Statements

slide-5
SLIDE 5

5

VHDL Modeling Styles

Components and interconnects

structural VHDL Descriptions dataflow

Concurrent statements

behavioral

  • Registers
  • State machines
  • Instruction decoders

Sequential statements

Subset most suitable for synthesis

  • Testbenches
slide-6
SLIDE 6

6

Combinational Circuit Building Blocks

slide-7
SLIDE 7

7

Fixed Shifters & Rotators

slide-8
SLIDE 8

8

Fixed Logical Shift Right in VHDL

A(3) A(2) A(1) A(0) A(3) A(2) A(1)

A C

4 4

A C

A A srl srl 1

SIGNAL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0); SIGNAL SIGNAL C : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0); srl srl: logic shift right C <= A C <= A srl srl 1; 1;

C <= ‘0’ & A(3 C <= ‘0’ & A(3 downto downto 1); 1);

slide-9
SLIDE 9

9

Fixed Arithmetic Shift Right in VHDL

A(3) A(2) A(1) A(0) A(3) A(2) A(1)

A

C <= A C <= A sra sra 1; 1;

c <= A(3) & A(3 c <= A(3) & A(3 downto downto 1); 1); C

4 4

A C

A A sra sra 1

A(3)

SIGNAL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0); SIGNAL SIGNAL C : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0); sra sra: arithmetic shift left

slide-10
SLIDE 10

10

Fixed Rotation in VHDL

A(3) A(2) A(1) A(0) A(2) A(1) A(0) A(3)

A

4 4

A C

A A rol rol 1 SIGNAL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0); SIGNAL SIGNAL C : STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0);

rol rol: : rotation to left

C <= A rol 1

C

slide-11
SLIDE 11

11

Logic Gates

slide-12
SLIDE 12

12

x

1

x

2

x

n

x

1 x 2 … x n

+ + + x

1

x

2

x

1 x 2

+ x

1

x

2

x

n

x

1

x

2

x

1 x 2

  • x

1 x 2 … x n

(a) AND gates (b) OR gates x x (c) NOT gate

Basic Gates – AND, OR, NOT

slide-13
SLIDE 13

13

x 1 x 2 x n x 1 x 2

x n + + + x 1 x 2 x 1 x 2 + x 1 x 2 x n x 1 x 2 x 1 x 2

×

x 1 x 2

x n

× × ×

(a) NAND gates (b) NOR gates

Basic Gates – NAND, NOR

… …

slide-14
SLIDE 14

14

(b) Graphical symbol (a) Truth table 1 1 1 1 1 1 x

1 x 2

x

1

x

2

f x

1

x

2

Å = f x

1

x

2

Å = (c) Sum-of-products implementation f x

1

x

2

Å = x

1

x

2

Basic Gates – XOR

slide-15
SLIDE 15

15

(b) Graphical symbol (a) Truth table 1 1 1 1 1 1 x

1 x 2

x

1

x

2

f x

1

x

2

Å = f x

1

x

2

Å = (c) Sum-of-products implementation f x

1

x

2

Å = x

1

x

2

x

1

x

2

= .

Basic Gates – XNOR

slide-16
SLIDE 16

16

1-Bit Full Adder

x y cin s cout

slide-17
SLIDE 17

17

LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY ENTITY fa1b IS IS PORT PORT( x : IN IN STD_LOGIC ; y : IN IN STD_LOGIC ; cin : IN IN STD_LOGIC ; s : OUT OUT STD_LOGIC ; cout : OUT OUT STD_LOGIC ) ; END END fa1b;

1-Bit Full Adder

slide-18
SLIDE 18

18

ARCHITECTURE ARCHITECTURE dataflow OF OF fa1b IS IS BEGIN BEGIN s <= x XOR XOR y XOR XOR cin ; cout <= (x AND AND y) OR OR (cin AND AND x) OR OR (cin AND AND y) ; END END dataflow ;

1-Bit Full Adder

x y cin s cout

slide-19
SLIDE 19

19

Logic Operators

  • Logic operators
  • Logic operators precedence

and or and or nand nand nor nor xor xor not not xnor xnor not not and or and or nand nand nor nor xor xor xnor xnor

Highest Lowest

slide-20
SLIDE 20

20

Wanted: y = ab + cd Incorrect y <= a and b or c and d; equivalent to y <= ((a and b) or c) and d; equivalent to y = (ab + c)d Correct y <= (a and b) or (c and d);

No Implied Precedence

slide-21
SLIDE 21

21

Modeling Routing Structures with Conditional Concurrent Signal Assignment (when-else)

slide-22
SLIDE 22

22

2-to-1 Multiplexer

(a) Graphical symbol (b) Truth table

f sel f sel w0

1

w1

1

w0 w1

slide-23
SLIDE 23

23

2-to-1 Multiplexer

LIBRARY LIBRARY ieee ; USE USE ieee.std_logic_1164.all ; ENTITY ENTITY mux2to1 IS IS PORT PORT( w0, w1, sel : IN IN STD_LOGIC ; f : OUT OUT STD_LOGIC ) ; END END mux2to1 ; ARCHITECTURE ARCHITECTURE dataflow OF OF mux2to1 IS IS BEGIN BEGIN f <= f <= w0 WHEN w0 WHEN sel sel = '0' ELSE = '0' ELSE w1; w1; END END dataflow ;

slide-24
SLIDE 24

24

Conditional Concurrent Signal Assignment

➜Branches are evaluated one by one from top to

bottom.

➜Induces priority among branches

target_signal <= value1 when when condition1 else else value2 when when condition2 else else . . . valueN+1 when when conditionN+1 else else valueN;

slide-25
SLIDE 25

25

Cascade of Multiplexers

LIBRARY LIBRARY ieee ; USE USE ieee.std_logic_1164.all ; ENTITY ENTITY mux_cascade IS PORT PORT (w1, w2, w3 : IN STD_LOGIC ; s1, s2 : IN STD_LOGIC ; f : OUT STD_LOGIC ) ; END END mux_cascade ; ARCHITECTURE ARCHITECTURE dataflow OF OF mux_cascade IS IS BEGIN BEGIN f <= f <= w1 WHEN s1 = w1 WHEN s1 =1' 1' ELSE ELSE w2 WHEN s2 = w2 WHEN s2 =1 ELSE ELSE w3; w3; END END dataflow ;

slide-26
SLIDE 26

26

Cascade of Multiplexers

1 1 y

Notice the priority of selection.

w3 w2 w1 s1 s2

slide-27
SLIDE 27

27

.…

Value N Value N-1 Condition N-1 Condition 2 Condition 1 Value 2 Value 1 Target Signal

1 1 1

Conditional Concurrent Signal Assignment

target_signal <= value1 when when condition1 else else value2 when when condition2 else else . . . valueN+1 when when conditionN+1 else else valueN;

slide-28
SLIDE 28

28

More Operators

  • Relational operators
  • Logic and relational operators precedence

= /= < <= > >= = /= < <= > >=

not not = /= < <= > >= = /= < <= > >= and or and or nand nand nor nor xor xor xnor xnor

Highest Lowest

slide-29
SLIDE 29

29

Precedence of Logic and Relational Operators

Comparison a = bc Incorrect … when a = b and and c else … equivalent to … when (a = b) and and c else … Correct … when a = (b and and c) else …

slide-30
SLIDE 30

30

Modeling Routing Structures with Selected Concurrent Signal Assignment (with-select-when)

slide-31
SLIDE 31

31

f s 1 w w 1 00 01 (b) Truth table w w 1 s 0 w 2 w 3 10 11 1 1 1 1 f s 1 s w 2 w 3 (a) Graphic symbol

No priority, and choices are disjoint.

4-to-1 Multiplexer

slide-32
SLIDE 32

32

LIBRARY LIBRARY ieee ; USE USE ieee.std_logic_1164.all all ; ENTITY ENTITY mux4to1 IS IS PORT( PORT( w0, w1, w2, w3 : IN IN STD_LOGIC ; s : IN IN STD_LOGIC_VECTOR(1 DOWNTO DOWNTO 0); f : OUT OUT STD_LOGIC ) ; END END mux4to1 ; ARCHITECTURE ARCHITECTURE dataflow OF OF mux4to1 IS IS BEGIN BEGIN

WITH WITH s SELECT SELECT f <= w0 WHEN WHEN "00", w1 WHEN WHEN "01", w2 WHEN WHEN "10", w3 WHEN WHEN OTHERS OTHERS;

END END dataflow;

A 4-to-1 Multiplexer

default condition

slide-33
SLIDE 33

33

Selected Concurrent Signal Assignment

with choice_expression select target <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N;

All choices are mutually exclusive and cover all values of choice_expression.

slide-34
SLIDE 34

34

Selected Concurrent Signal Assignment

with choice_expression select target <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N;

choices_1 choices_2 choices_N expression1 target_signal choice expression expression2 expressionN

slide-35
SLIDE 35

35

Formats of Choices

  • when Expr
  • when Expr_1 | .... | Expr_N
  • this branch is taken if any of Expr_x matches

choice_expression

  • when others

when others

slide-36
SLIDE 36

36

Formats of Choices - Example

with with sel select select y <= a when when "000", c when when "001" | "111", d when when

  • thers
  • thers;
slide-37
SLIDE 37

37

Decoders

slide-38
SLIDE 38

38

2-to-4 Decoder

1 1 1 1 y 3 w 1 w x x 1 1 1 1 En 1 y 2 1 y 1 1 y 1 w 1 En y 3 w y 2 y 1 y (a) Truth table (b) Graphical symbol

slide-39
SLIDE 39

39

  • - LIBRARY not shown

ENTITY ENTITY dec2to4 IS IS PORT PORT ( w : IN IN STD_LOGIC_VECTOR(1 DOWNTO 0) ; En : IN IN STD_LOGIC ; y : OUT OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ; END END dec2to4 ; ARCHITECTURE ARCHITECTURE dataflow OF OF dec2to4 IS IS SIGNAL SIGNAL Enw : STD_LOGIC_VECTOR(2 DOWNTO DOWNTO 0) ; BEGIN BEGIN

Enw <= En & w ; WITH WITH Enw SELECT SELECT y <= 0001" WHEN WHEN "100", "0010" WHEN WHEN "101", "0100" WHEN WHEN "110", 1000" WHEN WHEN "111", "0000" WHEN WHEN OTHERS OTHERS ;

END END dataflow ;

VHDL Code for a 2-to-4 Decoder

slide-40
SLIDE 40

40

Encoders

slide-41
SLIDE 41

41

Priority Encoder

w w

3

y y

1

x 1 1 w0 y1 x y0 1 1 1 1 1 1 z 1 x x x w1 1 x x w2 1 x w3 1

z w

1

w

2

slide-42
SLIDE 42

42

VHDL code for a Priority Encoder

  • - library not shown

ENTITY ENTITY priority IS IS PORT PORT ( w : IN IN STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0) ; y : OUT OUT STD_LOGIC_VECTOR(1 DOWNTO DOWNTO 0) ; z : OUT OUT STD_LOGIC ) ; END END priority ; ARCHITECTURE ARCHITECTURE dataflow OF OF priority IS IS BEGIN BEGIN

y <= "11" when when w(3) = '1’ else else "10" when when w(2) = '1' else else "01" when when w(1) = '1' else else "00" when others; z <= '0' when when w = "0000" else else '1' when others;

END END dataflow ;

slide-43
SLIDE 43

43

Adders

slide-44
SLIDE 44

44

16-bit Unsigned Adder

16 16

X Y

16

Cin Cout S

+

S = X + Y

slide-45
SLIDE 45

45

Operations on Unsigned Numbers

For operations on unsigned numbers USE ieee.numeric_std.all and signals of the type UNSIGNED and conversion functions std_logic_vector(), unsigned() OR USE ieee.std_logic_unsigned.all and signals of the type STD_LOGIC_VECTOR

slide-46
SLIDE 46

46

LIBRARY LIBRARY ieee ; USE USE ieee.std_logic_1164.all all ;

USE USE ieee.std_logic_unsigned.all all;--non-IEEE standard

ENTITY ENTITY adder16 IS IS PORT PORT( Cin : IN IN STD_LOGIC ; X : IN IN STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; Y : IN IN STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; S : OUT OUT STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; Cout : OUT OUT STD_LOGIC ) ; END END adder16 ; ARCHITECTURE ARCHITECTURE dataflow OF OF adder16 IS IS SIGNAL SIGNAL Sum : STD_LOGIC_VECTOR(16 16 DOWNTO DOWNTO 0) ; BEGIN BEGIN

Sum <= ('0' & X) + Y + Cin ;

S <= Sum(15 DOWNTO DOWNTO 0) ; Cout <= Sum(16) ; END END dataflow ;

16-bit Unsigned Adder

slide-47
SLIDE 47

47

Addition of Unsigned Numbers (1)

LIBRARY ieee ; USE ieee.std_logic_1164.all ;

USE USE ieee.numeric_std.all all; -- IEEE standard

ENTITY ENTITY adder16 IS IS PORT PORT( Cin : IN IN STD_LOGIC ; X : IN IN STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; Y : IN IN STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; S : OUT OUT STD_LOGIC_VECTOR(15 DOWNTO DOWNTO 0) ; Cout : OUT OUT STD_LOGIC ) ; END END adder16 ;

slide-48
SLIDE 48

48

Addition of Unsigned Numbers (2)

ARCHITECTURE ARCHITECTURE dataflow OF OF adder16 IS IS SIGNAL SIGNAL Xu, Yu : UNSIGNED(15 DOWNTO DOWNTO 0); SIGNAL SIGNAL Su : UNSIGNED(16 DOWNTO DOWNTO 0) ; BEGIN BEGIN Xu <= unsigned(X); Yu <= unsigned(Y); Su <= ('0' & Xu) + Yu + unsigned(0 & Cin) ; S <= std_logic_vector(Su(15 DOWNTO 0)) ; Cout <= Su(16) ; END END dataflow ; Signed and unsigned are arrays of std_logic.

slide-49
SLIDE 49

49

Operations on Signed Numbers

For operations on signed numbers

  • Either use

ieee.numeric_std.all, signals of the type SIGNED, and conversion std_logic_vector(), signed()

  • Or use

ieee.std_logic_signed.all, and signal type STD_LOGIC_VECTOR

slide-50
SLIDE 50

50

Signed/Unsigned Types in numeric_std

➜ Behave exactly like

std_logic_vector

➜ They determine whether a given vector should be

treated as a signed or unsigned number.

➜ Prefer to use

ieee.numeric_std.all;

➜ Use either numeric_std or std_logic_unsigned (or

signed).

➺Do NOT mix them together.

slide-51
SLIDE 51

51

Multipliers

slide-52
SLIDE 52

52

Unsigned vs. Signed Multiplication

1111 1111 x 11100001 15 15 x 225 1111 1111 x 00000001

  • 1
  • 1

x 1 Unsigned Signed

In Xilinx, a multiplier can be implemented either in a DSP or CLB

slide-53
SLIDE 53

53

8x8-bit Unsigned Multiplier

mult8b

a b c

LIBRARY LIBRARY ieee; USE USE ieee.std_logic_1164.all all; USE USE ieee.std_logic_unsigned.all .all; entity entity mult8b is is port port(…); end end mult8b; architecture architecture arch of

  • f mult8b is

is begin begin

c <= a * b;

end end arch;

slide-54
SLIDE 54

54

8x8-bit Signed Multiplier

mult8b

a b c

LIBRARY LIBRARY ieee; USE USE ieee.std_logic_1164.all all; USE USE ieee.std_logic_signed.all .all; entity entity mult8b is is port port(…); end end mult8b; architecture architecture arch of

  • f mult8b is

is begin begin

c <= a * b;

end end arch;

slide-55
SLIDE 55

55

Signed/Unsigned Multiplication

library library ieee; use use ieee.std_logic_1164.all;

use use ieee.numeric_std.all .all ;

entity entity multiply is is port port( a : in STD_LOGIC_VECTOR(7 downto downto 0); b : in STD_LOGIC_VECTOR(7 downto downto 0); cu : out STD_LOGIC_VECTOR(15 downto downto 0); cs : out STD_LOGIC_VECTOR(15 downto downto 0)); end end multiply; architecture architecture dataflow of

  • f multiply is

is begin begin

  • - signed multiplication

cs <= std_logic_vector(signed(a)*signed(b));

  • - unsigned multiplication

cu <= std_logic_vector(unsigned(a)*unsigned(b));

end end dataflow;

slide-56
SLIDE 56

56

Multiplication with Constants

➜If either A or B in A * B is a constant, more

efficient implementation with shifts and additions. A * 9 can be implemented as A << 3 + A

slide-57
SLIDE 57

57

Operators in numeric_std Package

slide-58
SLIDE 58

58

Parameterized Models

slide-59
SLIDE 59

59

Design Reuse

➜How to design for the 32-bit problem below? ➜Create a new 32-bit adder

➺waste of effort

➜Reuse previously designed adder

➺but it is 16-bit

O = A + B + C

slide-60
SLIDE 60

60

library ieee; use ieee. std_logic_1164 . a l l ; use ieee. numeric_std . a l l ; entity gen_add_w_carry i s generic(N : integer := 4); port( a, b : in std_logic_vector (N - 1 downto 0); cout : out std_logic; sum : out std_logic_vector (N - 1 downto 0) ); end gen_add_w_carry ; architecture arch

  • f

gen_add_w_carry is signal a_ext , b_ext , sum_ext : unsigned(N downto 0); begin a_ext <= unsigned (’0’ & a); b_ext <= unsigned (’0’ & b); sum_ext <= a_ext + b_ext; sum <= std_logic_vector (sum_ext(N - 1 downto 0)); cout <= sum_ext(N); end arch

slide-61
SLIDE 61

61

−− i n s t a n t i a t e 8− b i t adder adder_8_unit: work. gen_add_w_carry (arch) generic map(N=>8) port map(a=>a8 , b=>b8 , cout=>c8 , sum=>sum8 )); −− i n s t a n t i a t e 16− b i t adder adder_16_unit : work. gen_add_w_carry (arch) generic map(N= >16) port map(a=>a16 , b=>b16 , cout=>c16 , sum=>sum16 )); −− i n s t a n t i a t e 4− b i t adder −− ( gener ic mapping

  • mitted ,

d e f a u l t value 4 used ) adder_4_unit: work. gen_add_w_carry (arch) port map(a=>a4 , b=>b4 , cout=>c4 , sum=>sum4 ));

Instances of Generic Models

slide-62
SLIDE 62

62

A Word on Generics

➜ Generics are typically integer values ➺In this class, the entity inputs and outputs should be

std_logic or std_logic_vector.

➺But the generics should be integer. ➜ Generics are given a default value ➺GENERIC ( N : INTEGER := 16 ) ; ➺This value can be overwritten when entity is instantiated as

a component

➜ Generics are very useful when instantiating an often-used

component

➺Need a 32-bit register in one place, and 16-bit register in

another

➺Can use the same generic code, just configure them

differently

slide-63
SLIDE 63

63

Constants – Make Code More Readable

Syntax: constant constant name : type := value;

Examples:

constant constant init_val : STD_LOGIC_VECTOR(3 downto 0) := "0100"; constant constant ANDA_EXT : STD_LOGIC_VECTOR(7 downto 0) := X"B4"; constant constant counter_width : INTEGER := 16; constant constant buffer_address : INTEGER := x”FFFE”; constant constant clk_period : TIME := 20 ns; constant constant strobe_period : TIME := 333.333 ms;

slide-64
SLIDE 64

64

Constants vs Generics

➜Constants:

➺Create symbolic names ➺Make code more readable ➺Declared in packages, entity, or architecture. ➺Cannot create generic designs: still need two design

entities for Adder_8b and Adder_32b.

➜Generics:

➺Can be passed through design hierarchy through

component instantiation

➺Used for creating generic designs: a single design

entity Adder for Adder_8b and Adder_32b.

slide-65
SLIDE 65

65

Binary to BCD Conversion

slide-66
SLIDE 66

66

for(i=0; i<8; i++) { // add 3 to a column if it is >= 5 for each column if (column >= 5) column += 3; // shift binary digits left 1 Hundred << 1; Hundreds[0] = Tens[3]; Tens << 1; Tens[0] = Ones[3]; Ones << 1; Ones[0] = Binary[7]; Binary << 1; }

Shift and Add-3 (Double-Dabble)

slide-67
SLIDE 67

67

  • 1. If the binary value in any of the BCD columns is 5 or

greater, add 3 to that value in that BCD column.

  • 2. Shift the binary number left one bit.
  • 3. If 8 shifts have taken place, the BCD number is in the

Hundreds, Tens, and Ones column. Terminate

  • 4. Otherwise, go to 1.

Example: Hundreds Tens Ones Binary 0000 0000 0000 11110011

Shift and Add-3 (Double-Dabble)

slide-68
SLIDE 68

68

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010

Shift and Add-3 (Double-Dabble)

slide-69
SLIDE 69

69

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010 0000 0000 0001 0100010 << 1

Shift and Add-3 (Double-Dabble)

slide-70
SLIDE 70

70

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010 0000 0000 0001 0100010 << 1 0000 0000 0010 100010 << 1

Shift and Add-3 (Double-Dabble)

slide-71
SLIDE 71

71

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010 0000 0000 0001 0100010 << 1 0000 0000 0010 100010 << 1 0000 0000 0101 00010 << 1 0000 0000 1000 00010 +3

Shift and Add-3 (Double-Dabble)

slide-72
SLIDE 72

72

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010 0000 0000 0001 0100010 << 1 0000 0000 0010 100010 << 1 0000 0000 0101 00010 << 1 0000 0000 1000 00010 +3 0000 0001 0000 0010 << 1 0000 0010 0000 010 << 1 0000 0100 0000 10 << 1

Shift and Add-3 (Double-Dabble)

slide-73
SLIDE 73

73

100’s 10’s 1’s Binary Operation 0000 0000 0000 10100010 0000 0000 0001 0100010 << 1 0000 0000 0010 100010 << 1 0000 0000 0101 00010 << 1 0000 0000 1000 00010 +3 0000 0001 0000 0010 << 1 0000 0010 0000 010 << 1 0000 0100 0000 10 << 1 0000 1000 0001 << 1 0000 1011 0001 +3

Shift and Add-3 (Double-Dabble)

slide-74
SLIDE 74

74

Goto wiki for more information and VHDL implementation

Shift and Add-3 (Double-Dabble)

slide-75
SLIDE 75

75

Summary

➜More concurrent statements for DF modeling

➺ describing routing structures

➜Modeling of basic combinational circuit blocks

➺ Adders, multipliers, muxes, encoder/decoder

➜ Generic design modeling

➺Using VHDL generics

slide-76
SLIDE 76

76

Backup

slide-77
SLIDE 77

77

Comparators

slide-78
SLIDE 78

78

2-bit Number Comparator

A

AeqB

A = B

2 2 B

slide-79
SLIDE 79

79

4-bit Unsigned Number Comparator

library library ieee; use use ieee.std_logic_1164.all all;

use use ieee.std_logic_unsigned.all .all ;

entity entity compare is is port port( A, B : in in STD_LOGIC_VECTOR(1 downto downto 0); AeqB : out

  • ut

STD_LOGIC ); end end compare ; architecture architecture dataflow of

  • f compare is

is begin begin AeqB <= '1' when when A = B else else '0’; end end dataflow ;

slide-80
SLIDE 80

80

4-bit Unsigned Number Comparator

library library ieee; use use ieee.std_logic_1164.all all; entity entity compare is is port port( A, B : in in STD_LOGIC_VECTOR(1 downto downto 0); AeqB : out

  • ut

STD_LOGIC ); end end compare ;

  • - Create a different model?

Create a different model? architecture architecture dataflow of

  • f compare is

is begin begin end end dataflow ;

slide-81
SLIDE 81

81

4-bit Signed Number Comparator

library library ieee; use use ieee.std_logic_1164.all all;

use use ieee.std_logic_signed.all .all;

entity entity compare is is port port( A, B : in in STD_LOGIC_VECTOR(1 downto downto 0); AeqB : out

  • ut STD_LOGIC);

end end compare ; architecture architecture dataflow of

  • f compare is

is begin begin AeqB <= '1' when when A = B else else '0’; end end dataflow ;

slide-82
SLIDE 82

82

Hexadecimal to 7-Segment Display

slide-83
SLIDE 83

83

7-Segment Display

A F E D C B G dp To illuminate a segment, the corresponding control signal should be driven low.

slide-84
SLIDE 84

84

7-Segment Display

A F E D C B G dp To illuminate a segment, the corresponding control signal should be driven low – A = ‘0,’ ..., F = ‘0’, G = ‘1’

slide-85
SLIDE 85

85

7-Segment Display

A F E D C B G dp To illuminate a segment, the corresponding control signal should be driven low – A = ‘0,’ ..., E = ‘1’, F = ‘0’, G = ‘0’

slide-86
SLIDE 86

86

Hex to 7-Segment

Hex Input 7-Segment Control GFE...BCA

0000 (0) 1000000 0001 (1) 1111001 0010 (2) 0100100 0011 (3) 0110000 0100 (4) 0011001 0101 (5) 0010010 0110 (6) 0000010 0111 (7) 1111000 1000 (8) 0000000 1001 (9) 0010000 1010 (A) 0001000

slide-87
SLIDE 87

87

7-Segment Display

AN3 AN2 AN1 AN0 CA CB CC CD CE CF CG DP

  • All four displays share common segment control signals.
  • Only one display can be illuminated at a time when signal

ANx is driven high. A B C D E F G DP

slide-88
SLIDE 88

88

7-Segment Display Controller

disp_mux 8 8 8 8 in0 in2 in2 in3 sseg an 8 4 hex2sseg 4 hex2sseg 4 hex2sseg 4 hex2sseg 4 clk

slide-89
SLIDE 89

89

  • 1. Right shift bcd1, with the LSB shifting to the MSB
  • f bcd0.
  • 2. Right shift bcd0, with the LSB shifting to the MSB
  • f bin.
  • 3. If bcd0 is now > 4, subtract 3
  • 4. repeat steps 1-3, 7 times.

BCD to Binary Conversion

slide-90
SLIDE 90

90

BCD to Binary Conversion

slide-91
SLIDE 91

91

8-bit Variable Rotator Left

8 8 3

A B C

A <<< B

slide-92
SLIDE 92

92

Tri-State Buffers

slide-93
SLIDE 93

93

(b) Equivalent circuit (c) Truth table

x f e

(a) A tri-state buffer

1 1 1 1 Z Z 1 f e x x f e = 0 e = 1 x f

Tri-State Buffers

slide-94
SLIDE 94

94 x f e

(b)

x f e

(a)

x f e

(c)

x f e

(d)

Four types of Tri-state Buffers

slide-95
SLIDE 95

95

Tri-state Buffer – Example (1)

LIBRARY ieee; USE ieee.std_logic_1164.all;

entity entity tri_state is is port port( ena, input : IN IN STD_LOGIC;

  • utput

: OUT OUT STD_LOGIC); end end tri_state; architecture architecture dataflow of

  • f tri_state is

is begin begin

  • utput <=

input when when (ena = ‘1’) else else ‘Z’;

end end dataflow;

slide-96
SLIDE 96

96

ROM

slide-97
SLIDE 97

97

3 16

Addr C

8x16 ROM

Dout

ROM 8x16 example (1)

slide-98
SLIDE 98

98

ROM 8x16 example (2)

LIBRARY ieee; USE ieee.std_logic_1164.all; USE USE ieee.numeric_std.all all; entity entity rom is is port port ( Addr : in in STD_LOGIC_VECTOR(2 downto downto 0); Dout : out

  • ut

STD_LOGIC_VECTOR(15 downto downto 0)); end end rom;

  • - architecture body is defined on the next slide
slide-99
SLIDE 99

99

architecture architecture dataflow of

  • f rom is

is

signal signal temp: integer range range 0 to to 7; type type vector_array is is array array(0 to to 7) of

  • f

std_logic_vector(15 downto downto 0); constant constant memory : vector_array := ( X”800A", X"D459", X"A870", X"7853", X"650D", X"642F", X"F742", X"F548"); begin begin

temp <= to_integer(unsigned(Addr)); Dout <= memory(temp);

end end dataflow;

ROM 8x16 example (3)