CDA 4253/CIS 6930 FPGA System Design Sequential Circuit Building - - PowerPoint PPT Presentation

cda 4253 cis 6930 fpga system design sequential circuit
SMART_READER_LITE
LIVE PREVIEW

CDA 4253/CIS 6930 FPGA System Design Sequential Circuit Building - - PowerPoint PPT Presentation

CDA 4253/CIS 6930 FPGA System Design Sequential Circuit Building Blocks Hao Zheng Dept of Comp Sci & Eng USF Outline and Reading Introduction of behavioral modeling with process Sequential statements inside processes Modeling


slide-1
SLIDE 1

CDA 4253/CIS 6930 FPGA System Design Sequential Circuit Building Blocks

Hao Zheng Dept of Comp Sci & Eng USF

slide-2
SLIDE 2

2

Outline and Reading

➜ Introduction of behavioral modeling with process

➜ Sequential statements inside processes

➜ Modeling combinational/sequential circuits

➜ Using processes and sequential statements

➜ Reading – P. Chu, P. Chu, FPGA Prototyping by VHDL

Examples

Section 3.3 – 3.4, 3.7

➜ Chapter 4, Regular Sequential Circuit

slide-3
SLIDE 3

3

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-4
SLIDE 4

4

Processes and Sequential Statements

slide-5
SLIDE 5

5

Process Statements

➜ Processes are concurrent statements. ➜ Processes describe combinational/sequential

behavior

➜ Processes in VHDL are very powerful statements

➜ Allow to define arbitrary behavior that may be difficult

to represent by a real circuit

➜ Not every process can be synthesized

➜ Use processes with caution in order to write the

synthesizable code.

➜ Use processes freely in testbenches for

simulation.

slide-6
SLIDE 6

6

Concurrent Statements

➜ simple concurrent signal assignment

(Ü)

➜ conditional concurrent signal assignment

(when-else)

➜ selected concurrent signal assignment

(with-select-when)

➜ Processes

slide-7
SLIDE 7

7

Anatomy of a Process

[label:] process process [(sensitivity list)] [declaration part] begin begin sequential statements end process end process [label];

OPTIONAL

slide-8
SLIDE 8

8

Sequential Statements

➜ Used only in processes ➜ Evaluated one at a time sequentially ➜ Include

➜ Signal/variable assignments ➜ IF statements ➜ CASE statements ➜ WAIT statements ➜ Other – loop, …

slide-9
SLIDE 9

9

PROCESS with a SENSITIVITY LIST

  • List of signals to which the

process is sensitive.

  • Whenever there is an

event on any of the signals in the sensitivity list, the process fires.

  • Every time the process

fires, it will run in its entirety. label: process process (sensitivity list) declarations begin begin sequential statements end end process process; wait statements are NOT ALLOWED in a process with a sensitivity list.

slide-10
SLIDE 10

10

Processes – Semantics

Execute Suspend

  • 1. Finish sequential execution, or
  • 2. encounter wait
  • 1. An event on a sensitive signal occurs, or
  • 2. Certain amount of delay has passed
slide-11
SLIDE 11

11

Modeling Combinational Circuits

slide-12
SLIDE 12

12

Processes Modeling Combinational Circuits

priority: process process(a, b) begin begin c <= a and and b; end process end process; AND a b c

To model a combinational circuit, all input signals and signals on LHS of signal assignments must be included in the sensitivity list!

slide-13
SLIDE 13

13

Processes Modeling Combinational Circuits

priority: process process begin begin

  • - sensitivity list used

sensitivity list used

  • - wait statement

wait statement

wait on a, b; wait on a, b; c <= a and and b; end process end process; AND a b c

To model a combinational circuit, all input signals and signals on LHS of signal assignments must be included in the sensitivity list!

slide-14
SLIDE 14

14

Wrong Processes

priority: process (a, b) process (a, b) begin begin wait on a, b; wait on a, b; c <= a and and b; end process end process; AND a b c

wait statements are NOT ALLOWED in a process with a sensitivity list.

slide-15
SLIDE 15

15

Sequential Statement: wait

wait until boolean_condition;

  • - wait until a=‘1’ and b=‘0’;

wait on signal_list;

  • - wait on a, b;

wait for time;

  • - wait for 10 ns;

wait; -- suspend the process forever Synthesis – Do not use WAIT when modeling a design.

slide-16
SLIDE 16

16

Process for Conditional Concurrent Signal Assignment

architecture architecture arch of

  • f ex is

is begin begin r <= a + b + c when when m=n else else a – b when when m>0 else else c + 1; end architecture end architecture arch;

slide-17
SLIDE 17

17

Process for Conditional Concurrent Signal Assignment – IF Statement

architecture architecture arch of

  • f ex is

is begin begin process process(a, b, c, m, n) begin begin if if m=n then then r <= a + + b + c; elsif elsif m > 0 then then r <= a – b; else else r <= c + 1; end if; end if; end process end process; end architecture end architecture arch;

slide-18
SLIDE 18

18

If Statement – Syntax

if boolean_expr_1 then sequential_statements; elsif boolean_expr_2 then sequential_statements; elsif boolean_expr_3 then sequential_statements; . . . else sequential_statements; end if;

slide-19
SLIDE 19

19

Process for Selected Concurrent Signal Assignment

architecture architecture arch of

  • f ex is

is begin begin with with sel select select r <= a + b + c when when “00” else else a – b when when “10” else else c + 1 when others; when others; end architecture arch; end architecture arch;

slide-20
SLIDE 20

20

Process for Selected Concurrent Signal Assignment – Case Statement

architecture architecture arch of

  • f ex is

is begin begin process process(a, b, c, sel) begin begin case case sel is is when when “00” => r <= a + + b + c; when when “10” => => r <= a – b; when others when others => r <= c + 1; end case; end case; end process end process; end architecture end architecture arch;

slide-21
SLIDE 21

21

Case Statement – Syntax

case case_expression is when choice_1 => sequential statements; when choice_2 => sequential statements; . . . when choice_n => sequential statements; end case;

slide-22
SLIDE 22

22

Comparison to Concurrent Statements

