This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > A Verilog Primer: The Essentials > Connections

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Connections

FONT SIZE : AAA

Once we have a basic module definition (with a name) the next step is to connect it up. Consider the example of an 8-bit counter that has a clock (clk) and reset (rst) input, with the output word defined as dout (7 down to 0) The module definition needs to be modified to include the names of the ports in the header as shown here: 

1 module counter (clk,rst,dout);

2

3 /contents of the model here

4

5 endmodule

The module can also be written with the port names spread over several lines such as:

1 module counter (

2 clk,

3 rst,

4 dout

5 );

6

7 /contents of the model here

8

9 endmodule

The obvious question is “why would we do that?” However, this way makes it simple to add descriptive comments next to each port name definition, which can be extremely helpful in debugging the model. 

Comments in Verilog use the / notation (the same as in C++) and so we could write the module header with some additional comments as shown below. As you can see, we can put helpful comments such as the active clock edge (rising or falling), whether the reset signal is active high or low, and finally the width of the dout variable. 

1 module counter (

2 clk, / Clock Signal (Rising Edge)

3 rst, / reset Signal (Active High)

4 dout / Counter Output (7:0)

5 );

6

7 /contents of the model here

8

9 endmodule

The final step at this point of model creation is to define the type of the ports, in terms of direction. For example, are they inputs, outputs or both? Also, what is the width of the bus if they are composite (multiple value) ports? In this simple example, the clk and rst ports are both inputs, and the dout port is an output, of width 8 (tagged with indices 7 down to 0 in classical digital designer format). 

This definition is done using the keywords input, output or inout and the expanded port definitions are given here.

1 module counter (

2 clk, / Clock Signal (Rising Edge)

3 rst, / reset Signal (Active High)

4 dout / Counter Output (7:0)

5 );

6 / port declarations

7 input clk;

8 input rst;

9 output [7:0] dout;

10

11 /contents of the model here

12

13 endmodule


  • XCR3512XL-12PQG208C

    Manufacturer:Xilinx

  • CPLD CoolRunner XPLA3 Family 12K Gates 512 Macro Cells 77MHz 0.35um Technology 3.3V 208-Pin PQFP
  • Product Categories: CPLDs

    Lifecycle:Active Active

    RoHS:

  • XCR3512XL-7FTG256C

    Manufacturer:Xilinx

  • CPLD CoolRunner XPLA3 Family 12K Gates 512 Macro Cells 135MHz 0.35um Technology 3.3V 256-Pin FTBGA
  • Product Categories: CPLDs

    Lifecycle:Unconfirmed -

    RoHS:

  • XC2S400E-7FT256C

    Manufacturer:Xilinx

  • FPGA Spartan-IIE Family 400K Gates 10800 Cells 400MHz 0.15um Technology 1.8V 256-Pin FTBGA
  • Product Categories:

    Lifecycle:Obsolete -

    RoHS: No RoHS

  • XC3S250E-4VQ100C

    Manufacturer:Xilinx

  • FPGA Spartan-3E Family 250K Gates 5508 Cells 572MHz 90nm Technology 1.2V 100-Pin VTQFP
  • Product Categories: FPGAs

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC3S250E-5PQ208C

    Manufacturer:Xilinx

  • FPGA Spartan-3E Family 250K Gates 5508 Cells 657MHz 90nm Technology 1.2V 208-Pin PQFP
  • Product Categories: FPGAs

    Lifecycle:Active Active

    RoHS: No RoHS

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.