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 > Wires and Registers

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Wires and Registers

FONT SIZE : AAA

Once a module has been declared and its ports defined, it is then necessary to make those available internally to the module for use as connections. The most basic connection type is called a wire and this is exactly as its name suggests, simply a direct connection. 

If we take our counter example, in order to make each port available for internal coding, we need to setup a wire for each input. These are defined using the wire keyword and the extended module is given as follows: 

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 / wire definitions

12 wire clk;

13 wire rst;

14

15 /contents of the model here

16

17 endmodule

But what about the counter output? Why did we not simply assign a wire type to the dout variable? The answer is that wire is essentially combinatorial (i.e., a direct connection) whereas the output is synchronous and needs to be held in a register. In Verilog we denote this using the reg keyword rather than the simple wire and so the dout variable needs to be defined as shown below. Notice that the declaration of the register also needs to have the bus defined in an identical manner to the port declaration. 

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 / wire definitions

12 wire clk;

13 wire rst;

14

15 / Register definitions

16 reg [7:0] dout;

17

18 /contents of the model here

19

20 endmodule


  • XCR3512XL-12PQG208I

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

    Manufacturer:Xilinx

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

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC2S400E-7FTG256C

    Manufacturer:Xilinx

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

    Lifecycle:Obsolete -

    RoHS:

  • XC3S250E-4VQ100I

    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-5TQG144C

    Manufacturer:Xilinx

  • FPGA Spartan-3E Family 250K Gates 5508 Cells 657MHz 90nm Technology 1.2V 144-Pin TQFP EP
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS:

Need Help?

Support

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