UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor franch
Visitor
5,476 Views
Registered: ‎07-20-2012

iSIM Error: Value out of valid range of user defined type

Jump to solution

Hello,

 

I am currently designing a simple state machine in VHDL. I tried using my own kind of enconding, as shown here:

 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "100001 100010 000001 000010 000100 001000";
	
	signal state : state_type; 

 It all went fine through synthesis. But when I try to use iSIM to run my testbench, it fails before even running the simmulation and I get the following message on the log:

 

ERROR: Value 33 is out of valid range : 0 TO 5 of type state_type

 I don't get it. Is my encoding wrong and the synthesis tool failed to inform the error to me or is iSIM failing to recognize my encoding?

 

Thanks in advance.

 

Best regard,

Daniel K. Franch

0 Kudos
1 Solution

Accepted Solutions
Visitor franch
Visitor
6,821 Views
Registered: ‎07-20-2012

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

I think I solved it by myself. Apparently, the problem was not the fact that my user defined type could only be used internally. But it was a matter of the order in the enumeration. It seems that I can choose any encoding I want, as long as I put the states in a binary crescent order.

 

First, I tried changing my encoding to a gray code, just to see what would happen: 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000 001 011 010 110 100";

 and this worked just fine with iSIM!

 

When I have done this, I noticed the crescent order thing, so I tried putting the almost-one-hot code I tried before in this order, like this:

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000000 000001 100000 100001 100010 100100";

 and iSIM did not complain even a little bit. Good boy! :)

 

I may not have enough data to state that this was certainly the problem, but I am pretty sure that was the case.

0 Kudos
5 Replies
Historian
Historian
5,468 Views
Registered: ‎02-25-2008

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

@franch wrote:

Hello,

 

I am currently designing a simple state machine in VHDL. I tried using my own kind of enconding, as shown here:

 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "100001 100010 000001 000010 000100 001000";
	
	signal state : state_type; 

 It all went fine through synthesis. But when I try to use iSIM to run my testbench, it fails before even running the simmulation and I get the following message on the log:

 

ERROR: Value 33 is out of valid range : 0 TO 5 of type state_type

 I don't get it. Is my encoding wrong and the synthesis tool failed to inform the error to me or is iSIM failing to recognize my encoding?

 

Thanks in advance.

 

Best regard,

Daniel K. Franch


 

My suspicion is that the attributes are entirely ignored by the simulator, and for a good reason. You've defined the type:

 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);

signal state: state_type;

 

and as such, per the language, the only legal values one may assign to that signal state are the values explicitly defined in the type definition. As such, an assignment:

 

     state <= wait_rx;

 

is valid, but 

 

    state <= "001000";

 

should result in a compile-time error.

 

The error message ISIM throws at you, "out of valid range : 0 TO 5 of type state_type" makes no sense. There is no numeric value assigned to any of the values set in the type definition. 

 

Is there any particular reason why you wish to define your own encoding?

----------------------------Yes, I do this for a living.
0 Kudos
Visitor franch
Visitor
5,458 Views
Registered: ‎07-20-2012

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

Thank you very much for your answer. :)

 

What you have said does make sense. iSIM probably can't assign the values I defined to the signals.

 

I was just trying to use pseudo-one-hot encoding in a state machine that defined which string should be sent when the  system is transmiting or which to expect when it is receiving. As I have plenty of space in my FPGA, I guessed that one-hot encoding would be nice to get things running faster. It is not strictly neccessary, so I was just trying it out. And, as I have 2 "super-states" (transmiting and receiving), I thought that I could use one bit as a selection bit. I am not sure if this makes any sense, haha.

0 Kudos
Visitor franch
Visitor
6,822 Views
Registered: ‎07-20-2012

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

I think I solved it by myself. Apparently, the problem was not the fact that my user defined type could only be used internally. But it was a matter of the order in the enumeration. It seems that I can choose any encoding I want, as long as I put the states in a binary crescent order.

 

First, I tried changing my encoding to a gray code, just to see what would happen: 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000 001 011 010 110 100";

 and this worked just fine with iSIM!

 

When I have done this, I noticed the crescent order thing, so I tried putting the almost-one-hot code I tried before in this order, like this:

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000000 000001 100000 100001 100010 100100";

 and iSIM did not complain even a little bit. Good boy! :)

 

I may not have enough data to state that this was certainly the problem, but I am pretty sure that was the case.

0 Kudos
Historian
Historian
5,446 Views
Registered: ‎02-25-2008

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

@franch wrote:

Thank you very much for your answer. :)

 

What you have said does make sense. iSIM probably can't assign the values I defined to the signals.

 

I was just trying to use pseudo-one-hot encoding in a state machine that defined which string should be sent when the  system is transmiting or which to expect when it is receiving. As I have plenty of space in my FPGA, I guessed that one-hot encoding would be nice to get things running faster. It is not strictly neccessary, so I was just trying it out. And, as I have 2 "super-states" (transmiting and receiving), I thought that I could use one bit as a selection bit. I am not sure if this makes any sense, haha.



You should not care about the encoding when you write your HDL.

 

You set the encoding type in the XST properties. 

----------------------------Yes, I do this for a living.
0 Kudos
Historian
Historian
5,445 Views
Registered: ‎02-25-2008

Re: iSIM Error: Value out of valid range of user defined type

Jump to solution

@franch wrote:

I think I solved it by myself. Apparently, the problem was not the fact that my user defined type could only be used internally. But it was a matter of the order in the enumeration. It seems that I can choose any encoding I want, as long as I put the states in a binary crescent order.

 

First, I tried changing my encoding to a gray code, just to see what would happen: 

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000 001 011 010 110 100";

 and this worked just fine with iSIM!

 

When I have done this, I noticed the crescent order thing, so I tried putting the almost-one-hot code I tried before in this order, like this:

type state_type is (wait_rx, rxing, wait_tx, info0ing, info2ing, info4ing);
	attribute enum_encoding : string;
	attribute enum_encoding of state_type : type is "000000 000001 100000 100001 100010 100100";

 and iSIM did not complain even a little bit. Good boy! :)

 

I may not have enough data to state that this was certainly the problem, but I am pretty sure that was the case.


So you're still assigning a string value to the state register?

 

WHY?

 

That still shouldn't work.

----------------------------Yes, I do this for a living.
0 Kudos