VLSI-EDA / PoC

IP Core Library - Published and maintained by the Chair for VLSI Design, Diagnostics and Architecture, Faculty of Computer Science, Technische Universität Dresden, Germany
https://tu-dresden.de/ing/informatik/ti/vlsi
Other
538 stars 93 forks source link

Error for string.vhdl - Value := resize(slv, Value'length); #48

Open bhamadicharef opened 7 years ago

bhamadicharef commented 7 years ago

I want to use the function raw_format_slv_hex from string.vhdl. Vivado 2016.2 gives an error on line 359 about the following

Value := resize(slv, Value'length);

Error message is

[Synth 8-2778] type error near resize ; expected type std_logic_vector

How to fix ? Is it specific to Vivado ?

Brahim @ DCT :: DSI

bhamadicharef commented 7 years ago

Seems that it gets fixed by

Value := std_logic_vector(resize(signed(slv), Value'length)); 
preusser commented 7 years ago

Thanks for your feedback! Please, use the unsigned version of resize to make it semantically correct. Would you want to turn this fix into a pull request then?

Paebbels commented 7 years ago

The needed resize function is define in utils.vhdl. There is no need to rewrite the code.

The question is why doesn't Vivado 2016.2 find that overload.

preusser commented 7 years ago

resize on std_logic_vector is ill-defined as it has to make assumptions about signedness. I would rather fence in its use and put it on a deprecation path.

Paebbels commented 7 years ago

Why is it ill-defined? It makes no assumptions about signedness!

See at the definition in utils, how you wrote it. It's using a fill parameter.

preusser commented 7 years ago

Yes, and it even has implied semantics using the index direction as a hint for alignment. I would now consider this another feature hard to convey. Although I admittedly tried, std_logic_vector simply does not have an intuitively right semantics for resize. And I do not see why I should not allow my own mistakes to phase out - at least, eventually. The standard libraries provide valid implementations as soon as the types have clear semantics associated with them. Just use those.

Paebbels commented 7 years ago

Sounds reasonable.

Usage of resize

Where else is that function used?

preusser commented 7 years ago

Mmhhh, the first of these uses would even be semantically correct ...