二进制补码 VHDL [英] Two's complement VHDL

查看:47
本文介绍了二进制补码 VHDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想在 VHDL 中制作一个简单的二进制补码设备,但它返回了这个非常烦人的错误,我不确定我做错了什么.可能是非常愚蠢的事情......错误是错误 (10327):twocompliment.vhd(21) 处的 VHDL 错误:无法确定运算符nand"的定义——找到 0 个可能的定义"

I am just trying to make a simple two's complement device in VHDL but it is throwing back this really annoying error and I'm unsure what I have done wrong. Probably something very silly...The error is "Error (10327): VHDL error at twocompliment.vhd(21): can't determine definition of operator ""nand"" -- found 0 possible definitions"

代码是

library ieee;
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all;
entity twoscompliment is
      generic
      (
              Nbits : positive := 8 
       );
 port 
( 
           --Inputs
           A : in std_logic_vector (Nbits-1 downto 0);
           --Outputs
           Y : out std_logic_vector (Nbits downto 0)
);
end twoscompliment;

architecture twoscompliment_v1 of twoscompliment is
 begin
  Y <= std_logic_vector(unsigned(A NAND '1') + '1');
 end twoscompliment_v1;

任何帮助都会很棒!

推荐答案

试试这个:

architecture twoscompliment_v1 of twoscompliment is
signal temp : std_logic_vector(Nbits-1 downto 0);
begin
  temp <= not A;
  Y    <= std_logic_vector(unsigned(temp + 1));
end twoscompliment_v1;

这篇关于二进制补码 VHDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