large <= a when a > b else b; small <= b when a > b else a; process(a, b) begin if a > b then large <= a; small < = b; else large <= b; small <= a; end if; end process;

slide-23
SLIDE 23

23

Unintended Memory

process process(a) begin begin if if a > b then then gt <= ‘1’; elsif elsif a = b then then eq <= ‘1’; end if; end if; end process end process;

Implicit memory is introduced to hold gt and eq. To model a combinational circuit, all input signals and signals on LHS of signal assignments must be included in the sensitivity list!

slide-24
SLIDE 24

24

Avoid Unintended Memory

process process(a, b) begin begin if if a > b then then gt <= ‘1’; eq <= ‘0’ elsif elsif a = b then then gt <= ‘0’; eq <= ‘1’; else else gt <= ‘0’; eq <= ‘0’; end if; end if; end process; end process;

  • 1. All inputs and signals on

LHS of signal assignments are included in the sensitivity list.

  • 2. A signal must be assigned

in every branch.

slide-25
SLIDE 25

25

Signal Assignments in Processes

XOR AND

d2 d1 d3

  • s
  • - Is this process the
  • - right model?

process (d1, d2, d3) begin s <= d1 xor d2;

  • <= s and d3;

end process;

slide-26
SLIDE 26

26

Signal Assignments in Processes

XOR AND

d2 d1 d3

  • s
  • - Is this process the
  • - right model?

process (d1, d2, d3) begin s <= d1 xor d2;

  • <= s and d3;

end process;

d1 d2 d3

slide-27
SLIDE 27

27

Signal Assignments in Processes

XOR AND

d2 d1 d3

  • s
  • - This process is the
  • - right model.

process (d1, d2, d3, s) begin s <= d1 xor d2;

  • <= s and d3;

end process;

d1 1 d2 1 d3 1

slide-28
SLIDE 28

28

Signal Assignments in Processes

process (d1, d2, d3, s) begin s <= d1 xor d2;

  • <= s and d3;

end process; process (d1, d2, d3, s) begin

  • <= s and d3;

s <= d1 xor d2; end process;

d1 d2 d3

  • d1

d2 d3

  • s
slide-29
SLIDE 29

29

  • Comb. Design Ex: Find Max of a, b, c
slide-30
SLIDE 30

30

Modeling Sequential Circuits

slide-31
SLIDE 31

31

Processes Modeling Sequential Circuits

  • All signals which appear on the

left of signal assignment statement (<=) are outputs e.g. y, z

  • All signals which appear on the

sensitivity list are inputs e.g. clk

  • All signals which appear on the

right of signal assignment statement (<=) or in logic expressions are inputs e.g. w, a, b, c

  • Note that not all inputs need to

be included on the sensitivity list

priority: process process(clk clk) begin begin if if w(3) = '1' then then y <= "11" ; elsif elsif w(2) = '1' then then y <= "10" ; elsif elsif w(1) = ‘1’ then then y <= “01”; else else y <= "00" ; end if end if; end process end process;

  • - Not synthesizable!!

Not synthesizable!!

w clk y Priority Encoder

slide-32
SLIDE 32

32

Clock D 1 1 – 1 1 Truth table Graphical symbol

t

1

t

2

t

3

t

4

Time

Clock D Q Timing diagram Q(t+1) Q(t)

D D Q Q Cloc

  • ck

k

D-Latch

slide-33
SLIDE 33

33

  • - library not shown

entity entity latch is is port port ( D, Clock : in in STD_LOGIC ; Q : out

  • ut STD_LOGIC);

end end latch ; architecture architecture behavioral of

  • f latch is

is begin begin process process (D, Clock

D, Clock)

begin begin if if Clock = '1'

Clock = '1' then

then Q <= D ; end if end if; end process end process; end architecture end architecture behavioral;

D D Q Q Cloc

  • ck

k

Should be avoided!

D-Latch: Level Sensitive

slide-34
SLIDE 34

34

Synchronous Circuit Structure

FF Combinational Logic clock

slide-35
SLIDE 35

35

Processes Modeling Sequential Circuits – Code Template

process process(reset, clk) begin begin if if reset=‘1’ then then

  • - reset logic for memory

elsif elsif rising_edge rising_edge(clk) then then

  • - functional logic defined
  • - with sequential statements

end if end if; end process end process;

This template is for synthesizable synchronous designs

slide-36
SLIDE 36

36

Processes Modeling Sequential Circuits – Code Template

process process(clk) begin begin if if rising_edge rising_edge(clk) then then if if reset=‘1’ then then

  • - reset logic for memory

else else

  • - functional logic defined
  • - with sequential statements

end if; end if end if; end process end process;

This template is for synthesizable synchronous designs

slide-37
SLIDE 37

37

Clk D ­ ­ 1 1 Truth table

t

1

t

2

t

3

t

4

Time

Clock D Q Timing diagram Q(t+1) Q(t)

D D Q Q Cloc

  • ck

k

Graphical symbol 0 – Q(t) 1 –

D Flip-Flop: Edge Triggered

slide-38
SLIDE 38

38

D D Q Q Cloc

  • ck

k

  • - library not shown

entity entity dff is is port port( D, Clock : in in STD_LOGIC ; Q : out

  • ut STD_LOGIC) ;

end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(Clock

Clock)

begin begin if if rising_edge

rising_edge(Clock) (Clock) then

then Q <= D ; end if end if; end process end process; end architecture end architecture behavioral;

D Flip-Flop: Edge Triggered

slide-39
SLIDE 39

39

D D Q Q Cloc

  • ck

k

  • - library not shown

entity entity dff is is port port ( D, Clock : in in STD_LOGIC; Q : out

  • ut STD_LOGIC);

end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(Clock

Clock)

begin begin if if Clock’event

Clock’event and Clock=‘1’ and Clock=‘1’ then

then Q <= D ; end if end if; end process end process; end architecture end architecture behavioral;

D Flip-Flop: Edge Triggered

slide-40
SLIDE 40

40

  • - library not shown

entity entity dff is is port port( D, Clock : in in STD_LOGIC ; Q : out

  • ut STD_LOGIC) ;

end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(Clock

Clock)

begin begin if if falling_edge

falling_edge(Clock) (Clock) then

then Q <= D ; end if end if; end process end process; end architecture end architecture behavioral;

D D Q Q Cloc

  • ck

k

To be synthesizable, each process is sensitive

  • n a single clock edge

D Flip-Flop: Edge Triggered

slide-41
SLIDE 41

41

  • - library not shown

entity entity dff is is port port( D, Clock : in in STD_LOGIC ; Q : out

  • ut STD_LOGIC) ;

end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(Clock Clock) begin begin if if rising_edge rising_edge(Clock) (Clock) then then Q <= D ; elsif elsif falling_edge falling_edge(Clock) (Clock) then then Q <= not D ; end if end if; end process end process; end architecture end architecture behavioral;

D D Q Q Cloc

  • ck

k

D Flip-Flop: Not Allowed!

slide-42
SLIDE 42

42

D FF with Asynchronous Reset

D D Q Q Cloc

  • ck

k Re Resetn

  • - library not shown

entity entity dff is is port port ( D, clock : in in STD_LOGIC ; resetn : in std_logic; Q : out

  • ut

STD_LOGIC); end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(resetn, clock

clock)

begin begin if if resetn

resetn = ‘0’ = ‘0’ then

then Q <= ‘0’; elsif elsif rising_edge rising_edge(clock) then then Q <= D ; end if end if; end process end process; end architecture end architecture behavioral;

slide-43
SLIDE 43

43

D D Q Q Cloc

  • ck

k Re Resetn

D FF with Synchronous Reset

  • - library not shown

entity entity dff is is port port ( D, clock : in in STD_LOGIC; resetn : in std_logic; Q : out

  • ut

STD_LOGIC); end entity end entity dff; architecture architecture behavioral of

  • f dff is

is begin begin process process(clock

clock)

begin begin if if rising_edge rising_edge(clock) then then if if resetn

resetn = ‘0’ = ‘0’ then

then Q <= ‘0’; else else Q <= D; end if end if; end process end process; end end behavioral;

slide-44
SLIDE 44

44

  • -Library not shown

