help with a vhdl calculator

OP (Company: ipn) #4010805
Rate this post
• ▲ useful
▼ not useful
here i attach my program, it must multiply, add, subtract and compare 2 
numbers of 2bits. I have a problem it says that logic equation has to 
many terms on signal a_to_g(3).
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
4
USE IEEE.numeric_std.ALL;
5
ENTITY calc is
6
  Port (Num1: in Signed (1 downto 0);
7
    Num2: in Signed (1 downto 0);
8
    S:  in STD_LOGIC_VECTOR (1 downto 0);
9
    a_to_g:out STD_LOGIC_VECTOR (6 downto 0));
10
end calc;
11

12
Architecture tris of calc is
13
signal SUM:Signed (4 downto 0);
14
signal RES:Signed (4 downto 0);
15
signal MUL:Signed (4 downto 0);
16
signal COM:Signed (4 downto 0);
17
signal DISP : signed(4 downto 0);
18
begin 
19
process(Num1,Num2,S)
20
  BEGIN
21
  CASE S IS
22
    WHEN "00"=>SUM<=resize(Num1,5)+Num2;
23
     WHEN "01"=>RES<=resize(Num1,5)-Num2;
24
    WHEN "10"=>
25
    if Num1>Num2 then 
26
    COM <= "11110";
27
    elsif Num1<Num2 then
28
    COM <= "11011";
29
    else
30
    COM <= "11010";
31
  end if;
32
    WHEN OTHERS=>MUL<=resize(Num1,3)*Num2;
33
    END CASE;
34
END PROCESS;
35
PROCESS (S,SUM,RES,MUL,COM)
36
BEGIN
37
IF (S="00") THEN DISP<=SUM;
38
ELSIF (S="01") THEN DISP<=RES;
39
ELSIF (S="10") THEN DISP<=COM;
40
ELSE DISP<=MUL;
41
  END IF;
42
    END PROCESS;  
43
      
44
process (DISP)
45
  begin
46
    case DISP is
47
  -- output numbers
48
  when "00000"=> a_to_g <="0000001";  --0
49
  when "00001"=> a_to_g <="1001111";  --1
50
  when "00010"=> a_to_g <="0010010";  --2
51
  when "00011"=> a_to_g <="0000110";  --3
52
  when "00100"=> a_to_g <="1001100";  --4
53
  when "00101"=> a_to_g <="0100100";  --5
54
  when "00110"=> a_to_g <="0100000";  --6
55
  when "00111"=> a_to_g <="0001101";  --7
56
  when "01000"=> a_to_g <="0000000";  --8
57
  when "01001"=> a_to_g <="0000100";  --9
58
  -- output symbols
59
  when "11010"=> a_to_g <="1000001";  --=
60
  when "11011"=> a_to_g <="1001110";  --<
61
  when "11110"=> a_to_g <="1111000";  -->
62
  when others => a_to_g <="0000000";
63
end case;
64
  end process;
65
end tris;
Moderator (Company: Titel) #4010832
Rate this post
• ▲ useful
▼ not useful
Yair Orta wrote:
> it says
WHO is IT?

> it says that logic equation has to many terms on signal a_to_g(3).
Nothing more? With wich words?

> USE IEEE.STD_LOGIC_UNSIGNED.ALL;
> USE IEEE.numeric_std.ALL;
Never ever use both of them together!
Use the numeric_std solely. It has all the conversions you need. Try 
this with Google translator, its German:
http://www.lothar-miller.de/s9y/categories/16-Numeric_Std

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.