Vhdl 将'others'表达式与'signed'cast组合
让Vhdl 将'others'表达式与'signed'cast组合,vhdl,xilinx-ise,Vhdl,Xilinx Ise,让var代表大小为m的有符号向量(库IEEE.NUMERIC\u STD.ALL) 设foo为std_逻辑_向量(n-1到0)类型的另一个变量,其中n小于m 我想连接foo左侧的“0”,然后在其右侧填充零,直到其大小为m,然后将结果存储在var中 我试过了 rdsor <= signed('0' & divisor & others=>'0'); 如何做我想做的事?您需要使用其他作为聚合的一部分,而不是连接的一部分。下面是一个使用聚合和属性的解决方案(依赖于您使用V
var
代表大小为m
的有符号向量(库IEEE.NUMERIC\u STD.ALL)
设foo
为std_逻辑_向量(n-1到0)
类型的另一个变量,其中n小于m
我想连接foo
左侧的“0”,然后在其右侧填充零,直到其大小为m
,然后将结果存储在var
中
我试过了
rdsor <= signed('0' & divisor & others=>'0');
如何做我想做的事?您需要使用
其他
作为聚合的一部分,而不是连接的一部分。下面是一个使用聚合和属性的解决方案(依赖于您使用VHDL 2008):
rdsor有符号(除数),其他=>'0');
您需要使用
其他
作为聚合的一部分,而不是连接的一部分。下面是一个使用聚合和属性的解决方案(依赖于您使用VHDL 2008):
rdsor有符号(除数),其他=>'0');
假设
rdsor
等于理论上的var
和等于foo
的除数,您可以在流程语句中使用两个赋值:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity jsevillamol is
end entity;
architecture fum of jsevillamol is
constant M: natural := 42;
constant N: natural := 23;
signal rdsor: signed (M - 1 downto 0);
signal divisor: std_logic_vector (N - 1 downto 0);
begin
-- rdsor <= signed('0' & divisor & others=>'0');
process (divisor)
begin
rdsor <= (others => '0');
rdsor (rdsor'LEFT downto rdsor'LEFT - divisor'LENGTH)
<= signed('0' & divisor);
end process;
end architecture;
这使用串联并将其他
包含到聚合中。尾部“0”部分有一个子类型声明,允许聚合表达式成为限定表达式的目标
该体系结构还分析、阐述和模拟证明索引算法是正确的。假设
rdsor
相当于您的理论var
和除数相当于foo
,您可以在流程语句中使用两个赋值:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity jsevillamol is
end entity;
architecture fum of jsevillamol is
constant M: natural := 42;
constant N: natural := 23;
signal rdsor: signed (M - 1 downto 0);
signal divisor: std_logic_vector (N - 1 downto 0);
begin
-- rdsor <= signed('0' & divisor & others=>'0');
process (divisor)
begin
rdsor <= (others => '0');
rdsor (rdsor'LEFT downto rdsor'LEFT - divisor'LENGTH)
<= signed('0' & divisor);
end process;
end architecture;
这使用串联并将其他
包含到聚合中。尾部“0”部分有一个子类型声明,允许聚合表达式成为限定表达式的目标
此体系结构还分析、阐述和模拟证明索引算法是正确的。您尚未提供提供解决方案所需的
除数、
或rdsor的声明。注意,var
和foo
都不会出现在单行代码段中。您还忽略了工具所需的VHDL标准版本。您没有提供提供解决方案所需的除数、
或rdsor
声明。注意,var
和foo
都不会出现在单行代码段中。您还忽略了工具所需的VHDL标准版本。请注意-2008选项。@user1155120您是对的。这不是第一次,我无意中想出了一个需要VHDL 2008的解决方案,因为在EDA游乐场上,Riviera Pro默认设置了该开关。请注意-2008选项。@user1155120您是对的。这不是第一次,我无意中提出了一个需要VHDL 2008的解决方案,因为在EDA游乐场上,Riviera Pro默认设置了该开关。Ups,我混淆了变量的名称。感谢您提供了详尽的解决方案!Ups,我把变量的名字弄混了。感谢您提供了详尽的解决方案!
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity jsevillamol is
end entity;
architecture fum of jsevillamol is
constant M: natural := 42;
constant N: natural := 23;
signal rdsor: signed (M - 1 downto 0);
signal divisor: std_logic_vector (N - 1 downto 0);
begin
-- rdsor <= signed('0' & divisor & others=>'0');
process (divisor)
begin
rdsor <= (others => '0');
rdsor (rdsor'LEFT downto rdsor'LEFT - divisor'LENGTH)
<= signed('0' & divisor);
end process;
end architecture;
architecture fie of jsevillamol is
constant M: natural := 42;
constant N: natural := 23;
signal rdsor: signed (M - 1 downto 0);
signal divisor: std_logic_vector (N - 1 downto 0);
subtype other is signed (rdsor'LEFT - divisor'LENGTH - 1 downto 0);
begin
-- rdsor <= signed('0' & divisor & others=>'0');
rdsor <= '0' & signed(divisor) & other'(others => '0');
end architecture;