element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs My Verilog Diary - 1: Modules and Ports
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: msimon
  • Date Created: 7 Oct 2017 9:33 AM Date Created
  • Views 301 views
  • Likes 4 likes
  • Comments 2 comments
  • my_verilog_diary
Related
Recommended

My Verilog Diary - 1: Modules and Ports

msimon
msimon
7 Oct 2017

A module is basic building block Verilog. Ports are the interface which module communicate with the environment, in other words, inputs and outputs of the module.

 

We can assume module as a design box and ports are inputs and outputs of that box. The design box can provide a functionality to higher levels while hiding its internal connection. The analogy reminds me libraries in programming. The following example shows the structure of the module.

 

module <module_name> (<port_list>);
  
  ...
  
  internal_of_module
  
  ...
    
endmodule

 

Verilog module can be described in four levels of abstraction. The method you use doesn't affect the usage of the module. It will appear as a functional box from outside. The inside can use any design methodologies at the end all will be translated to boolean equations.

 

These design methods are:

 

Behaviour and Algorithmic Level

This is the most abstract level of the hardware design. It is similar to C language programming.

 

Dataflow Level

In this level, the designer specifies the data flow.

 

Gate Level

This design is achieved by describing logic gates and interconnections between them.

 

Switch Level

This is the lowest level of abstraction. A module is defined with switches, storage nodes, and interconnection between them.

 

 

Let's give an example to a module. The example will be an implementation of 74F08 Quad 2-Input AND Gate.

 

/*
* Program: implementation of 74F08 (Quad 2-Input AND Gate)
* Version: v1.0
* Autor: Mehmet Bozdal
* Date: 1.10.2017
*/


module ic_74F08 (A,B,O);
  
  //input output decleration
  input [3:0] A;
  input [3:0] B;
  output [3:0] O;
  
  //internal connection
  assign O = A & B;


    
endmodule

 

The module_name is ic_74F08 which has inputs A and B and output O. The only connection is done by assign keyword. Assign is the continues assignment statement. It is used only for modelling combinational circuits. You can also use logic gates which are described in Verilog functions. In that case, assign O = A & B; should be replaced by and(O,A,B) which is gate level modelling.

 

image

The RTL view of the design is the same as the datasheet of 74F08.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

The video above shows how the design work on actual FPGA board. In order to upload your code to FPGA, you can follow instructions on your board's user manual. It is already defined step by step on DE0 Nano's user manual.

 

I said modules can be used to provide a functionality to higher levels. The process is called instantiation and the module created is called instance. Imagine you need two 74F08 in one design. You can instantiate our previous design and use it more than once. I need to warn you we are not calling a function here. We create actual hardware and each instantiation is a real hardware implementation.

 

/*
* Program: instantiation of 74F08 (Quad 2-Input AND Gate)
* Version: v1.0
* Autor: Mehmet Bozdal
* Date: 1.10.2017
*/




module ic_74F08_double (Ain,Bin,Out);
  
  //input output decleration
  input [7:0] Ain;
  input [7:0] Bin;
  output [7:0] Out;
  
  //instantiation of icle_74F08 module
  ic_74F08 first_74F08 (Ain[3:0],Bin[3:0],Out[3:0]);
  ic_74F08 second_74F08 (Ain[7:4],Bin[7:4],Out[7:4]);
   
endmodule

 

 

The instantiation is done by writing module name followed by instance name and connections of the module. The instance name is not compulsory but it is good practice to give a name. [7:0] Ain is an eight-bit vector. Ain[3:0] is least significant half of that vector.

 

If we look at the RTL view of the design, there are two identical ic_74F08 design. They have different inputs and outputs.

image

The RTL view of the design has two ic_74F08 boxes which are explored in the previous RTL view.

 

To see My Verilog Diary you can search for my_verilog_diary or go to the initial article My Verilog Diary - 0 : Introduction. If you have any question, please comment image

  • Sign in to reply

Top Comments

  • djfraz
    djfraz over 5 years ago +1
    Great introduction to verilog. looking forward to the rest of your blog
  • msimon
    msimon over 5 years ago in reply to djfraz +1
    Thank you djfraz
  • msimon
    msimon over 5 years ago in reply to djfraz

    Thank you djfraz image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • djfraz
    djfraz over 5 years ago

    Great introduction to verilog. looking forward to the rest of your blog

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube