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 mult_test_tb IS
END mult_test_tb;
ARCHITECTURE behavior OF mult_test_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT mult_test
PORT(
clk : IN std_logic;
reset : IN std_logic;
ina : IN std_logic_vector(8 downto 0);
inb : IN std_logic_vector(8 downto 0);
mult_out : OUT std_logic_vector(17 downto 0)
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal reset : std_logic := '0';
signal ina : std_logic_vector(8 downto 0) := (others => '0');
signal inb : std_logic_vector(8 downto 0) := (others => '0');
--Outputs
signal mult_out : std_logic_vector(17 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: mult_test PORT MAP (
clk => clk,
reset => reset,
ina => ina,
inb => inb,
mult_out => mult_out
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
reset <= '1';
wait for 100 ns;
reset <= '0';
wait for clk_period*10;
-- insert stimulus here
ina <= "000000010";
inb <= "000000011";
wait for 450 ns;
ina <= "000000011";
inb <= "111111111";
wait;
end process;
END;
-- mult test
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity mult_test is
port (
clk : in std_logic;
reset : in std_logic;
ina : in std_logic_vector(8 downto 0);
inb : in std_logic_vector(8 downto 0);
mult_out : out std_logic_vector(17 downto 0)
);
end mult_test;
architecture RTL of mult_test is
begin
process(clk)
begin
if clk'event and clk='1' then
if reset='1' then
mult_out <= (others => '0');
else
mult_out <= ina * inb;
end if;
end if;
end process;
end RTL;
mult_out <= unsigned(ina) * signed(inb);
ERROR:HDLCompiler:410 - "\HDL\FndISEWork\DWM2008_07\Graphic_board2\test\mult_test\Synth123\../mult_test.vhd" Line 32: Expression has 19 elements ; expected 18
process(clk)
variable i, j, k : integer := 0;
begin
if clk'event and clk='1' then
if reset='1' then
mult_out <= (others => '0');
else
i := CONV_INTEGER(unsigned(ina));
j := CONV_INTEGER(signed(inb));
k := i * j;
mult_out <= CONV_STD_LOGIC_VECTOR(k, 18);
end if;
end if;
end process;
mult <= unsigned(ina) * signed("111110000");
signal temp : std_logic_vector(8 downto 0);
begin
temp <= "111110000";
process(clk) begin
if clk'event and clk='1' then
if reset='1' then
mult <= (others => '0');
else
mult <= unsigned(ina) * signed(temp);
end if;
end if;
end process;
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
|---|---|---|---|---|---|---|
| - | - | - | - | - | 1 | 2 |
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |