using module instantiation outputs in procedural block

T

thomasc

Guest
Suppose I have a module named 'abc' and I'm instantiating it in another
module multiple times. I was wondering if I can refer to the outputs from
the instantiation by writing something like 'A1.out'. (below is the
abstract of what i mean). Is it possible? if not, how can I use outputs
from module instantiations inside a procedural block?

================

module abc(a,b,c);
input b,c;
output a;
...
endmodule

module higher_level(...);
reg temp1, temp2;
...
abc A1 (a, b, c); //a is the output from
abc A2 (a, d, e); //the module abc

always
...
temp1 = A1.a;
...
temp2 = A2.a;
...
end //always
endmodule //higher_level
 
thomasc wrote:
Suppose I have a module named 'abc' and I'm instantiating it in
another module multiple times. I was wondering if I can refer to the
outputs from the instantiation by writing something like 'A1.out'.
(below is the abstract of what i mean). Is it possible? if not, how
can I use outputs from module instantiations inside a procedural
block?
Connect the pin of the instantiated module to a wire with a unique name.
Use the wire. If this becomes tedious, look at the xemacs "AUTOINST" and
"AUTO_TEMPLATE" functions.

I recommend wiring instantiations by named association, not positional
association.

In the example you give, wire a is driven by two different instantiations -
this is fine only if it is a tri-state wire. If you are synthesising I
suspect it is not. Incidentally, even though you don't use your wire a, it
will still cause you problems (inputs and outputs are in fact normally
bi-directional).

Anyway, I'll rework your code the way I would write it:

================

module abc(a,b,c);
input b,c;
output a;
..
endmodule

module higher_level(...);
reg temp1, temp2;
wire a1, a2;
..
abc A1 (
.a (a1),
.b (b),
.c (c)
);
abc A2 (
.a (a2),
.b (d),
.c (e)
);
always
begin
..
temp1 = a1;
..
temp2 = a2;
..
end //always
endmodule //higher_level
--
John Penton, posting as an individual unless specifically indicated
otherwise.
 

Welcome to EDABoard.com

Sponsor

Back
Top