D
daluu
Guest
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?
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?