VHDL multiplication for std_logic_vector

Guest #5601489
Rate this post
• ▲ useful
▼ not useful
When simulating I get a run time error, so I'm trying to run a RTL 
analysis in Vivado to see if the schematic of the component can be 
created at least. The code is the following
1
library IEEE;
2
use IEEE.std_logic_1164.all;
3
use IEEE.numeric_std.all;
4

5
entity multiplicator_test is
6
  generic(
7
      WORD_SIZE: natural := 8;
8
      EXP_SIZE: natural := 3
9
    );
10
    port(
11
      input_1: in std_logic_vector(WORD_SIZE-1 downto 0);
12
      input_2: in std_logic_vector(WORD_SIZE-1 downto 0);
13
      result: out std_logic_vector(WORD_SIZE-1 downto 0)
14
    );
15
end entity multiplicator_test;
16

17
architecture multiplicator_test_arch of multiplicator_test is
18
  constant SIGNIFICAND_SIZE: natural := WORD_SIZE - EXP_SIZE - 1;
19

20
  signal significand: std_logic_vector(SIGNIFICAND_SIZE-1 downto 0) := (others => '0');
21
  signal exponent: std_logic_vector(EXP_SIZE-1 downto 0) := (others => '0');
22
  signal sign: std_logic := '0';
23
  signal aux: std_logic_vector((2*SIGNIFICAND_SIZE)-1 downto 0) := (others => '0');
24
begin
25
    aux <= std_logic_vector(signed(input_1(SIGNIFICAND_SIZE-1 downto 0))*signed(input_2(SIGNIFICAND_SIZE - 1 downto 0)));
26
    significand <= aux(SIGNIFICAND_SIZE - 1 downto 0);
27
    exponent <= std_logic_vector(unsigned(input_1(WORD_SIZE-2 downto WORD_SIZE-EXP_SIZE-2))+unsigned(input_2(WORD_SIZE-2 downto WORD_SIZE-EXP_SIZE-2)));
28
    sign <= input_1(WORD_SIZE-1) or input_2(WORD_SIZE-1);
29
    result <= sign & exponent & significand;
30
end architecture multiplicator_test_arch;

When running the analysis, I get
1
ERROR: [Synth 8-690] width mismatch in assignment; target has 3 bits, source has 4 bits [(...)/multiplicador.vhd:27]

The line with the error is 27,
1
aux <= std_logic_vector(signed(input_1(SIGNIFICAND_SIZE-1 downto 0))*signed(input_2(SIGNIFICAND_SIZE - 1 downto 0)));

Apparently the target (aux) is 3 bits, but really it should be 8.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.