我正在尝试使用结构建模使用 4 位加法器减法器制作一个 4 位加减计数器问题是加法器减法器的输入(A)需要更新为等于总和,我尝试在过程中制作信号解决这个问题,但它在模拟中给出了 U 我也不能将 a 设置为等于输出,但我必须写出输出等于 A
此外,信号 s 为 0 的警告,我需要它来更改 0 和 1,因为它负责向上向下计数,但是当我尝试在测试台中为其设置值时它会出错
我无法弄清楚这一点,非常感谢任何帮助
模拟错误:错误:Xst:528 - 信号单元中的多源>;该信号连接到多个驱动器。错误:Xst:528 - 信号单元中的多源 >;该信号连接到多个驱动器。错误:Xst:528 - 信号单元中的多源 >;该信号连接到多个驱动器。错误:Xst:528 - 信号单元中的多源 >;该信号连接到多个驱动器
模拟警告:从未使用输入。如果该端口属于顶级块或属于子块并且该子块的层次结构被保留,则该端口将被保留并保持未连接状态。WARNING:Xst:653 - 使用了信号但从未分配过信号。这个无源信号将自动连接到值 0。
This is the counter code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity upDown is
Port ( a: in STD_LOGIC_VECTOR(3 downto 0 );
b : in STD_LOGIC_VECTOR(3 downto 0 );
clk,reset,enable : in STD_LOGIC ;
o : out STD_LOGIC_VECTOR(3 downto 0 )
);
end upDown;
architecture Behavioral of upDown is
component addersub4bits is
Port ( a,b : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
s : in STD_LOGIC );
end component ;
signal s : STD_LOGIC ;
-- signal tmp2 : STD_LOGIC_VECTOR(3 downto 0) ;
signal outputsignal: STD_LOGIC_VECTOR(3 downto 0) ; --inside process
begin
ad : addersub4bits port map( a,"0001" ,outputsignal ,s) ;
process (clk,reset,enable)
begin
if(reset= '1' )
then outputsignal <= "0000";
elsif(clk' event and clk='1' ) then
if(enable ='1' ) then
outputsignal<=a ;
else
outputsignal<=outputsignal ; --zay mahowa
end if ;
end if ;
end process ;
--o <= tmp ;
o <=outputsignal ;
end Behavioral ;
加减器
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity addersub4bits is
Port ( a,b : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0);
s : in STD_LOGIC);
end addersub4bits;
architecture dataflow of addersub4bits is
begin
Process(a,b,s)
begin
if (s='1') then
y<= (a + b) ;
else
y<=(a-b) ;
end if ;
end process ;
end dataflow;
试验台
-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY uD_testbench IS
END uD_testbench;
ARCHITECTURE behavior OF uD_testbench IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT upDown
PORT(
a : IN std_logic_vector(3 downto 0);
b : IN std_logic_vector(3 downto 0);
clk : IN std_logic;
reset : IN std_logic;
enable : IN std_logic;
o : OUT std_logic_vector(3 downto 0)
);
END COMPONENT;
--Inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
signal clk : std_logic := '0';
signal reset : std_logic := '0';
signal enable : std_logic := '0';
--Outputs
signal o : std_logic_vector(3 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: upDown PORT MAP (
a => a,
b => b,
clk => clk,
reset => reset,
enable => enable,
o => o
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for 100 ns ;
clk <= '1';
wait for 100 ns ;
end process;
-- Stimulus process
stim_proc: process
begin
reset <= '1' ;enable <= '0' ; wait for 150 ns ;
reset <= '0'; wait for 300 ns ;
--enable <= '0' ; wait for 200 ns ;
enable <='1' ;wait ;
end process;
END;