Boris_Troyanovsky
New Member
Offline
Posts: 1
|
Hi Yongjin,
It looks as though your intent is to set individual bits within "result" to indicate whether V(in[i]) is above or below a certain threshold. However, declaring "result" as
integer result [0:3];
will give you an array of four integers, and not four bits. The compiler reports an error on the "case(result)" line because it expects to receive an integer value, rather than an array of integers (it could concatenate the integers together into a big bitfield, but I don't think that would give you the result that you expect based on your case-stmnt contents).
The way to address this issue is to simply use
integer result;
as your datatype, since a single integer contains more than four bits. You can then use bitwise ops, along with shifts, to set the proper bits as follows:
analog begin result = 0; for (i=0; i < 4; i=i+1) begin if(V(in[i]) >= thresh) result = result | (1 << i); end //for
.... case stmnt goes here unchanged, etc.
Lastly, on your transition statement, you would want to loop through each of the values as follows:
for(i = 0; i < 4; i = i+1) V(out[i]) <+ transition(vout[i],td, tt);
As Geoffrey mentions above, your bit order (most significant bit vs. least significant bit) may or (may not) be in the order that you intended, so that might be something to have a look at as well.
- Boris
|