如何 use/declare VHDL 中的无符号整数值?
How to use/declare an unsigned Integer value in VHDL?
我正在尝试在 Altera DE1-SoC 板上设计一个基本的自动售货机。我的问题来自于尝试对控制自动售货过程的状态机进行编码。您如何跟踪在各州之间跳跃增加的美元价值?我认为我要实现的代码是用高级语言格式编写的,无法用 VHDL 进行编译。有什么想法吗?
我收到这个错误(就在架构声明之后):
Error (10482): VHDL error at State.vhd(21): object "unsignedInteger"
is used but not declared
library ieee;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity MessageState is
Port(
Reset :in std_logic; -- reset to a safe state
-----------------------------------------------------------------------------------
MyStateOut :out std_logic_vector( 1 downto 0 ); -- drive the current state to display or LEDs
OutputCode :out std_logic_vector( 6 downto 0 ) -- to the display driver
);
end;
architecture Vending_FSM of MessageState is
signal Count: unsignedInteger(8 downto 0);
-- we define a data type to represent the states. Use descriptive names
-- add more lines for more states. Change the size of MyState as needed
subtype MyState is std_logic_vector(2 downto 0);
constant Idle :MyState := "000";
constant NickelState :MyState := "001";
constant DimeState :MyState := "010";
constant QuarterState :MyState := "011";
constant Dispense :MyState := "100";
signal state, next_state: MyState;
begin
MyStateOut <= state; -- make state visible.
MyNextState: process(state, next_state) begin -- add all signals read or tested in this process
case state is
when Idle =>
if ( KEY(0) = '1') then
next_state <= NickelState;
elsif ( KEY(1) = '1') then
next_state <= DimeState;
elsif ( KEY(2) = '1') then
next_state <= QuarterState;
else
next_state <= Idle; -- default action
Count <= (others => '0');
end if;
1) 删除 use IEEE.std_logic_unsigned.all;
因为 numeric_std
已经加载。它声明了 SIGNED
和 UNSIGNED
数据类型。
2) 您的信号 Count
的类型只是 UNSIGNED
.
我正在尝试在 Altera DE1-SoC 板上设计一个基本的自动售货机。我的问题来自于尝试对控制自动售货过程的状态机进行编码。您如何跟踪在各州之间跳跃增加的美元价值?我认为我要实现的代码是用高级语言格式编写的,无法用 VHDL 进行编译。有什么想法吗?
我收到这个错误(就在架构声明之后):
Error (10482): VHDL error at State.vhd(21): object "unsignedInteger" is used but not declared
library ieee;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity MessageState is
Port(
Reset :in std_logic; -- reset to a safe state
-----------------------------------------------------------------------------------
MyStateOut :out std_logic_vector( 1 downto 0 ); -- drive the current state to display or LEDs
OutputCode :out std_logic_vector( 6 downto 0 ) -- to the display driver
);
end;
architecture Vending_FSM of MessageState is
signal Count: unsignedInteger(8 downto 0);
-- we define a data type to represent the states. Use descriptive names
-- add more lines for more states. Change the size of MyState as needed
subtype MyState is std_logic_vector(2 downto 0);
constant Idle :MyState := "000";
constant NickelState :MyState := "001";
constant DimeState :MyState := "010";
constant QuarterState :MyState := "011";
constant Dispense :MyState := "100";
signal state, next_state: MyState;
begin
MyStateOut <= state; -- make state visible.
MyNextState: process(state, next_state) begin -- add all signals read or tested in this process
case state is
when Idle =>
if ( KEY(0) = '1') then
next_state <= NickelState;
elsif ( KEY(1) = '1') then
next_state <= DimeState;
elsif ( KEY(2) = '1') then
next_state <= QuarterState;
else
next_state <= Idle; -- default action
Count <= (others => '0');
end if;
1) 删除 use IEEE.std_logic_unsigned.all;
因为 numeric_std
已经加载。它声明了 SIGNED
和 UNSIGNED
数据类型。
2) 您的信号 Count
的类型只是 UNSIGNED
.