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 05-17-2006, 03:38 PM
kunal
Guest
 
Posts: n/a
Default how i declare array for input port

hi
if i declare array for input port like input [1:0] in [7:0];
it is giving syntax error.
if i use reg then its ok but reg is use for input port.
my question is how to declare array for input port.

Reply With Quote
  #2 (permalink)  
Old 05-17-2006, 04:16 PM
Stephen Williams
Guest
 
Posts: n/a
Default Re: how i declare array for input port

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kunal wrote:
> hi
> if i declare array for input port like input [1:0] in [7:0];
> it is giving syntax error.
> if i use reg then its ok but reg is use for input port.
> my question is how to declare array for input port.
>


You can't have an array for a port, input or output, in Verilog.

- --
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEaz5frPt1Sc2b3ikRAruPAJwILkEHeyGpUvfbCdPKEH TR99qNsACfXh2w
7+828uQoHTTXptp9HkQFg8o=
=Gym/
-----END PGP SIGNATURE-----
Reply With Quote
  #3 (permalink)  
Old 05-17-2006, 07:52 PM
Ralf Hildebrandt
Guest
 
Posts: n/a
Default Re: how i declare array for input port

Stephen Williams wrote:

>> if i declare array for input port like input [1:0] in [7:0];


> You can't have an array for a port, input or output, in Verilog.


-> Transform the 2D-vector into a 1D-vector: input inp [15:0];
You map map it to a 2D-vector inside the module - if you really need it.

Ralf
Reply With Quote
  #4 (permalink)  
Old 05-18-2006, 03:03 PM
visiblepulse
Guest
 
Posts: n/a
Default Re: how i declare array for input port

input [15:0] in;

wire [1:0] in_A[0:7];
assign in_A[0] = in[1:0];
assign in_A[1] = in[3:2];
assign in_A[2] = in[5:4];
assign in_A[3] = in[7:6];
assign in_A[4] = in[9:8];
assign in_A[5] = in[11:10];
assign in_A[6] = in[13:12];
assign in_A[7] = in[15:14];

to access...
foo[1:0] <= in_A[4];
bar[1:0] <= in_A[1];

Reply With Quote
  #5 (permalink)  
Old 05-18-2006, 03:10 PM
kunal
Guest
 
Posts: n/a
Default Re: how i declare array for input port

but the wire is not supported
i used like
module mux8_1 (in, sel, out);
input [1:0] in [7:0];// input is array of 8 bit of 2 bit width
input[2:0] sel;
output[1:0] out;
reg[1:0] out;

always @(in or sel)
begin
case (sel)
3'b000 : out = in[0];
3'b001 : out = in[1];
3'b010 : out = in[2];
3'b011 : out = in[3];
3'b100 : out = in[4];
3'b101 : out = in[5];
3'b110 : out = in[6];
default : out = in[7];
endcase
end
endmodule
how i declare aaray having width like above to work mux properly.

Reply With Quote
  #6 (permalink)  
Old 05-18-2006, 06:44 PM
Jeremy Ralph
Guest
 
Posts: n/a
Default Re: how i declare array for input port


Certainly Ralf's wire technique is supported. Arrays are permitted for
wires or regs, but ARRAYS ARE NOT PERMITTED FOR INPUTS OR OUTPUTS IN
VERILOG as Steve already mentioned. Thus, arrays can only be used
*within* a module and you need to flatten the array into a single
dimensional vector for ports. Then wherever you instantiate the
module, you can map the input and outputs back into a array (reg or
wire) for ease of use in the instantiating (parent) module.

SystemVerilog supports array ports.



---
PDTi [ http://www.productive-eda.com ]
SpectaReg -- Spec-down code and doc generation for register maps


kunal wrote:
> but the wire is not supported
> i used like
> module mux8_1 (in, sel, out);
> input [1:0] in [7:0];// input is array of 8 bit of 2 bit width
> input[2:0] sel;
> output[1:0] out;
> reg[1:0] out;
>
> always @(in or sel)
> begin
> case (sel)
> 3'b000 : out = in[0];
> 3'b001 : out = in[1];
> 3'b010 : out = in[2];
> 3'b011 : out = in[3];
> 3'b100 : out = in[4];
> 3'b101 : out = in[5];
> 3'b110 : out = in[6];
> default : out = in[7];
> endcase
> end
> endmodule
> how i declare aaray having width like above to work mux properly.


Reply With Quote
  #7 (permalink)  
Old 05-18-2006, 06:50 PM
Jeremy Ralph
Guest
 
Posts: n/a
Default Re: how i declare array for input port

I think a generate statement can also be used for situations where N
(the number of array elements) gets unmanageable (or is generic). This
would be the same as above but would only have one assign statement,
wrapped in a generate block, and the indexes would be a function of the
generate index.

---
PDTi [ http://www.productive-eda.com ]
SpectaReg -- Spec-down code and doc generation for register maps

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
How do I make dual-port RAM from single port RAM? Frank @ CN Verilog 34 03-06-2006 12:33 PM
How is the input transition time used in calculating input delays ?? Rajat Mitra Verilog 2 10-13-2005 04:51 AM
Array input problem thomasc Verilog 2 03-10-2005 06:16 PM
making output port to bi-directional port! Vick Verilog 0 12-16-2004 06:14 AM
Making output-port to bi-directional-port! Vick Verilog 5 12-15-2004 06:03 AM


All times are GMT +1. The time now is 01:43 PM.


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