Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[help]what's the problem with my verilog program?

Status
Not open for further replies.

bigrice911

Member level 3
Member level 3
Joined
Apr 27, 2004
Messages
65
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
500
range must be bounded by constant expressions.

I made a program but when it prompts errors when compile.
Range must be bounded by constant expressions

Code:
function [8*`w-1:0] cast;
input	[`w-1:0] 	data_i;
input	[2:0] 	addr_i;

integer	index; 
for(index=0; index<8; index=index+1)
	if(addr_i == index)
		cast[`w*index+7: `w*index] = data_i; //Range must be bounded by constant expressions	
    else
		cast[`w*index+7: `w*index] = 'bZ; 

endfunction

faint! most verilog compilers do not support this statement!
can anybody give me some hints? thanks!
 

range must be bounded by constant expressions

[...]
u can try other ways
use shift
cast = data_i << addr_i * 'w;
:it cant asign 'bZ

or use mem
reg [`w-1:0] cast [2:0]
for () cast[index] = `w'bz;
cast[addr_i] = data_i;
:it not fit function
 

verilog range bounds are not constants

Verilog Assignment Rule:
part select must constant,
but bit select no limit in procedure assign:
so can use another method,
for(ii = 0;ii<8;ii=ii+1)
if (ii == addr_i)
for(jj = 0;jj<`w;jj=jj+1)
cast[ii*`w+jj] = data_i[jj];
else
for(jj = 0;jj<`w;jj=jj+1)
cast[ii*`w+jj] = 1'bz;
 

xigu, thank you so much!
your answer made me understood my error and your solution DOSE work!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top