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
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).
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
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.