Top Banner
Chap. 4 Modules and Ports
28

Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

Dec 13, 2015

Download

Documents

Moses Moody
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

Chap. 4 Modules and Ports

Page 2: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

2

Modules and Ports

Modules Ports Hierarchical Names Summary

Page 3: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

3

Modules

Basic component in Verilog for describing/defining a hardware

module <module_name> (<module_terminal_list>);<I/O declaration><parameter declaration>…<module internals>……endmodule

Page 4: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

4

Components of Modules - I

Variables Declaration Dataflow Statement Module Instantiation Behavior Statement Tasks and Functions

Page 5: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

5

Components of Modules - II

These components are optional!

Page 6: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

6

An Example – SR Gate

Page 7: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

7

Module Description of SR Gate

No “variable declaration”, “dataflow statement” and “behavioral statement” are included in this module

Page 8: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

8

Testbench for SR Gate

Page 9: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

9

Modules and Ports

Modules Ports Hierarchical Names Summary

Page 10: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

10

Ports

I/O Interface used to communicate with external module

“No” port declaration if do not need to communicate with other module, such as Top module

Page 11: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

11

Module fulladd4 has five ports while top has no port.a, b, and c_in are input ports and sum and c_out are output ports.

List of Ports - I

Page 12: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

12

List of Ports - II

Page 13: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

13

Port Declaration

Three types input output inout

Page 14: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

14

Port Declaration of fulladd4

Default data type of I/O ports is regarded as “wire”.

Page 15: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

15

Port Declaration of D Flip-Flop

Page 16: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

16

ANSI C Port Declaration

Page 17: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

17

Input Port Internal view - viewed as “a wire/net” External view - can be connected to a reg or wire

Output Port Internal view - declared as a reg or wire External view - only be connected to a wire

Inout Port viewed as a wire/net regardless of internal or extern

al module

Port Connection Rules - I

Page 18: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

18

Port Connection Rules - II

Page 19: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

19

Mismatch of internal and external port connections Simulation should issue a warning for this conditio

n Floating of port connection

Fulladd4 fa0(sum, , a, b, c_in); // c_out floating

Illegal connection of internal and external ports

Port Connection Rules - II

Page 20: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

20

An Example of Illegal Internal/External Port Connection

Page 21: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

21

Connecting Ports to External Signals Connecting ports by module declaration

sequence Connecting ports by name

Page 22: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

22

Connecting Ports by Module Declaration Sequence

Page 23: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

23

Connecting Ports by Name Fulladd4 fa_byname(.c_out(c_out), .sum(sum),

.b(b), .c_in(c_in), .a(a));

Fulladd4 fa_byname(.sum(sum), .b(b),

.c_in(c_in), .a(a));

Page 24: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

24

Modules and Ports

Modules Ports Hierarchical Names Summary

Page 25: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

25

Hierarchical Names

Named each instance, variables and signals in hierarchical design

Root module Never be referenced by other modules, such as

stimulus Hierarchical instances are separated by dot

sign “.” $display (“%m”)

display hierarchical level of that module

Page 26: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

26

An Example of Hierarchical Names

Page 27: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

27

Modules and Ports

Modules Ports Hierarchical Names Summary

Page 28: Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.

28

Summary

A module contains module, endmodule keyword Port list, port declaration, variable declaration, dataflow statement,

behavioral block, module instantiation, task and function Ports provide an interface communicated with external environm

ent Input, output, inout

Connecting ports to external signals By port declaration sequence By port name

Hierarchical name Root module Separated by “.” between instances