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:15 AM
daluu
Guest
 
Posts: n/a
Default parameterized mux issue

I'm working on a lab which has given parameterized mux code but has compile
problems in ModelSim and we are supposed to fix it.

The code below gives a range must be bounded by constant expression
error:

-----------
for(Index = 0; Index < N_channel; Index = Index +1)
if(Index == Sel)
D_out = D_in[Data_width*Index+Data_width-1ata_width*Index];
else
D_out = 8'bx;
------------

I found a possible workaround in from a post in this forum, don't have URL
at moment, but that just fixes the bound error but the simulation is
incorrect.

I'm using a inner for loop to handle assigning the data from input to
output bit by bit. I believe the problem lies in the outer for loop or the
if/else statement.

When I run a simulation in modelsim, the output is always 8'bx unless Sel
= 3. When sel = 3, then it selects the appropriate section of input as
output. So it looks like 90% of the time, all output is set by the else
section. And I have set a range of values for Sel in the testbench but
like I said only sel=3 outputs the right result other sel values come up
as 8'bx when it shouldn't.

Did I miss something in the code that causes this?



Reply With Quote
  #2 (permalink)  
Old 10-01-2004, 02:25 PM
pranav
Guest
 
Posts: n/a
Default Re: parameterized mux issue

"daluu" <[email protected]> wrote in message news:<[email protected] alkaboutprogramming.com>...
> I'm working on a lab which has given parameterized mux code but has compile
> problems in ModelSim and we are supposed to fix it.
>
> The code below gives a range must be bounded by constant expression
> error:
>
> -----------
> for(Index = 0; Index < N_channel; Index = Index +1)
> if(Index == Sel)
> D_out = D_in[Data_width*Index+Data_width-1ata_width*Index];
> else
> D_out = 8'bx;
> ------------
>

The D_out does not seem to be a single bit, is it ok?
Reply With Quote
  #3 (permalink)  
Old 10-03-2004, 05:39 AM
daluu
Guest
 
Posts: n/a
Default Re: parameterized mux issue

D_out is an 8-bit array. works ok only when sel is 3.

Reply With Quote
  #4 (permalink)  
Old 10-04-2004, 07:41 PM
John_H
Guest
 
Posts: n/a
Default Re: parameterized mux issue

Suppose your Sel is 2.
Your loop will go through Index values of 0 and 1 with D_out assigned 8'bx
each time.
When you hit Index 2, the D_out will be assigned D_in>>2*Data_width (limited
to the D_out width).
Then you go to your last Index value of 3 (N_channel) which reassigns D_out
to 8'bx.

What is the 8'bx intended *for* anyway?


"daluu" <[email protected]> wrote in message
news:[email protected] lkaboutprogramming.com...
> I'm working on a lab which has given parameterized mux code but has

compile
> problems in ModelSim and we are supposed to fix it.
>
> The code below gives a range must be bounded by constant expression
> error:
>
> -----------
> for(Index = 0; Index < N_channel; Index = Index +1)
> if(Index == Sel)
> D_out = D_in[Data_width*Index+Data_width-1ata_width*Index];
> else
> D_out = 8'bx;
> ------------
>
> I found a possible workaround in from a post in this forum, don't have URL
> at moment, but that just fixes the bound error but the simulation is
> incorrect.
>
> I'm using a inner for loop to handle assigning the data from input to
> output bit by bit. I believe the problem lies in the outer for loop or the
> if/else statement.
>
> When I run a simulation in modelsim, the output is always 8'bx unless Sel
> = 3. When sel = 3, then it selects the appropriate section of input as
> output. So it looks like 90% of the time, all output is set by the else
> section. And I have set a range of values for Sel in the testbench but
> like I said only sel=3 outputs the right result other sel values come up
> as 8'bx when it shouldn't.
>
> Did I miss something in the code that causes this?
>
>
>



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
Re: One issue about free hardware Tom Hawkins Verilog 6 05-18-2004 07:24 PM
bottom up synthesis with parameterized design Marco Lazar Verilog 0 04-22-2004 07:38 PM
VHDL+verilog design, strange simulation issue Akshaye Verilog 1 02-11-2004 09:28 AM
Subtle Verilog Scheduling Issue Stephen Williams Verilog 11 09-09-2003 01:44 AM


All times are GMT +1. The time now is 06:40 PM.


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