Web tutorialWire Assignments


A wire can be declared and continuously assigned in a single statement - a wire assignment. This is a shortcut which saves declaring and assigning a wire separately. There are no advantages or disadvantages between the two methods other than the obvious difference that wire assignments reduce the size the the text.

Later on we will discuss delays on assignments and wires. A delay in a wire assignment is equivalent to a delay in the corresponding continuous assignment, not a delay on the wire. Thus it could be necessary to separate the wire declaration from the continuous assignment to put the delay onto the wire rather than the assignment. Note that this is a subtle point that you are unlikely to encounter in practice!

Note the use of a block comment in the Verilog code, rather than the line comments we have seen so far.

Verilog: Using wire assignments to describe an AOI gate module

// Verilog code for AND-OR-INVERT gate 

module AOI (A, B, C, D, F);
  input A, B, C, D;
  output F;

/*  start of a block comment
  wire F;  
  wire AB, CD, O;  
  assign AB = A & B;  
  assign CD = C & D;  
  assign O = AB | CD;  
  assign F = ~O;

end of a block comment
*/

// Equivalent... 
 
  wire AB = A & B;  
  wire CD = C & D;  
  wire O = AB | CD;  
  wire F = ~O;

endmodule

// end of Verilog code 

So in this sample code, each of the wire declarations and its corresponding assign statement are effectively merged into one wire assignment.


help iconVerilog FAQ
teaching pointerDoulos Training Courses
Web tutorialReturn to Hardware Designers Guide Contents


river sceneDoulos Home Page

Copyright 1995-1997 Doulos
This page was last updated 15th November 1996.

mail iconWe welcome your e-mail comments. Please contact us at: webmaster@doulos.co.uk