EDAboard.com | EDAboard.de | EDAboard.co.uk | WTWH Media

output <= registers(to_integer(address)) and intentional met

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - VHDL Language - output <= registers(to_integer(address)) and intentional met


Guest

Tue Jun 18, 2019 1:45 pm   



Hi,
I have an array of std_logic_vectors. The address selector (unsigned type) may intentionally be unsigned to don't care/unknown state in order to simplify logic in other parts of a design. In such a case, the simulator will generate a warning, however, the output vector will be assigned to registers(0). My intention, in such a case, would be to assign don't care/unknown state also to the output vector. Is there any best practice for this problem?
I know that something like:
output <= (others => '-') when is_x(address) else registers(to_integer(address));
could work, but according to my knowledge, the is_x function may have a problem with synthesis.

Another option would be to write a process:

mux: process(all)
begin
output <= (others => '-');
for i in registers'range loop
if address = to_unsgined(i, address'range) then
output <= registers(i);
end if;
end loop;
end process;

However, I am worried that the synthesis tool may have an issue to extract a proper and simple mux from this description.

Is there any more straightforward description? I am using VHDL 2008.

Regards,
Adrian

Rick C
Guest

Tue Jun 18, 2019 2:45 pm   



On Tuesday, June 18, 2019 at 8:43:46 AM UTC-4, a.fie...@gmail.com wrote:
Quote:
Hi,
I have an array of std_logic_vectors. The address selector (unsigned type) may intentionally be unsigned to don't care/unknown state in order to simplify logic in other parts of a design. In such a case, the simulator will generate a warning, however, the output vector will be assigned to registers(0). My intention, in such a case, would be to assign don't care/unknown state also to the output vector. Is there any best practice for this problem?
I know that something like:
output <= (others => '-') when is_x(address) else registers(to_integer(address));
could work, but according to my knowledge, the is_x function may have a problem with synthesis.

Another option would be to write a process:

mux: process(all)
begin
output <= (others => '-');
for i in registers'range loop
if address = to_unsgined(i, address'range) then
output <= registers(i);
end if;
end loop;
end process;

However, I am worried that the synthesis tool may have an issue to extract a proper and simple mux from this description.

Is there any more straightforward description? I am using VHDL 2008.

Regards,
Adrian


Why not convert address to an integer and use it as the index in a simple assignment? Put that assignment inside a conditional that checks the bounds of the register index and perform the default assignment if that test fails.

output <= registers(to_integer(address)) when
(to_integer(address) in registers'range) else
output <= (others => '-');

Not sure if (to_integer(address) in registers'range) is a valid expression for this syntax. You may need to break that out as an AND of the upper and lower limit checks.

The way to see what the compiler does with this syntax is to construct a test bench that simply instantiates the code and look at the result in your synthesis tool. I would do that with your existing code before bothering to optimize it.

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209


Guest

Tue Jun 18, 2019 3:45 pm   



Hi Rick,

Thank you for your reply.

I haven't simulated it, but as you propose to_integer(address) you will have the same issue: even if the address has meta values, the output of the to_integer will be 0 which lies in the range of registers.

Rick C
Guest

Tue Jun 18, 2019 4:45 pm   



On Tuesday, June 18, 2019 at 9:47:10 AM UTC-4, a.fie...@gmail.com wrote:
Quote:
Hi Rick,

Thank you for your reply.

I haven't simulated it, but as you propose to_integer(address) you will have the same issue: even if the address has meta values, the output of the to_integer will be 0 which lies in the range of registers.


Sorry, I didn't quite catch what you had written. i assume this conditional is intended only for simulation and debug and has nothing to do with the operation of the circuit since these values are not synthesizable.

In that case, simply substitute the is_X function for the comparison in the WHEN conditional and it should do what you want... assuming I now understand the full problem.

I see in your original post you talk about IS_X not being synthesizable, so I'm wondering if you really are trying to synthesize the use of meta-values. If you give it a bit of thought you will realize there is no hardware that will perform this sort of evaluation, so the use of meta-values can't generate synthesizable logic. I believe constructs like these are simply ignored by synthesis.

I shouldn't make this sound so absolute though. I believe the value '-' can be used in comparisons as a wild card, but it has been too long since I've done this to remember if it is limited to non-standard extensions of synthesizers. After digging a bit, I see VHDL-2008 allows wild cards to be used in a version of case statements.

Am I getting closer to understanding your question?

--

Rick C.

+ Get 1,000 miles of free Supercharging
+ Tesla referral code - https://ts.la/richard11209


Guest

Tue Jun 18, 2019 5:45 pm   



Yes, I think you are getting closer to the core of the issue.

You are right, this condition is intended only for the simulation. I want to avoid a mismatch between eventual hardware and the behavioural verification: when address is unknown, also the "output" vector should be unknown. Currently, in simulation, it will be assigned to registers(0) (to_integer returns 0 for vectors containing meta value bits). An RTL description being verified may rely on this fact (registers(0) output when address is don't care) and I would like to exclude it

My concern is that line like:
output <= (others => '-') when is_x(address) else registers(to_integer(address));
will be fully ignored by a synthesis tool. I think, in general, synthesis tool's behaviour is not standardized in such a case.

I also confirm VHDL2008 comes with new relational operators (?=, ?<...) and case? statements.

Rob Gaddi
Guest

Tue Jun 18, 2019 6:45 pm   



On 6/18/19 5:43 AM, a.fiergolski_at_gmail.com wrote:
Quote:
Hi,
I have an array of std_logic_vectors. The address selector (unsigned type) may intentionally be unsigned to don't care/unknown state in order to simplify logic in other parts of a design. In such a case, the simulator will generate a warning, however, the output vector will be assigned to registers(0). My intention, in such a case, would be to assign don't care/unknown state also to the output vector. Is there any best practice for this problem?
I know that something like:
output <= (others => '-') when is_x(address) else registers(to_integer(address));
could work, but according to my knowledge, the is_x function may have a problem with synthesis.

Another option would be to write a process:

mux: process(all)
begin
output <= (others => '-');
for i in registers'range loop
if address = to_unsgined(i, address'range) then
output <= registers(i);
end if;
end loop;
end process;

However, I am worried that the synthesis tool may have an issue to extract a proper and simple mux from this description.

Is there any more straightforward description? I am using VHDL 2008.

Regards,
Adrian


I've definitely used IS_X in synthesizable code for exactly this reason, and
done pretty much exactly what you did (I tend to prefer 'X' to '-' as an output
don't care and only use '-' as an input don't care). It worked out just fine;
IS_X was treated as a constant false and the entire half of the condition
dropped out of existence.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.

Rick C
Guest

Tue Jun 18, 2019 6:45 pm   



On Tuesday, June 18, 2019 at 12:29:31 PM UTC-4, a.fie...@gmail.com wrote:
Quote:
Yes, I think you are getting closer to the core of the issue.

You are right, this condition is intended only for the simulation. I want to avoid a mismatch between eventual hardware and the behavioural verification: when address is unknown, also the "output" vector should be unknown. Currently, in simulation, it will be assigned to registers(0) (to_integer returns 0 for vectors containing meta value bits). An RTL description being verified may rely on this fact (registers(0) output when address is don't care) and I would like to exclude it

My concern is that line like:
output <= (others => '-') when is_x(address) else registers(to_integer(address));
will be fully ignored by a synthesis tool. I think, in general, synthesis tool's behaviour is not standardized in such a case.

I also confirm VHDL2008 comes with new relational operators (?=, ?<...) and case? statements.


Why not just write a test case and try it with your tools. Most synthesis tools will let you "see" the resulting logic in diagrams which are easy to analyze as long as they aren't large.

--

Rick C.

-- Get 1,000 miles of free Supercharging
-- Tesla referral code - https://ts.la/richard11209


Guest

Wed Jun 19, 2019 10:45 am   



I confirm that my original idea (and confirmed by Rob as well) works:

Code:

output <= registers(to_integer(address)) when not Is_X(address) else (others => 'U');

I checked results generated by the synthesis tool, and it seems that it properly ignores (set False) Is_X branch and the generated netlist is equivalent to simple
Code:

output <= registers(to_integer(address));


Thank you all for discussion.

elektroda.net NewsGroups Forum Index - VHDL Language - output <= registers(to_integer(address)) and intentional met

Ask a question - edaboard.com

Arabic version Bulgarian version Catalan version Czech version Danish version German version Greek version English version Spanish version Finnish version French version Hindi version Croatian version Indonesian version Italian version Hebrew version Japanese version Korean version Lithuanian version Latvian version Dutch version Norwegian version Polish version Portuguese version Romanian version Russian version Slovak version Slovenian version Serbian version Swedish version Tagalog version Ukrainian version Vietnamese version Chinese version Turkish version
EDAboard.com map