FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-29-2006, 07:46 PM
paz
Guest
 
Posts: n/a
Default array of instances

Hi,


Does anyone know how array of instance works in verilog?

For example:

I found an example like this:

wire[2:0] in;
wire[2:0] out;
wire ctrl;

bufif0 u[2:0] (out, in, ctrl);

I read that Each primitive instantiation is done separately, and
actually this equals to:

bufif0 u2 (out[2], in[2], ctrl);
bufif0 u1 (out[1], in[1], ctrl);
bufif0 u0 (out[0], in[0], ctrl);

How does verilog "know" to divide out to 3 for 3 instances, but to
connect all instances to ctrl (which is only one bit)?

How does it work?

Reply With Quote
  #2 (permalink)  
Old 11-29-2006, 10:54 PM
Guest
 
Posts: n/a
Default Re: array of instances

IME, Verilog "sign extends" to fill. That is, the highest order bit is
replicated in the remaining positions. (It may replicate, but in this
example, there is no difference.)

ctrl can be though of as ctrl[0:0]. So where it "wanted" bits 2 and 1,
the "MSB" of ctrl[0:0] (aka ctrl) is connected.

(If it replicates, the intermediate term would be
{ctrl[0:0],ctrl[0:0],ctrl[0:0]}.)

Hope that helps,
GH


paz wrote:
> Hi,
>
>
> Does anyone know how array of instance works in verilog?
>
> For example:
>
> I found an example like this:
>
> wire[2:0] in;
> wire[2:0] out;
> wire ctrl;
>
> bufif0 u[2:0] (out, in, ctrl);
>
> I read that Each primitive instantiation is done separately, and
> actually this equals to:
>
> bufif0 u2 (out[2], in[2], ctrl);
> bufif0 u1 (out[1], in[1], ctrl);
> bufif0 u0 (out[0], in[0], ctrl);
>
> How does verilog "know" to divide out to 3 for 3 instances, but to
> connect all instances to ctrl (which is only one bit)?
>
> How does it work?


Reply With Quote
  #3 (permalink)  
Old 11-29-2006, 11:14 PM
Guest
 
Posts: n/a
Default Re: array of instances

The rules for instance array connects (taken from the Verilog LRM)...

The terminal connections for an array of instances shall follow these
rules:

1) The bit length of each port expression in the declared
instance-array shall be compared with the bit length of each
single-instance port or terminal in the instantiated module or
primitive.
2) For each port or terminal where the bit length of the instance-array
port expression is the same as the bit length of the single-instance
port, the instance-array port expression shall be connected to each
single-instance port.
3) If bit lengths are different, each instance shall get a part-select
of the port expression as specified in the range, starting with the
right-hand index.

Too many or too few bits to connect to all the instances shall be
considered an error.

David Walker

[email protected] wrote:
> IME, Verilog "sign extends" to fill. That is, the highest order bit is
> replicated in the remaining positions. (It may replicate, but in this
> example, there is no difference.)
>
> ctrl can be though of as ctrl[0:0]. So where it "wanted" bits 2 and 1,
> the "MSB" of ctrl[0:0] (aka ctrl) is connected.
>
> (If it replicates, the intermediate term would be
> {ctrl[0:0],ctrl[0:0],ctrl[0:0]}.)
>
> Hope that helps,
> GH
>
>
> paz wrote:
> > Hi,
> >
> >
> > Does anyone know how array of instance works in verilog?
> >
> > For example:
> >
> > I found an example like this:
> >
> > wire[2:0] in;
> > wire[2:0] out;
> > wire ctrl;
> >
> > bufif0 u[2:0] (out, in, ctrl);
> >
> > I read that Each primitive instantiation is done separately, and
> > actually this equals to:
> >
> > bufif0 u2 (out[2], in[2], ctrl);
> > bufif0 u1 (out[1], in[1], ctrl);
> > bufif0 u0 (out[0], in[0], ctrl);
> >
> > How does verilog "know" to divide out to 3 for 3 instances, but to
> > connect all instances to ctrl (which is only one bit)?
> >
> > How does it work?


Reply With Quote
  #4 (permalink)  
Old 11-30-2006, 01:12 AM
paz
Guest
 
Posts: n/a
Default Re: array of instances

Thanks a lot!


[email protected] лъб:
> The rules for instance array connects (taken from the Verilog LRM)...
>
> The terminal connections for an array of instances shall follow these
> rules:
>
> 1) The bit length of each port expression in the declared
> instance-array shall be compared with the bit length of each
> single-instance port or terminal in the instantiated module or
> primitive.
> 2) For each port or terminal where the bit length of the instance-array
> port expression is the same as the bit length of the single-instance
> port, the instance-array port expression shall be connected to each
> single-instance port.
> 3) If bit lengths are different, each instance shall get a part-select
> of the port expression as specified in the range, starting with the
> right-hand index.
>
> Too many or too few bits to connect to all the instances shall be
> considered an error.
>
> David Walker
>
> [email protected] wrote:
> > IME, Verilog "sign extends" to fill. That is, the highest order bit is
> > replicated in the remaining positions. (It may replicate, but in this
> > example, there is no difference.)
> >
> > ctrl can be though of as ctrl[0:0]. So where it "wanted" bits 2 and 1,
> > the "MSB" of ctrl[0:0] (aka ctrl) is connected.
> >
> > (If it replicates, the intermediate term would be
> > {ctrl[0:0],ctrl[0:0],ctrl[0:0]}.)
> >
> > Hope that helps,
> > GH
> >
> >
> > paz wrote:
> > > Hi,
> > >
> > >
> > > Does anyone know how array of instance works in verilog?
> > >
> > > For example:
> > >
> > > I found an example like this:
> > >
> > > wire[2:0] in;
> > > wire[2:0] out;
> > > wire ctrl;
> > >
> > > bufif0 u[2:0] (out, in, ctrl);
> > >
> > > I read that Each primitive instantiation is done separately, and
> > > actually this equals to:
> > >
> > > bufif0 u2 (out[2], in[2], ctrl);
> > > bufif0 u1 (out[1], in[1], ctrl);
> > > bufif0 u0 (out[0], in[0], ctrl);
> > >
> > > How does verilog "know" to divide out to 3 for 3 instances, but to
> > > connect all instances to ctrl (which is only one bit)?
> > >
> > > How does it work?


Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
array of instances paz Verilog 0 11-29-2006 07:46 PM
Using contents of one array to index into another array kb33 Verilog 3 10-08-2006 08:12 PM
array of instances with a different parameters [email protected] Verilog 1 08-24-2006 03:49 PM
Initializing array of BlockRAM instances in verilog [email protected] Verilog 1 04-22-2006 09:09 AM
array of module instances sridhar Verilog 3 02-27-2004 04:02 AM


All times are GMT +1. The time now is 06:14 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved