T
Taylor Hutt
Guest
-- I have an ALU which I want to verify. It has a fundamental type
-- 'word_t' which is defined as shown in the package 'types'.
--
-- To verify that the output of the ALU is correct, I want to iterate
-- over each operation, and all the operand values, setting the inputs
-- to the entity with the current 'op_0', 'op_1' and 'operator'
-- values.
--
-- However, being a rank novice VHDL programmer, the only way I can
-- think to do this easily is to declare an integer value for the
-- operands, and then assign this variable to the signal.
--
-- The problem is that I don't now how to cast the variable to the
-- 'word_t' type.
--
-- Can someone point me in the right direction to do one of the
-- following:
--
-- o Cast the 'integer' variable 'oper_0' to be of type 'word_t'.
-- o Declare 'oper_0' as an unsigned variable and assign it to
-- 'op_0'.
library ieee;
use ieee.std_logic_1164.all, ieee.numeric_bit.all;
package types is
subtype word_t is unsigned(31 downto 0);
end package types;
library ieee;
use ieee.std_logic_1164.all, ieee.std_logic_arith.all,
ieee.std_logic_unsigned.all;
use work.types;
entity main is
Port (clk : in std_logic; op_0 : out types.word_t);
end main;
architecture structural of main is
begin
driver : process (clk) is
variable oper_0 : integer := 0;
begin
op_0 <= oper_0;
-- ^^^^^^^^ Error: Type of op_0 is incompatible with type of oper_0.
op_0 <= types.word_t(oper_0);
-- ^^^^^^^^ Error: The expression can not be converted to type word_t.
op_0 <= conv_std_logic_vector(oper_0, 32);
-- ^^^^^^^^ Error: Type of op_0 is incompatible with type of
-- conv_std_logic_vector.
op_0 <= types.word_t(conv_unsigned(oper_0, 32));
-- ^^^^^^^^ Error: The expression can not be converted to type word_t.
end process driver;
end structural;
Thanks for any help,
thutt
-- 'word_t' which is defined as shown in the package 'types'.
--
-- To verify that the output of the ALU is correct, I want to iterate
-- over each operation, and all the operand values, setting the inputs
-- to the entity with the current 'op_0', 'op_1' and 'operator'
-- values.
--
-- However, being a rank novice VHDL programmer, the only way I can
-- think to do this easily is to declare an integer value for the
-- operands, and then assign this variable to the signal.
--
-- The problem is that I don't now how to cast the variable to the
-- 'word_t' type.
--
-- Can someone point me in the right direction to do one of the
-- following:
--
-- o Cast the 'integer' variable 'oper_0' to be of type 'word_t'.
-- o Declare 'oper_0' as an unsigned variable and assign it to
-- 'op_0'.
library ieee;
use ieee.std_logic_1164.all, ieee.numeric_bit.all;
package types is
subtype word_t is unsigned(31 downto 0);
end package types;
library ieee;
use ieee.std_logic_1164.all, ieee.std_logic_arith.all,
ieee.std_logic_unsigned.all;
use work.types;
entity main is
Port (clk : in std_logic; op_0 : out types.word_t);
end main;
architecture structural of main is
begin
driver : process (clk) is
variable oper_0 : integer := 0;
begin
op_0 <= oper_0;
-- ^^^^^^^^ Error: Type of op_0 is incompatible with type of oper_0.
op_0 <= types.word_t(oper_0);
-- ^^^^^^^^ Error: The expression can not be converted to type word_t.
op_0 <= conv_std_logic_vector(oper_0, 32);
-- ^^^^^^^^ Error: Type of op_0 is incompatible with type of
-- conv_std_logic_vector.
op_0 <= types.word_t(conv_unsigned(oper_0, 32));
-- ^^^^^^^^ Error: The expression can not be converted to type word_t.
end process driver;
end structural;
Thanks for any help,
thutt