cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
8,992 Views
Registered: ‎02-22-2015

VHDL VALUE' attribute

Jump to solution

T'VALUE(X) is a value of type T converted from the string X.

 

I am using this to convert a string into an enum.

The string is a command read from a file (AEx5 Commands.vhd)  and specific actions are taken based on what is read. There is a case statement for each command.

The "others" case is supposed to take effect when an illegal command is read however in this situation,

"Op := opcode'VALUE(cmd);" (in AEx5 Testbench.vdh) fails to convert cmd into enum.. as you might expect.

 

How do i resolve this issue i.e. is there a way i can determine cmd is contained within enum type opcode before using 'VALUE attribute?

 

Note. The commands file contains an illegal command ("Reseet") so that it is setup to fail to exercise the "others" case.

Note. All vhdl files are attached with commands.txt.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor
Visitor
16,255 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

Thanks very much for your help.

 

I have fixed the issue on ISim by using the following to check Cmd is within range:

 

Op := opcode'VALUE(cmd);  --in previous code

 

IF opcode'POS(op) > 6 THEN

 

   REPORT "Unrecognised command " & Cmd;

ELSE

   CASE Op is --in previous code

...

   END CASE; --in previous code

 

END IF;

END LOOP; --in previous code

View solution in original post

0 Kudos
15 Replies
Highlighted
Moderator
Moderator
8,976 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

When I tried with your code I got Fatal Error.

Are you getting the same?

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Moderator
Moderator
8,967 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

I have done a little modification to code.

It's working at my end.(Attached Snapshot)

Please verify at your end.(Attached code)

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
1.JPG
Highlighted
Visitor
Visitor
8,934 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

I have applied your modifications and get the following error message:

 

ISim P.20131013 (signature 0x8ef4fb42)
WARNING: A WEBPACK license was found.
WARNING: Please use Xilinx License Configuration Manager to check out a full ISim license.
WARNING: ISim will run in Lite mode. Please refer to the ISim documentation for more information on the differences between the Lite and the Full version.
This is a Lite version of ISim.
Time resolution is 1 ps
Simulator is doing circuit initialization process.
at 0 ps: Note: Reset (/counter_tb/).
Finished circuit initialization process.
at 40 ns(1): Note: check (/counter_tb/).
at 40 ns(1): Note: hold (/counter_tb/).
at 80 ns(1): Note: check (/counter_tb/).
at 80 ns(1): Note: down (/counter_tb/).
at 160 ns(1): Note: check (/counter_tb/).
ERROR: In process ex_05.vhd:read_cmd
FATAL ERROR:ISim: This application has discovered an exceptional condition from which it cannot recover. Process will terminate. To search for possible resolutions to this issue, refer to the Xilinx answer database by going to http://www.xilinx.com/support/answers/index.htm and search with keywords 'ISim' and 'FATAL ERROR'. For technical support on this issue, please open a WebCase with this project attached at http://www.xilinx.com/support.
INFO: Simulator is stopped.

0 Kudos
Highlighted
Visitor
Visitor
8,933 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

using the attached commands file for the snapshot above

0 Kudos
Highlighted
Visitor
Visitor
8,925 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

other files modified and added here

0 Kudos
Highlighted
Moderator
Moderator
8,920 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

Please find the archived project file.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
8,911 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

Can't try this at the moment. Was there something wrong with my code?

 

Thanks

0 Kudos
Highlighted
Moderator
Moderator
8,904 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

It seems some issue with initialization of Cmd. 

Initializing it to "Count" worked.

When you have time please try running the project(attached in my previous reply) and let me know. 

 

Note- Please set the path of Commands.txt according to file location on your machine.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
8,890 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

Unfortunately I have taken your .vhd files but i am getting the same error when i run simulation.

 

I have confirmed that the code simulates correctly with valid Cmd from commands.txt. So it is purely invalid commands causing this problem. I dont understand why.

 

My only work around would check validity of Cmd before attempting to convert to Enum suing "Op := opcode'VALUE(cmd);"

 

This brings me back to my original question: Is there a way i can check string Cmd is contained within my  Enum type (Opcode)?

Or do i reallly have to have a series of If statements to check for each enumerated value?

 

I am using Isim simulator version 14.7 (nt) - running in Lite mode. What software/version are you using?

0 Kudos
Highlighted
Moderator
Moderator
7,984 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

I am using Vivado 2015.3.

Can you please try with Vivado 2015.3?

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
7,976 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

Just another point, the fault is not caused by initialisation issue. The following report is from Isim resulting from a command.txt file that contains an illegal Cmd further down i.e. not the first reset command (i changed the "check fc" to "checck fc"). 

As can be seen, the first 5 Cmds are being read correctly.

 

ISim P.20131013 (signature 0x8ef4fb42)
WARNING: A WEBPACK license was found.
WARNING: Please use Xilinx License Configuration Manager to check out a full ISim license.
WARNING: ISim will run in Lite mode. Please refer to the ISim documentation for more information on the differences between the Lite and the Full version.
This is a Lite version of ISim.
Time resolution is 1 ps
Simulator is doing circuit initialization process.
at 0 ps: Note: Reset (/counter_tb/).
Finished circuit initialization process.
at 40 ns(1): Note: Check (/counter_tb/).
at 40 ns(1): Note: Hold (/counter_tb/).
at 80 ns(1): Note: Check (/counter_tb/).
at 80 ns(1): Note: down (/counter_tb/).
ERROR: In process Counter_TB.vhd:read_cmd
FATAL ERROR:ISim: This application has discovered an exceptional condition from which it cannot recover. Process will terminate. To search for possible resolutions to this issue, refer to the Xilinx answer database by going to http://www.xilinx.com/support/answers/index.htm and search with keywords 'ISim' and 'FATAL ERROR'. For technical support on this issue, please open a WebCase with this project attached at http://www.xilinx.com/support.
INFO: Simulator is stopped.
ISim>

 

0 Kudos
Highlighted
Visitor
Visitor
7,974 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

I dont have Vivado at the moment ..will try over the weekend

0 Kudos
Highlighted
Moderator
Moderator
7,966 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

In Vivado the Fatal error was because of initialization issue only.

It's better to go for Vivado latest version because the bugs are getting fixed along the process.

 

Please go through the following link for simulation in Vivado
http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_3/ug937-vivado-design-suite-simulation-tutorial.pdf

 

Hope this will be helpful to you.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
Highlighted
Visitor
Visitor
16,256 Views
Registered: ‎02-22-2015

Re: VHDL VALUE' attribute

Jump to solution

Thanks very much for your help.

 

I have fixed the issue on ISim by using the following to check Cmd is within range:

 

Op := opcode'VALUE(cmd);  --in previous code

 

IF opcode'POS(op) > 6 THEN

 

   REPORT "Unrecognised command " & Cmd;

ELSE

   CASE Op is --in previous code

...

   END CASE; --in previous code

 

END IF;

END LOOP; --in previous code

View solution in original post

0 Kudos
Highlighted
Moderator
Moderator
7,944 Views
Registered: ‎07-01-2015

Re: VHDL VALUE' attribute

Jump to solution

Hi @kpatel94126,

 

That's great.

 

Glad to know that your issue got resolved by modifying the code. I tried at my end also.

But the same code works for Vivado 2015.3 without any modifications. 

 

So if possible go with the latest build of Vivado as the bugs are getting fixed along the process.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos