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 10-01-2004, 03:04 AM
daluu
Guest
 
Posts: n/a
Default accessing 2D arrays in Verilog

I'm just learning Verilog in my Digital Design class. We focus more on
module design using Verilog than the actual verilog language.

I see these lines in code in our lab projects:

reg [N_channel*Data_width-1:0] in_tb_array[999:0];
...
...
Result_array[i] <= [Data_width-1:0] in_tb_array[i];

This line gave compile problems in ModelSim.

I would believe by traditional programming construct the way to write it
the array assignment would be:

Result_array[i] <= in_tb_array[i][Data_width-1:0];

This didn't give any compile errors. It appears to work in simulation, so
I just wanted to verify that my line of code is correct or not.

Reply With Quote
  #2 (permalink)  
Old 10-01-2004, 02:30 PM
pranav
Guest
 
Posts: n/a
Default Re: accessing 2D arrays in Verilog

"daluu" <[email protected]> wrote in message news:<[email protected] alkaboutprogramming.com>...
> I'm just learning Verilog in my Digital Design class. We focus more on
> module design using Verilog than the actual verilog language.
>
> I see these lines in code in our lab projects:
>
> reg [N_channel*Data_width-1:0] in_tb_array[999:0];
> ..
> ..
> Result_array[i] <= [Data_width-1:0] in_tb_array[i];
>
> This line gave compile problems in ModelSim.
>
> I would believe by traditional programming construct the way to write it
> the array assignment would be:
>
> Result_array[i] <= in_tb_array[i][Data_width-1:0];
>
> This didn't give any compile errors. It appears to work in simulation, so
> I just wanted to verify that my line of code is correct or not.


I think Result_array[i] <= in_tb_array[i]; should be enough.
Reply With Quote
  #3 (permalink)  
Old 10-03-2004, 05:37 AM
daluu
Guest
 
Posts: n/a
Default Re: accessing 2D arrays in Verilog

yea I just noticed that after readin your post. But what if I wanted only a
segment of the data width. Is my line of code correct?

Reply With Quote
  #4 (permalink)  
Old 10-04-2004, 07:43 PM
John_H
Guest
 
Posts: n/a
Default Re: accessing 2D arrays in Verilog

Yes.

As long as your tool is fully Verilog 2001 compliant. I'm using a tool
which *still* doesn't have the 2-D array "part select" supported which would
correspond to the final [Data_width-1:0] reference.

"daluu" <[email protected]> wrote in message
news:[email protected] lkaboutprogramming.com...
> yea I just noticed that after readin your post. But what if I wanted only

a
> segment of the data width. Is my line of code correct?



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
Arrays of Instances John_H Verilog 1 07-30-2004 12:07 AM
assigning to multidimensional arrays Greg Tumbush Verilog 1 05-12-2004 07:02 PM
Verilog Instance Arrays and Synopsys DC? Marty Verilog 3 03-04-2004 07:25 PM
Why syntax error when accessing bits of an array word? Gammaburst Verilog 3 10-31-2003 10:05 AM
Accessing Simulator Event Queue! Hrh Verilog 1 08-23-2003 07:36 PM


All times are GMT +1. The time now is 02:27 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