architecture Behavioral of vga_test is constant MXINIT : integer := 100; constant MYINIT : integer := 100; signal mousex_reg,mousey_reg : unsigned(9 downto 0); signal mousex_next,mousey_next : unsigned(9 downto 0); .... begin process(clk,reset) begin if reset='1' then rgb_reg '0'); mousex_reg
Didn't find your answer? Ask the community — no account required.
T
tarmopalm
I would declare registers us std_logic_vector(9 downto 0) and use following type conversion conv_std_logic_vector(MXINIT, 10).
Or mousex_reg
S
Symon
Hi Thorsten, Try
formatting link
Also, you might be better asking this sort of thing on comp.lang.vhdl .
HTH., Syms.
K
KJ
You need to use the to_unsigned function in ieee.numeric_std. You can't simply cast an integer to an unsigned because in order to do so, that function would need to know how many bits of precision you would like (which is what the second parameter in the 'to_unsigned' function defines).
Change to the following...
mousex_reg
P
Philip Potter
Use the to_unsigned() function defined in numeric_std.
Philip
B
Brian Drummond
1) DO NOT declare registers as std_logic_vector(9 downto 0) or use conv_std_logic_vector(). I presume you are using the correct numeric_std library; stick with this.
2) As others have said, numeric_std defines to_unsigned() to perform this conversion.
3) A peculiarity of this library is that while direct assignment of integer is not defined, mixed arithmetic between [un]signed and integer is defined, by overloading +,- etc with different signatures.
Hence mousex_reg '0') + MXINIT; will work (but it's UGLY)
4) Consider declaring your constants MXINIT etc to be unsigned. If this is the only place they are used, why declare them as a different type to their purpose? If you find yourself using type conversions everywhere, it's usually a sign that you are working at the wrong abstraction.
5) Another option is to use a subtype
subtype mouse_word is unsigned(9 downto 0);
-- makes it easy to change mouse resolution later
constant MXINIT : mouse_word := to_unsigned(100, mouse_word'length); -- at this point we don't need to know how big mouse_word is... signal mousex_reg,mousey_reg : mouse_word; mousex_reg
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.