recursive instantiations of modules


Subject: recursive instantiations of modules
From: VhdlCohen@aol.com
Date: Fri Mar 08 2002 - 14:42:53 PST


An interesting question came up:
Do we allow ib Verilog ('95 or '01) recursive instantiation of modules?
Below is an example:
module my_not(out, in);
input in;
output out;

my_not inst(out, in);

endmodule

module bin2gray (gray, bin);
  parameter SIZE = 4;
  output [SIZE-1:0] gray;
  input [SIZE-1:0] bin;
  assign gray = (bin>>1) ^ bin;
  my_not gray_1(gray, bin);
endmodule

for the record, compilation in NC-Sim and and ModelSim yielded the following:

%ncvlog testrec.v
ncvlog: v03.30.(p001): (c) Copyright 1995 - 2001 Cadence Design Systems, Inc.

%ncelab bin2gray
ncelab: v03.30.(p001): (c) Copyright 1995 - 2001 Cadence Design Systems, Inc.
ncelab: *W,CUSRCH: Resolved module/udp 'my_not' at 'gray_1' to
'work_lib.my_not:module' through a global search of all libraries.
ncelab: *E,CUTODP: maximum design hierarchy component instance depth (64)
exceeded.
       Module instantiation:
bin2gray.gray_1.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.in

st.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.

inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.ins

t.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.inst.i

nst.inst.inst.inst
%
%vlog testrec.v
Model Technology ModelSim SE vlog 5.5a Compiler 2001.04 Apr 5 2001
-- Compiling module my_not
-- Compiling module bin2gray

Top level modules:
    bin2gray
Simulation in ModelSim crashed, and exited after elaboration.

In the context of generates sometimes it may result in limited recursion
and create hardware. Someone might argue about this and I
dont have anything to show why this would be illegal usage.

From a hardware point of view I am failing to visualize how a module can
instantiate itself, when it was not completely defined.
 
Recursive functions (e.g., factorial), the function terminates when the
actual is a 1.
Factorial (x) function calls factorial(x-1), but stops when (x-1) = 1. In
hardware though, I would have difficulty visualizing this because:
  1. There is no STOP. I guess you could instantiate a module where last
instance is itself with no components ?
     (ambiguous)
   2. Drivers. Multiple drivers would result.

Bottom line, I don't know if Vlog2001 would allow this (I don't think so, but
even if it did, the whole thing does NOT make sense and should be discouraged
as a design mechanism.
Recursive functions: OK.
Recursive modules: NO I challenge anyone to try to explain what that means!

Is there anyone out there who has seen or applied this module recursion
before?
I am amazed how Verilog would compile almost anything!
Comments?
Thanks,
Ben
----------------------------------------------------------------------------
Ben Cohen Publisher, Trainer, Consultant (310) 721-4830
<A HREF="http://www.vhdlcohen.com/">http://www.vhdlcohen.com/> vhdlcohen@aol.com
Author of following textbooks:
* Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn
0-9705394-2-8
* Component Design by Example ", 2001 isbn 0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------



This archive was generated by hypermail 2b28 : Fri Mar 08 2002 - 14:50:49 PST