ENTITY reg8 IS PORT ( D : in in STD_LOGIC_VECTOR(7 DOWNTO 0) STD_LOGIC_VECTOR(7 DOWNTO 0); resetn, clock : in in STD_LOGIC ; Q : out

  • ut STD_LOGIC_VECTOR(7 DOWNTO 0

STD_LOGIC_VECTOR(7 DOWNTO 0)); END reg8 ; ARCHITECTURE behavioral OF reg8 IS BEGIN PROCESS (resetn, clock) BEGIN IF resetn = '0' THEN Q <= "00000000” Q <= "00000000”; ELSIF rising_edge(clock) THEN Q <= D ; END IF ; END PROCESS ; END behavioral ;`

Resetn Clock

reg8

8 8 D Q

8-Bit Register

slide-45
SLIDE 45

45

  • -library not shown

ENTITY regn IS GENERIC (N : INTEGER := 16) GENERIC (N : INTEGER := 16) ; PORT( D : in in STD_LOGIC_VECTOR(N-1 downto downto 0); Resetn, Clock : in in STD_LOGIC; Q : out

  • ut STD_LOGIC_VECTOR(N-1 downto

downto 0)); END regn ; ARCHITECTURE behavioral OF regn IS BEGIN PROCESS (Resetn, Clock) BEGIN IF Resetn = '0' THEN Q <= (others

  • thers => '0’);

ELSIF rising_edge(Clock) THEN Q <= D ; END IF ; END PROCESS; END behavioral;

Resetn Clock

regn

N N D Q

Generic N-bit Register

slide-46
SLIDE 46

46

  • thers stands for any index value that has

not been previously referenced to.

Q <= 00000001 can be written as

Q <= (0 => 1’, others =>0)

Q <= 10000001 can be written as

Q <= (7 => 1, 0 => 1, others =>0)

  • r

Q <= (7 | 0 => 1, others =>0)

Q <= 00011110 can be written as

Q <= (4 downto 1 =>1, others =>0)

Use of Keyword OTHERS

slide-47
SLIDE 47

47

Example

x <= “0000_0001_0000_0001”

  • ther way to write the bit string?
slide-48
SLIDE 48

48

  • - library not shown

ENTITY regne IS GENERIC (N : INTEGER := 8); PORT ( Enable Enable, Clock : IN STD_LOGIC; D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0); Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0)); END regne ; ARCHITECTURE behavioral OF regne IS BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN IF IF Enable = '1' Enable = '1' THEN THEN Q <= D; END IF; END IF; END PROCESS; END behavioral;

Q D Enable Clock

regn

N N

N-bit Register with Enable

slide-49
SLIDE 49

49

FF Coding Guidelines (Xilinx)

➜ Do not set or reset FFs asynchronously

➜ Such FFs not supported, or ➜ Requiring additional resources -> hurts performance

➜ Do not describe Flip-Flops with both a set and a

reset

➜ No FFs with both set and reset

➜ Always describe enable, set, or reset control

inputs of Flip-Flop primitives as active-High

➜ additional inverter may hurt performance

➜ See XST user guide for more information

slide-50
SLIDE 50

50

Shift Registers

slide-51
SLIDE 51

51

Shift Register – Internal Structure

D Q Sin Clock D Q D Q D Q

Q(3) Q(2) Q(1) Q(0) Enable ENTITY sr4 IS PORT (Enable: IN STD_LOGIC; Sin : IN STD_LOGIC; Clock : IN STD_LOGIC; Q : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END sr4;

slide-52
SLIDE 52

52

Shift Register – Model

ARCHITECTURE behavioral OF sr4 IS signal signal reg: STD_LOGIC_VECTOR(3 downto downto 0); BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN IF Enable = 1 THEN

  • - shift right

reg <= reg(3 (3 downto downto 1) & sin; 1) & sin; END IF; END IF ; END PROCESS ;

  • - output logic

Q <= reg; END behavioral;

slide-53
SLIDE 53

53

Shift Register With Parallel Load

D(3) D Q Clock

Enable

Sin D(2) D Q D(1) D Q D(0) D Q

Q(0) Q(1) Q(2) Q(3) Load

slide-54
SLIDE 54

54

ENTITY sr4_pl IS PORT (D : IN STD_LOGIC_VECTOR(3 DOWNTO 0); Enable: IN STD_LOGIC; Load : IN STD_LOGIC; Sin : IN STD_LOGIC; Clock : IN STD_LOGIC; Q : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END sr4_pl;

Q Enable Clock 4 D Load Sin 4

4-bit Shift Register with Parallel Load

slide-55
SLIDE 55

55

ARCHITECTURE behavioral OF sr4_pl IS SIGNAL reg : STD_LOGIC_VECTOR(3 DOWNTO 0); BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN IF Enable = 1 THEN IF Load = '1' THEN reg <= D; -- parallel load ELSE reg reg <= <= reg reg(3 (3 downto downto 1) & sin; 1) & sin; -- shift right END IF; END IF; END IF ; END PROCESS; Q <= reg; -- output logic END behavioral;

Q Enable Clock 4 D Load Sin 4

4-bit Shift Register with Parallel Load

slide-56
SLIDE 56

56

ENTITY srn_pl IS GENERIC ( N : INTEGER := 8); GENERIC ( N : INTEGER := 8); PORT(D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0); Enable : IN STD_LOGIC ; Load : IN STD_LOGIC ; Sin : IN STD_LOGIC ; Clock : IN STD_LOGIC ; Q : OUT OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0)); END srn_pl ;

Q Enable Clock N D Load Sin N

N-bit Shift Register with Parallel Load

slide-57
SLIDE 57

57

ARCHITECTURE behavioral OF shiftn IS signal signal reg: STD_LOGIC_VECTOR(N-1 downto downto 0); BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN IF Enable = 1 THEN IF Load = '1' THEN reg <= D ; ELSE reg <= reg(N (N-1 1 downto downto 1) & sin; 1) & sin; END IF ; END IF; END IF ; END PROCESS ; Q <= reg; END behavioral;

Q Enable Clock N D Load Sin N

N-bit Shift Register with Parallel Load

slide-58
SLIDE 58

58

Counters

slide-59
SLIDE 59

59

architecture architecture behavioral of

  • f upcount is

is SIGNAL Count : SIGNAL Count : std_logic_vector std_logic_vector(1 DOWNTO 0); (1 DOWNTO 0); begin begin process process(Clock) begin begin if if rising_edge(Clock) then then IF IF Clear = ' = '1' THEN THEN Count <= " <= "00”; ”; ELSE ELSE Count <= <= Count + + 1 ; END IF ; end if end if; end process end process; Q <= Count; Q <= Count; -- output internal state end end behavioral;

2-bit Counter with Synchronous Reset

Q

Clear Clock

upcount

2

slide-60
SLIDE 60

60

ARCHITECTURE behavioral OF upcount _ar IS SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; BEGIN PROCESS (Clock, Resetn) BEGIN

IF IF Resetn Resetn = '0' THEN = '0' THEN Count <= "0000”; Count <= "0000”; ELSIF rising_edge(Clock) THEN IF Enable = '1' THEN IF Enable = '1' THEN Count <= Count + 1 ; Count <= Count + 1 ; END IF END IF; END IF ;

END PROCESS ; Q <= Count; Q <= Count; END behavioral ;

Q

Enable Clock

upcount 4

Resetn

Counter with Asynchronous Reset

slide-61
SLIDE 61

61

➜ Modify the model below to make it generic

LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE USE ieee.std_logic_unsigned.all ieee.std_logic_unsigned.all ; ENTITY upcount_ar IS PORT (Clock, Resetn Resetn, Enable Enable : IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR (3 DOWNTO 0)) ; END upcount_ar ;

N-bit Generic Counter: Exercise

slide-62
SLIDE 62

62

ARCHITECTURE behavioral OF upcount _ar IS SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; BEGIN PROCESS (Clock, Resetn) BEGIN IF IF Resetn Resetn = '0' THEN = '0' THEN Count <= "0000”; Count <= "0000”; ELSIF rising_edge(Clock) THEN IF Enable = '1' THEN IF Enable = '1' THEN Count <= Count + 1 ; Count <= Count + 1 ; END IF END IF; END IF ; END PROCESS ; Q <= Count; Q <= Count; END behavioral ;

N-bit Generic Counter: Exercise

slide-63
SLIDE 63

63

A Timer that Outputs a Tick per Second

slide-64
SLIDE 64

64

A Timer that Outputs a Tick per Second

LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE USE ieee.numeric_std.all ieee.numeric_std.all ; ENTITY timer_1s IS PORT( Clock, Resetn Resetn : IN STD_LOGIC_VECTOR(26 DOWNTO 0); tick : OUT STD_LOGIC ) ; END timer_1s;

slide-65
SLIDE 65

65

A Timer that Outputs a Tick per Second

ARCHITECTURE behavioral OF timer_1s IS SIGNAL Count : unsigned(26 DOWNTO 0); SIGNAL Count : unsigned(26 DOWNTO 0); BEGIN PROCESS (Clock, Resetn) BEGIN IF IF Resetn Resetn = '0' THEN = '0' THEN Count <= (others => ‘0’); Count <= (others => ‘0’); ELSIF rising_edge(Clock) THEN if Count = 100000000 100000000 then Count <= 0; else Count <= Count + 1 ; Count <= Count + 1 ; END IF ; END PROCESS ; tick <= tick <= ‘1’ when Count = ‘1’ when Count = 100000000 100000000 else else ‘0’; ‘0’; END behavioral ;

slide-66
SLIDE 66

66

Mod-m Counter

Counts from 0 to m-1, and wraps around

LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE USE ieee.numeric_std.all ieee.numeric_std.all ; ENTITY mod_m_counter IS generic( N : integer : 4; –- number of bits M : integer : 10 –- mod-M ); PORT( Clock, Reset Reset : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0); q : out std_logic_vector(N-1 downto 0); tick : OUT STD_LOGIC ) ; END mod_m_counter;

slide-67
SLIDE 67

67

Mod-m Counter

ARCHITECTURE arch OF mod_m_counter IS SIGNAL reg : unsigned(N-1 downto 0); BEGIN PROCESS (Clock, Reset) BEGIN IF Reset = '0' THEN reg <= (others => ‘0’); ELSIF rising_edge(Clock) THEN if (reg = M-1) then reg <= (others => ‘0’); else reg <= reg+1; end if; END IF ; END PROCESS ; q <= std_logic_vector(reg); tick <= ‘1’ when reg = M-1 else ‘0’; END arch; reg <= (reg + 1) mod M;

slide-68
SLIDE 68

68

Another Timer Design

➜ User sets a time in seconds ➜ Outputs a tick when time is expired

slide-69
SLIDE 69

69

Mixing Description Styles Inside of an Architecture

slide-70
SLIDE 70

70

VHDL Description Styles

Components and interconnects

structural VHDL Description Styles dataflow

Concurrent statements

behavioral

  • Registers
  • Shift registers
  • Counters
  • State machines

Sequential statements

synthesizable

slide-71
SLIDE 71

71

architecture architecture ARCHITECTURE_NAME of

  • f ENTITY_NAME is

is

  • - Declarations: signals, constants, functions,
  • - procedures, component declarations, ...

begin begin

  • - Concurrent statements:
  • - Concurrent simple signal assignment
  • - Conditional signal assignment
  • - Selected signal assignment
  • - Component instantiation statements
  • - Process statement
  • - inside process you can use

inside process you can use

  • - only sequential statements
  • nly sequential statements

end end ARCHITECTURE_NAME;

Mixed Style Modeling

Concurrent Statements

slide-72
SLIDE 72

72

PRNG Example (1)

ENTITY PRNG IS PORT( Coeff : in std_logic_vector(4 downto 0); Load_Coeff : in std_logic; Seed : in std_logic_vector(4 downto 0); Init_Run : in std_logic; Clk : in std_logic; Current_State : out std_logic_vector(4 downto 0)); END PRNG; ARCHITECTURE mixed OF PRNG is signal Ands : std_logic_vector(4 downto 0); signal Sin : std_logic; signal Coeff_Q : std_logic_vector(4 downto 0); signal Sr5_Q : std_logic_vector(4 downto 0);

  • - continue on the next slide
slide-73
SLIDE 73

73

PRNG Example (2)

BEGIN

  • - Data Flow

Sin <= Ands(0) XOR Ands(1) XOR Ands(2) XOR Ands(3) XOR Ands(4); Current_State <= sr4_Q; Ands <= Coeff_Q AND Sr5_Q;

  • - Behavioral

Coeff_Reg: PROCESS(Clk) BEGIN IF rising_edge(Clk) THEN IF Load_Coeff = '1' THEN Coeff_Q <= Coeff; END IF; END IF; END PROCESS;

  • - Structural

Sr4_pl_0 : ENTITY work.Sr4(behavioral) generic map(N => 5); PORT MAP (D => Seed, Load => Init_Run, Sin => Sin, Clock => Clk, Q => Sr5_Q); END mixed;

slide-74
SLIDE 74

Sequential Logic Modeling

slide-75
SLIDE 75

75

Sequential Logic – Overview

clk register inputs reg_next reg

  • utput
slide-76
SLIDE 76

76

Sequential Logic – VHDL Style 1

architecture arch of architecture arch of seq_template is is signal signal reg : std_logic_vector(N-1 downto downto 0); begin begin process( process(clk, reset) begin begin if if reset=‘1’ then then reg <= (others

  • thers => ‘0’);

elsif elsif rising_edge(clk) then then reg <= f(inputs, reg); end if; end if; end process; end process; end architecture arch; end architecture arch;

slide-77
SLIDE 77

77

Sequential Logic – VHDL Style 2

architecture arch of architecture arch of disp_mux is is signal signal reg, reg_next : std_logic_vector(N-1 downto downto 0); begin begin process( process(clk, reset) begin begin if if reset=‘1’ then then reg <= (others

  • thers => ‘0’);

elsif elsif rising_edge(clk) then then reg <= reg_next; end if; end if; end process; end process; reg_next reg_next <= f(inputs, <= f(inputs, reg reg); ); end architecture arch; end architecture arch;

Register update

  • Comb. logic
slide-78
SLIDE 78

78

VHDL Variables

slide-79
SLIDE 79

79

entity variable_in_process is port ( A,B : in std_logic_vector (3 downto 0); ADD_SUB : in std_logic; S : out std_logic_vector (3 downto 0) ); end variable_in_process; architecture archi of variable_in_process is begin process (A, B, ADD_SUB) variable AUX : std_logic_vector (3 downto 0); begin if ADD_SUB = ’1’ then AUX := A + B ; else AUX := A - B ; end if; S <= AUX; end process; end archi;

if-else and if-elsif-else statements use true-false conditions to execute statements.

  • If the expression evaluates to true, the if branch is executed.
  • If the expression evaluates to false, x, or z, the else branch is executed.
  • A block of multiple statements is executed in an if or else branch.
  • begin and end keywords are required.
  • if-else statements can be nested.
slide-80
SLIDE 80

80

Differences: Signals vs Variables

  • Variables can only be declared and used within

processes or procedures.

  • Used to hold temporary results.
  • Signals can only be declared in architecture.
  • Used for inter-process communications.
  • Variables are updated immediately.
  • Signals are updated after current execution of a

process is finished.

  • Synthesis results:
  • Variables: similar to signals, but maybe optimized away
  • Signals: wires, registers, or latches.
slide-81
SLIDE 81

81

Differences: Signals vs Variables

process (a, b, c, s) begin s <= a and b;

  • <= s xor c;

end process; process (a, b, c) variable s : std_logic; begin s := a and b;

  • <= s xor c;

end process; process (a, b, c, s) begin

  • <= s xor c;

s <= a and b; end process; process (a, b, c) variable s : std_logic; begin

  • <= s xor c;

s := a and b; end process;

slide-82
SLIDE 82

82

Differences: Signals vs Variables

process (a, b, c, s) begin s <= a and b;

  • <= s xor c;

end process; process (a, b, c) variable s : std_logic; begin s := a and b;

  • <= s xor c;

end process;

slide-83
SLIDE 83

83

Differences: Signals vs Variables

process (a, b, c) variable s : std_logic; begin

  • <= s xor c;

s := a and b; end process;

slide-84
SLIDE 84

84

Differences: Signals vs Variables

architecture sig_ex of test is signal s : std_logic; begin process (clk) begin if rising_edge(clk) then s <= a and b;

  • <= s xor c;

end if; end process; end sig_ex;

FF FF AND XOR

a b c

  • ut1
  • ut2
slide-85
SLIDE 85

85

Differences: Signals vs Variables

architecture var_ex of test is begin process (clk) variable s : std_logic; begin if rising_edge(clk) then s := a and b;

  • <= s xor c;

end if; end process; end var_ex;

AND XOR

a b c

FF

  • ut3
  • ut4
slide-86
SLIDE 86

86

Signals vs Variables – Summary

C1 C2 S1 S2 X1 X2

process (clk) begin if rising_edge(clk) then S1 <= C1(X1, S1, S2); S2 <= C2(X2, S1, S2); end if; end process;

slide-87
SLIDE 87

87

Signals vs Variables – Summary

C1 C2 V S X1 X2

process (clk) begin if rising_edge(clk) then V := C1(X1, S); S <= C2(X2, S); end if; end process;

slide-88
SLIDE 88

Case Studies

slide-89
SLIDE 89

Stopwatch

slide-90
SLIDE 90

90

Stopwatch

00.0 00.1 00.9 01.0

... ...

99.9

AB.C

  • A: count of 10 seconds;
  • B: count of 1 seconds;
  • C: count of 0.1 seconds.

How to measure 0.1 second?

slide-91
SLIDE 91

91

Stopwatch – Concept

Msec Counter Second Counter Second10 Counter

clk go

d1_en d2_en

Msec Tick Gen

ms tick

d0 d1 d2

slide-92
SLIDE 92

92

Stopwatch – VHDL Code

library library ieee; use use ieee.std_logic_1164.all; all; use use ieee.numeric_std.all all; entity entity stop_watch is is port port(clk, go, clr : in in std_logic; d0 : out

  • ut std_logic_vector(3 downto

downto 0); d1 : out

  • ut std_logic_vector(3 downto

downto 0); d2 : out

  • ut std_logic_vector(3 downto

downto 0)); end entity end entity stop_watch;

slide-93
SLIDE 93

93

Stopwatch – VHDL Code

architecture architecture caecade_arch caecade_arch of

  • f stop_watch

stop_watch is is constant DVSR : integer := 10000000; constant DVSR : integer := 10000000; signal signal ms_reg ms_reg, , ms_next ms_next : unsigned(23 : unsigned(23 downto downto 0); 0); signal d0_reg, d1_reg, d2_reg signal d0_reg, d1_reg, d2_reg : unsigned(3 : unsigned(3 downto downto 0); 0); signal d0_next, d1_next, d2_next signal d0_next, d1_next, d2_next : unsigned(3 : unsigned(3 downto downto 0); 0); signal d1_en, d2_en : signal d1_en, d2_en : std_logic std_logic; signal signal ms_tick ms_tick, d0_tick, d1_tick, d2_tick , d0_tick, d1_tick, d2_tick : : std_logic std_logic; begin begin

  • - to continue on the next slide

to continue on the next slide

slide-94
SLIDE 94

94

Stopwatch – VHDL Code

architecture architecture caecade_arch caecade_arch of

  • f stop_watch

stop_watch is is ... ... –- see previous slide see previous slide begin begin

  • - register update

register update process( process(clk clk) begin begin if if rising_edge rising_edge(clk clk) then ) then ms_reg ms_reg <= <= ms_next ms_next; d0_reg <= d0_next; d0_reg <= d0_next; d1_reg <= d1_next; d1_reg <= d1_next; d2_reg <= d2_next; d2_reg <= d2_next; end if; end if; end process; end process;

slide-95
SLIDE 95

95

Stopwatch – VHDL Code

  • - next state logic

next state logic

  • - 0.1 sec tick generator

0.1 sec tick generator ms_next ms_next <= (others =>’0’) when <= (others =>’0’) when clr clr=‘1’ or =‘1’ or (ms_reg ms_reg=DVSR and go=‘1’) else =DVSR and go=‘1’) else ms_reg+1 when go=‘1’ else ms_reg+1 when go=‘1’ else ms_reg ms_reg; ms_tick ms_tick <= <= ms_reg ms_reg=DVSR; =DVSR; --

  • - generate

generate ms_tick ms_tick

  • - 0.1 second counter

0.1 second counter do_next do_next <= “0000” when <= “0000” when clr clr=‘1’ or =‘1’ or (ms_tick ms_tick=‘1’ and d0_reg=9) else =‘1’ and d0_reg=9) else d0_reg+1 when d0_reg+1 when ms_tick ms_tick=‘1’ else =‘1’ else d0_reg; d0_reg; d0_tick <= d0_reg=9; d0_tick <= d0_reg=9;

slide-96
SLIDE 96

96

Stopwatch – VHDL Code

  • - next state logic

next state logic

  • - 1 sec counter

1 sec counter d1_en <= d1_en <= ms_tick ms_tick=‘1’ and d0_tick=‘1’; =‘1’ and d0_tick=‘1’; d1_next <= “0000” when d1_next <= “0000” when clr clr=‘1’ or =‘1’ or (d1_en=‘1’ and d1_reg=9) else (d1_en=‘1’ and d1_reg=9) else d1_reg+1 when d1_en=‘1’ else d1_reg+1 when d1_en=‘1’ else d1_reg; d1_reg; d1_tick <= d1_reg=9; d1_tick <= d1_reg=9;

  • - 10 second counter

10 second counter d2_en <= d1_en and d1_tick=‘1’; d2_en <= d1_en and d1_tick=‘1’; d2_next <= “0000” when d2_next <= “0000” when clr clr=‘1’ or =‘1’ or (d2_en=‘1’ and d2_reg=9) else (d2_en=‘1’ and d2_reg=9) else d2_reg+1 when d2_en=‘1’ else d2_reg+1 when d2_en=‘1’ else d2_reg; d2_reg;

slide-97
SLIDE 97

97

Stopwatch – VHDL Code

  • - output logic
  • utput logic

d0 <= d0_reg; d0 <= d0_reg; d1 <= d1_reg; d1 <= d1_reg; d2 <= d2_reg; d2 <= d2_reg; end architecture cascade; end architecture cascade;

slide-98
SLIDE 98

Non-Synthesizable VHDL

slide-99
SLIDE 99

99

Testbench Code

  • - clock generator

process begin clk <= ‘0’; wait for 10ns; clk <= ‘1’; wait for 10ns; end process;

slide-100
SLIDE 100

100

Testbench Code

  • - test vector generator

process process begin begin

  • - initialization

wait until wait until falling_edge(clk);

  • - generate some random inputs

wait until wait until rising_edge(clk);

  • - generate other random inputs

end end process process;

slide-101
SLIDE 101

101

Testbench Code

  • - test vector generator

process process begin begin ...

  • - generate randome inputs

for for i in in 1 to to 10 loop loop --wait for 10 cycles. wait until wait until rising_edge(clk); end loop; end loop;

  • - check if outputs are correct

end end process process;

slide-102
SLIDE 102

102

Delays

Delays are not synthesizable. Statements, such as wait for 5 ns a <= b after 10 ns will not produce the required delay, and should not be used in the code intended for synthesis.

slide-103
SLIDE 103

103

Signal Initialization

➜ Declarations of signals (and variables) with

initialized values, such as signal a : STD_LOGIC := 0; are allowed by Xilinx.

➜ Models become less portable ➜ Set and reset signals explicitly instead.

➜ Define reset logic for each synchronous process

slide-104
SLIDE 104

104

Dual-Edge Triggered Register/Counter

➜ In FPGAs, registers/counters change only on

either rising or falling edge of the clock, but not both.

➜ Dual edge triggered processes are not

synthesizable.

➜ A single process is sensitive to either rising edge or

falling edge, but not both, of the clock.

slide-105
SLIDE 105

105

Dual-Edge Triggered Register/Counter

PROCESS (clk) BEGIN IF rising_edge(clk ) THEN counter <= counter + 1; ELSIF falling_edge(clk) THEN counter <= counter + 1; END IF; END PROCESS;

slide-106
SLIDE 106

106

Dual-Edge Triggered Register/Counter

PROCESS (clk) BEGIN IF (clk’EVENT) THEN counter <= counter + 1; END IF; END PROCESS; PROCESS (clk) BEGIN counter <= counter + 1; END PROCESS;

process begin wait on clk then ... end if end process;

slide-107
SLIDE 107

107

Given a single signal, the assignments to this signal should

  • nly be made within a single process block in order to avoid

possible conflicts in assigning values to this signal.

Single Driver Rule for Signals

Process 1: PROCESS (a, b) BEGIN y <= a AND b; END PROCESS; Process 2: PROCESS (a, b) BEGIN y <= a OR b; END PROCESS;

slide-108
SLIDE 108

108

Backup

slide-109
SLIDE 109

109

7-Segment Display Multiplexer

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

CASESTUDY

89

an0 an1 a

, .

  • ,

.

I

an3 an2 an1 an0 1 1 1

Figure 4.5 Time-multiplexed seven-segment LED display. Figure 4.6 Timing diagram of a time-multiplexed seven-segment LED display.

A B C D E F G DP

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

slide-110
SLIDE 110

110

7-Segment Display Controller

library library ieee; use use ieee.std_logic_1164.all; all; use use ieee.numeric_std.all all; entity entity disp_mux is is port port(clk, reset : in in std_logic; in3, in2, in1, in0 : in in std_logic_vector(7 downto downto 0); an : out

  • ut std_logic_vector(3 downto

downto 0); sseg : out

  • ut std_logic_vector(7 downto

downto 0)); end entity end entity disp_mux;

slide-111
SLIDE 111

111

7-Segment Display Controller

architecture arch of architecture arch of disp_mux is is constant constant N : integer := 18; signal signal q_reg, q_next : unsigned(N-1 downto downto 0); signal signal sel : std_logic_vector(1 downto downto 0); begin begin process( process(clk, reset) begin begin if if reset=‘1’ then then q_reg <= (others

  • thers => ‘0’);

elsif elsif rising_edge(clk) then then q_reg <= q_next; end if; end if; end process; end process; q_next <= q_reg + 1;

counter

slide-112
SLIDE 112

112

7-Segment Display Controller

sel <= std_logic_vector(q_reg(N-1 downto downto N-2)); process( process(sel, in0, in1, in2, in3) begin begin case case sel is is when when “00” => an <= “1110”; sseg <= in0; when when “01” => an <= “1101”; sseg <= in1; when when “10” => an <= “1011”; sseg <= in2; when others when others => an <= “0111”; sseg <= in3; end case; end case; end process; end process; end architecture; end architecture;

How long does it take for ‘sel’ to change?

slide-113
SLIDE 113

113

Generic Component Instantiation

slide-114
SLIDE 114

114

ENTITY regn IS GENERIC ( N : INTEGER := 8 ) ; GENERIC ( N : INTEGER := 8 ) ; PORT (Enable, Clock : IN STD_LOGIC; D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0); Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0)); END regn; ARCHITECTURE Behavior OF regn IS BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN IF Enable = '1' THEN Q <= D ; END IF ; END IF; END PROCESS ; END Behavior ;

N-bit Register with Enable

Q D Enable Clock

regn

N N

slide-115
SLIDE 115

115

Circuit Built of Components

w w

3

y

1

y z w

1

w

2

w 1 En y 3 w y 2 y 1 y s(0) 1 s(1) 1 r(0) r(1) r(2) r(3) r(4) r(5) p(0) p(1) p(2) p(3) q(1) q(0) ena z(3) z(2) z(1) z(0)

dec2to4 priority

t(3) t(2) t(1) t(0)

regne

D Q

Clk Clock Enable

En

slide-116
SLIDE 116

116

ENTITY priority_resolver IS PORT( r : IN STD_LOGIC_VECTOR(5 DOWNTO 0); s : IN STD_LOGIC_VECTOR(1 DOWNTO 0); clk : IN STD_LOGIC; en : IN STD_LOGIC; t : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END priority_resolver; ARCHITECTURE structural OF priority_resolver IS SIGNAL p : STD_LOGIC_VECTOR (3 DOWNTO 0); SIGNAL q : STD_LOGIC_VECTOR (1 DOWNTO 0); SIGNAL z : STD_LOGIC_VECTOR (3 DOWNTO 0); SIGNAL ena : STD_LOGIC;

  • - continue on the next slide

Structural Description – VHDL-93

slide-117
SLIDE 117

117

BEGIN u1: ENTITY work.mux2to1(dataflow) PORT MAP( w0 => r(0), w1 => r(1), s => s(0), f => p(0)); p(1) <= r(2); p(2) <= r(3); u2: ENTITY work.mux2to1(dataflow) PORT MAP( w0 => r(4), w1 => r(5), s => s(1), f => p(3));

  • - continue on the next slide

Structural Description – VHDL-93

slide-118
SLIDE 118

118

u3: ENTITY work.priority(dataflow) PORT MAP (w => p, y => q, z => ena); u4: ENTITY work.dec2to4 (dataflow) PORT MAP (w => q, En => ena, y => z); u5: ENTITY work.regne(behavioral) GENERIC MAP (N => 4) PORT MAP (D => z, Enable => En, Clock => Clk, Q => t); END structural;

Structural Description – VHDL-93

slide-119
SLIDE 119

119

ENTITY ENTITY priority_resolver priority_resolver IS IS PORT ( PORT ( r : IN : IN STD_LOGIC_VECTOR( STD_LOGIC_VECTOR(5 DOWNTO 0); DOWNTO 0); s : IN : IN STD_LOGIC STD_LOGIC_VECTOR(1 DOWNTO 0) _VECTOR(1 DOWNTO 0); clk clk : IN STD_LOGIC; : IN STD_LOGIC; en en : IN STD_LOGIC; : IN STD_LOGIC; t t : OUT STD_LOGIC_VECTOR(3 : OUT STD_LOGIC_VECTOR(3 DOWNTO DOWNTO 0)); 0)); END END priority_resolver priority_resolver; ARCHITECTURE ARCHITECTURE structural structural OF OF priority_resolver priority_resolver IS IS SIGNAL p : STD_LOGIC_VECTOR (3 DOWNTO 0); SIGNAL p : STD_LOGIC_VECTOR (3 DOWNTO 0); SIGNAL q : STD_LOGIC_VECTOR (1 DOWNTO 0); SIGNAL q : STD_LOGIC_VECTOR (1 DOWNTO 0); SIGNAL SIGNAL z : STD_LOGIC_VECTOR (3 DOWNTO 0); : STD_LOGIC_VECTOR (3 DOWNTO 0); SIGNAL SIGNAL ena ena : STD_LOGIC; : STD_LOGIC;

  • - continue on the next slide

Structural Description – VHDL-87

slide-120
SLIDE 120

120

Structural Description – VHDL-87

COMPONENT mux2to1 PORT (w0, w1, s : IN STD_LOGIC; f : OUT STD_LOGIC); END COMPONENT; COMPONENT priority PORT (w : IN STD_LOGIC_VECTOR(3 DOWNTO 0); y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0); z : OUT STD_LOGIC ) ; END COMPONENT;

slide-121
SLIDE 121

121

COMPONENT dec2to4 PORT( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0); En : IN STD_LOGIC; y : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END COMPONENT; COMPONENT regn GENERIC(N : INTEGER := 8 ) ; PORT( D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0); En : IN STD_LOGIC; Clk : IN STD_LOGIC; Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0)); END COMPONENT ;

Structural Description – VHDL-87

slide-122
SLIDE 122

122

BEGIN u1: mux2to1 PORT MAP (w0 => r(0), w1 => r(1), s => s(0), f => p(0)); p(1) <= r(2); p(2) <= r(3); u2: mux2to1 PORT MAP (w0 => r(4), w1 => r(5), s => s(1), f => p(3)); u3: priority PORT MAP (w => p, y => q, z => ena); u4: dec2to4 PORT MAP (w => q, En => ena, y => z); u5: u5: regne regne GENERIC MAP (N => 4) GENERIC MAP (N => 4) PORT MAP PORT MAP ( D => z, D => z, En => En, En => En, Clk Clk => => Clk Clk, , Q => t); => t); END END structural structural;

Structural Description – VHDL-87

slide-123
SLIDE 123

123

architecture structural of ex is architecture structural of ex is begin begin U1 : ENTITY U1 : ENTITY work.regn work.regn(behavioral) (behavioral) GENERIC MAP (N => 4) GENERIC MAP (N => 4) PORT MAP PORT MAP (D => z, (D => z, Resetn Resetn => reset, => reset, Clock => Clock => clk clk, , Q => t ); => t );

  • - other concurrent statements
  • ther concurrent statements

end architecture structural; end architecture structural;

Component Instantiation in VHDL-93

Generic map is optional.

slide-124
SLIDE 124

124

architecture structural of ex is architecture structural of ex is component regn IS GENERIC (N : INTEGER := 16) GENERIC (N : INTEGER := 16) ; PORT( D : in in STD_LOGIC_VECTOR(N-1 downto downto 0); Resetn, Clock : in in STD_LOGIC; Q : out

  • ut STD_LOGIC_VECTOR(N-1 downto

downto 0)); end regn; begin begin U1: U1: regn regn GENERIC MAP (N => 8) GENERIC MAP (N => 8) PORT MAP PORT MAP( D => z, D => z, Resetn Resetn => reset , => reset , Clock => Clock => clk clk, Q => t); => t);

  • - other concurrent statements
  • ther concurrent statements

end architecture structural; end architecture structural;

Component Instantiation in VHDL-87

slide-125
SLIDE 125

125

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 can 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