我正在尝试将一行中的值相乘:
Q<= unsigned(reg_output) or (unsigned(multiplicand) and unsigned(shifted_lsb)*"0010");
注意:我知道multiplicand是std_logic_vector,我这样做是为了通过if进行比较。
每次我编译我得到错误:从ieee.std_logic_1164进行的非法类型转换。STD_LOGIC to see . numeric_std。UNSIGNED(非数字数组).
下面是我的代码:library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity shiftaddr is
port(
clk, clear : in std_logic;
multiplicand: in std_logic_vector(3 downto 0);
reg_output: in unsigned(7 downto 0);
shifted_lsb: in std_logic;
Q: out unsigned(7 downto 0) );
end shiftaddr;
architecture arch of shiftaddr is
signal temp: std_logic_vector(3 downto 0);
begin
shift: process(clk,clear,multiplicand, shifted_lsb,reg_output) --Define a process and state the inputs
begin
if (clk = '0') then
Q <= reg_output;
end if;
if (clk = '1') then
if (multiplicand(0) = '1') then Q <= (reg_output);
end if;
if (multiplicand(1) = '1') then
Q<= unsigned(reg_output) or (unsigned(multiplicand) and unsigned(shifted_lsb)*"0010");
end if;
end if;
end process;
end arch;
我该如何解决这个问题?由于
问题来自:
unsigned(shifted_lsb)*"0010"
shifted_lsb
不是矢量,不能转换为矢量类型的unsigned
。根据Khanh N. Dang的建议,你可以直接测试它的值。
但是你的代码可能是假的:你的灵敏度列表不是同步进程的,而你的一个信号被命名为clk
。此外,如果您希望您的进程是同步的,那么您将遇到问题,因为您使用了时钟的两种状态。你应该:
- 缩进你的代码,这样我们就可以不费太多力气地阅读它,
- 首先考虑硬件:如果你清楚地知道你想要的硬件(寄存器,加法器,多路复用器…),编码通常变得非常容易, 再读一遍课本中关于同步进程的部分。