??? 06/20/08 02:46 Read: times |
#156057 - Yes it's a pain, and it's not well explained. Responding to: ???'s previous message |
Andy Peters said:
Richard said:
Actually, I've spent quite a lot of time doing what I needed to do with VHDL, and this business with type conversion has often been a pain. As I've said, VHDL is a strongly-typed language, unlike Verilog, which is an unmitigated disaster when it comes to dealing with numbers. But you still haven't answered my question. What is the decimal equivalent to the binary vector "10010110"? The answer makes it obvious why VHDL handles numbers as it does. I don't know why that's an issue but if it's what it appears to be, namely a bit vector, then the first element is 1 which makes it a HEX 69, which is decimal 96+9 or 105. I should further note that you can code your numbers however you want, and your simulator (I use ModelSim) can display a vector in any numeric base you wish. (It can even do a simple D-to-A conversion and show it as a waveform!)
-a I agree about the simulator, and, in fact, that's made some things pass that might otherwise have failed. What puzzles me is why so many textbooks on VHDL simply fail to discuss the business of the various data types and their purpose, and when they're of benefit, not to mention the business of translating from one to the other. Running the counter in type natural is fine until you have to generate STD_LOGIC_VECTOR output from it because it's an address counter in a DMA Channel. Then, too, you'd want to decode various strobes from the low-order bits ... How would that work without type conversion? Can you recommend of a text that actually goes into meaningful and exhaustive detail about when you'd want to use one type over another? RE |