YAI
Newbie level 6
- Joined
- Feb 12, 2015
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 118
Code VHDL - [expand] 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 library IEEE; use IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; USE IEEE.numeric_std.ALL; use work.std_arith.all; ENTITY calc is Port (Num1: in Signed (1 downto 0); Num2: in Signed (1 downto 0); S: in STD_LOGIC_VECTOR (1 downto 0); a_to_g:out STD_LOGIC_VECTOR (6 downto 0)); end calc; Architecture tris of calc is signal SUM:Signed (3 downto 0); signal RES:Signed (3 downto 0); signal MUL:Signed (3 downto 0); signal COM:STD_LOGIC_VECTOR (3 downto 0); begin process(Num1,Num2,S) BEGIN CASE S IS WHEN "00"=>SUM<=resize(Num1,4)+Num2; WHEN "01"=>RES<=resize(Num1,4)-Num2; WHEN "10"=> if Num1>Num2 then COM <= "1110"; elsif Num1<Num2 then COM <= "1011"; else COM <= "1010"; end if; WHEN OTHERS=>MUL<=(Num1*Num2); END CASE; END PROCESS; process (SUM) begin case SUM is when "0000"=> a_to_g <="0000001"; --0 when "0001"=> a_to_g <="1001111"; --1 when "0010"=> a_to_g <="0010010"; --2 when "0011"=> a_to_g <="0000110"; --3 when "0100"=> a_to_g <="1001100"; --4 when "0101"=> a_to_g <="0100100"; --5 when "0110"=> a_to_g <="0100000"; --6 when "0111"=> a_to_g <="0001101"; --7 when "1000"=> a_to_g <="0000000"; --8 when "1001"=> a_to_g <="0000100"; --9 end case; end process; process (RES) begin case RES is when "0000"=> a_to_g <="0000001"; --0 when "0001"=> a_to_g <="1001111"; --1 when "0010"=> a_to_g <="0010010"; --2 when "0011"=> a_to_g <="0000110"; --3 when "0100"=> a_to_g <="1001100"; --4 when "0101"=> a_to_g <="0100100"; --5 when "0110"=> a_to_g <="0100000"; --6 when "0111"=> a_to_g <="0001101"; --7 when "1000"=> a_to_g <="0000000"; --8 when "1001"=> a_to_g <="0000100"; --9 end case; end process; process (MUL) begin case MUL is when "0000"=> a_to_g <="0000001"; --0 when "0001"=> a_to_g <="1001111"; --1 when "0010"=> a_to_g <="0010010"; --2 when "0011"=> a_to_g <="0000110"; --3 when "0100"=> a_to_g <="1001100"; --4 when "0101"=> a_to_g <="0100100"; --5 when "0110"=> a_to_g <="0100000"; --6 when "0111"=> a_to_g <="0001101"; --7 when "1000"=> a_to_g <="0000000"; --8 when "1001"=> a_to_g <="0000100"; --9 end case; end process; process (COM) begin case COM is when "1010"=> a_to_g <="1000001"; --= when "1011"=> a_to_g <="1001110"; --< when "1110"=> a_to_g <="1111000"; --> when others => a_to_g <="0000000"; end case; end process; end tris;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.numeric_std.ALL;
ENTITY calc is
Port (Num1: in Signed (1 downto 0);
Num2: in Signed (1 downto 0);
S: in STD_LOGIC_VECTOR (1 downto 0);
a_to_g:out STD_LOGIC_VECTOR (6 downto 0));
end calc;
Architecture tris of calc is
signal SUM:Signed (3 downto 0);
signal RES:Signed (3 downto 0);
signal MUL:Signed (3 downto 0);
signal COM:Signed (3 downto 0);
signal a_to_g1:signed (3 downto 0);
begin
process(Num1,Num2,S)
BEGIN
CASE S IS
WHEN "00"=>SUM<=resize(Num1,4)+Num2;
WHEN "01"=>RES<=resize(Num1,4)-Num2;
WHEN "10"=>
if Num1>Num2 then
COM <= "1110";
elsif Num1<Num2 then
COM <= "1011";
else
COM <= "1010";
end if;
WHEN OTHERS=>MUL<=(Num1*Num2);
END CASE;
if (S="00") then
a_to_g1<=SUM;
ELSIF (S="01") THEN
a_to_g1<=RES;
ELSIF (S="10") THEN
a_to_g1<=COM;
ELSE a_to_g1<=MUL;
end if;
END PROCESS;
process (a_to_g1)
begin
case a_to_g1 is
when "0000"=> a_to_g <="0000001"; --0
when "0001"=> a_to_g <="1001111"; --1
when "0010"=> a_to_g <="0010010"; --2
when "0011"=> a_to_g <="0000110"; --3
when "0100"=> a_to_g <="1001100"; --4
when "0101"=> a_to_g <="0100100"; --5
when "0110"=> a_to_g <="0100000"; --6
when "0111"=> a_to_g <="0001101"; --7
when "1000"=> a_to_g <="0000000"; --8
when "1001"=> a_to_g <="0000100"; --9
when "1010"=> a_to_g <="1000001"; --=
when "1011"=> a_to_g <="1001110"; --<
when "1110"=> a_to_g <="1111000"; -->
when others => a_to_g <="0000000";
end case;
end process;
end tris;
signal DISP : std_logic_vector(4 downto 0);
case DISP is
-- output numbers
when "00000"=> a_to_g <="0000001"; --0
when "00001"=> a_to_g <="1001111"; --1
when "00010"=> a_to_g <="0010010"; --2
when "00011"=> a_to_g <="0000110"; --3
when "00100"=> a_to_g <="1001100"; --4
when "00101"=> a_to_g <="0100100"; --5
when "00110"=> a_to_g <="0100000"; --6
when "00111"=> a_to_g <="0001101"; --7
when "01000"=> a_to_g <="0000000"; --8
when "01001"=> a_to_g <="0000100"; --9
-- output symbols
when "11010"=> a_to_g <="1000001"; --=
when "11011"=> a_to_g <="1001110"; --<
when "11110"=> a_to_g <="1111000"; -->
when others => a_to_g <="0000000";
end case;
If a signal is read inside a process it needs to be in the sensitivity list. i.e. signals on the right hand side of an assignment and when signals are used in comparisons.i just added an if and a signal for the output it says that sum,res,com,mul should be referenced in the sensitivity list. what does it means?
if (S="00") then
a_to_g1<=SUM;
ELSIF (S="01") THEN
a_to_g1<=RES;
ELSIF (S="10") THEN
a_to_g1<=COM;
ELSE a_to_g1<=MUL;
end if;
END PROCESS;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.numeric_std.ALL;
ENTITY calc is
Port (Num1: in Signed (1 downto 0);
Num2: in Signed (1 downto 0);
S: in STD_LOGIC_VECTOR (1 downto 0);
a_to_g:out STD_LOGIC_VECTOR (6 downto 0));
end calc;
Architecture tris of calc is
signal SUM:Signed (3 downto 0);
signal RES:Signed (3 downto 0);
signal MUL:Signed (3 downto 0);
signal COM:Signed (3 downto 0);
signal DISP : signed(4 downto 0);
begin
process(Num1,Num2,S)
BEGIN
CASE S IS
WHEN "00"=>SUM<=resize(Num1,4)+Num2;
WHEN "01"=>RES<=resize(Num1,4)-Num2;
WHEN "10"=>
if Num1>Num2 then
COM <= "1110";
elsif Num1<Num2 then
COM <= "1011";
else
COM <= "1010";
end if;
WHEN OTHERS=>MUL<=(Num1*Num2);
END CASE;
END PROCESS;
process(Num1,Num2,S)
BEGIN
CASE S IS
WHEN "00"=>SUM<=DISP;
WHEN "01"=>RES<=DISP;
WHEN "10"=>COM<=DISP;
WHEN others=>MUL<=DISP;
END CASE;
END PROCESS;
process (DISP)
begin
case DISP is
-- output numbers
when "00000"=> a_to_g <="0000001"; --0
when "00001"=> a_to_g <="1001111"; --1
when "00010"=> a_to_g <="0010010"; --2
when "00011"=> a_to_g <="0000110"; --3
when "00100"=> a_to_g <="1001100"; --4
when "00101"=> a_to_g <="0100100"; --5
when "00110"=> a_to_g <="0100000"; --6
when "00111"=> a_to_g <="0001101"; --7
when "01000"=> a_to_g <="0000000"; --8
when "01001"=> a_to_g <="0000100"; --9
-- output symbols
when "11010"=> a_to_g <="1000001"; --=
when "11011"=> a_to_g <="1001110"; --<
when "11110"=> a_to_g <="1111000"; -->
when others => a_to_g <="0000000";
end case;
end process;
end tris;
Code VHDL - [expand] 1 2 3 4 5 6 WHEN "00"=> -- when S is "00" then do... -- the following assignment: SUM<=resize(Num1,4)+Num2; WHEN "00"=> -- when S is "00" then do... -- the following assignment: SUM<=DISP;
new in .... programing in vhdl
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.numeric_std.ALL;
ENTITY calc is
Port (Num1: in Signed (1 downto 0);
Num2: in Signed (1 downto 0);
S: in STD_LOGIC_VECTOR (1 downto 0);
a_to_g:out STD_LOGIC_VECTOR (6 downto 0));
end calc;
Architecture tris of calc is
signal SUM:Signed (4 downto 0);
signal RES:Signed (4 downto 0);
signal MUL:Signed (4 downto 0);
signal COM:Signed (4 downto 0);
signal DISP: signed(4 downto 0);
begin
process(Num1,Num2,S)
BEGIN
CASE S IS
WHEN "00"=>SUM<=resize(Num1,5)+Num2;
SUM<=DISP;
WHEN "01"=>RES<=resize(Num1,5)-Num2;
RES<=DISP;
WHEN "10"=>
if Num1>Num2 then
COM <= "11110";
elsif Num1<Num2 then
COM <= "11011";
else
COM <= "11010";
end if;
WHEN OTHERS=>MUL<=resize(Num1,3)*Num2;
MUL<=DISP;
END CASE;
END PROCESS;
process (DISP)
begin
case DISP is
-- output numbers
when"00000"=> a_to_g <="0000001"; --0
when "00001"=> a_to_g <="1001111"; --1
when "00010"=> a_to_g <="0010010"; --2
when "00011"=> a_to_g <="0000110"; --3
when "00100"=> a_to_g <="1001100"; --4
when "00101"=> a_to_g <="0100100"; --5
when "00110"=> a_to_g <="0100000"; --6
when "00111"=> a_to_g <="0001101"; --7
when "01000"=> a_to_g <="0000000"; --8
when "01001"=> a_to_g <="0000100"; --9
-- output symbols
when "11010"=> a_to_g <="1000001"; --=
when "11011"=> a_to_g <="1001110"; --<
when "11110"=> a_to_g <="1111000"; -->
when others => a_to_g <="0000000";
end case;
end process;
end tris;
CASE S IS
WHEN "00"=>
SUM<=resize(Num1,5)+Num2;
SUM<=DISP;
Code VHDL - [expand] 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 library IEEE; use IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; USE IEEE.numeric_std.ALL; ENTITY calc is Port (Num1: in Signed (1 downto 0); Num2: in Signed (1 downto 0); S: in STD_LOGIC_VECTOR (1 downto 0); a_to_g:out STD_LOGIC_VECTOR (6 downto 0)); end calc; Architecture tris of calc is signal SUM:Signed (4 downto 0); signal RES:Signed (4 downto 0); signal MUL:Signed (4 downto 0); signal COM:Signed (4 downto 0); signal DISP : signed(4 downto 0); begin process(Num1,Num2,S) BEGIN CASE S IS WHEN "00"=>SUM<=resize(Num1,5)+Num2; WHEN "01"=>RES<=resize(Num1,5)-Num2; WHEN "10"=> if Num1>Num2 then COM <= "11110"; elsif Num1<Num2 then COM <= "11011"; else COM <= "11010"; end if; WHEN OTHERS=>MUL<=resize(Num1,3)*Num2; END CASE; END PROCESS; PROCESS (S,SUM,RES,MUL,COM) BEGIN IF (S="00") THEN DISP<=SUM; ELSIF (S="01") THEN DISP<=RES; ELSIF (S="10") THEN DISP<=COM; ELSE DISP<=MUL; END IF; END PROCESS; process (DISP) begin case DISP is -- output numbers when "00000"=> a_to_g <="0000001"; --0 when "00001"=> a_to_g <="1001111"; --1 when "00010"=> a_to_g <="0010010"; --2 when "00011"=> a_to_g <="0000110"; --3 when "00100"=> a_to_g <="1001100"; --4 when "00101"=> a_to_g <="0100100"; --5 when "00110"=> a_to_g <="0100000"; --6 when "00111"=> a_to_g <="0001101"; --7 when "01000"=> a_to_g <="0000000"; --8 when "01001"=> a_to_g <="0000100"; --9 -- output symbols when "11010"=> a_to_g <="1000001"; --= when "11011"=> a_to_g <="1001110"; --< when "11110"=> a_to_g <="1111000"; --> when others => a_to_g <="0000000"; end case; end process; end tris;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.numeric_std.ALL;
ENTITY calc is
Port (Num1: in Signed (1 downto 0);
Num2: in Signed (1 downto 0);
S: in STD_LOGIC_VECTOR (1 downto 0);
a_to_g:out STD_LOGIC_VECTOR (6 downto 0));
end calc;
Architecture tris of calc is
signal SUM:Signed (4 downto 0);
signal RES:Signed (4 downto 0);
signal MUL:Signed (4 downto 0);
signal COM:Signed (4 downto 0);
signal DISP : signed(4 downto 0);
begin
process(Num1,Num2,S)
BEGIN
CASE S IS
WHEN "00"=>SUM<=resize(Num1,5)+Num2;
WHEN "01"=>RES<=resize(Num1,5)-Num2;
WHEN "10"=>
if Num1>Num2 then
COM <= "11110";
elsif Num1<Num2 then
COM <= "11011";
else
COM <= "11010";
end if;
WHEN OTHERS=>MUL<=resize(Num1,3)*Num2;
END CASE;
END PROCESS;
PROCESS (S,SUM,RES,MUL,COM)
BEGIN
IF (S="00") THEN DISP<=SUM;
ELSIF (S="01") THEN DISP<=RES;
ELSIF (S="10") THEN DISP<=COM;
ELSE DISP<=MUL;
END IF;
END PROCESS;
process (DISP)
begin
case DISP is
-- output numbers
when "00000"=> a_to_g <="0000001"; --0
when "00001"=> a_to_g <="1001111"; --1
when "00010"=> a_to_g <="0010010"; --2
when "00011"=> a_to_g <="0000110"; --3
when "00100"=> a_to_g <="1001100"; --4
when "00101"=> a_to_g <="0100100"; --5
when "00110"=> a_to_g <="0100000"; --6
when "00111"=> a_to_g <="0001101"; --7
when "01000"=> a_to_g <="0000000"; --8
when "01001"=> a_to_g <="0000100"; --9
-- output symbols
when "11010"=> a_to_g <="1000001"; --=
when "11011"=> a_to_g <="1001110"; --<
when "11110"=> a_to_g <="1111000"; -->
when others => a_to_g <="0000000";
end case;
end process;
end tris;
To be strict, the requirement is that all possible combinations are covered. This is difficult without "others" for std_logic based types which can have 'X', 'H', 'Z' etc. For some types it is possible to list all cases, and "others" can then be removed. If you want to handle all possible cases explicitly it is an advantage to remove "others", because the compiler will then give an error if any case is missing.There may be more errors, but every case construct must have an others alternative (it might be empty).
i only have 1 error it says that logic equation has too many product terms on sinal a_to_g(3):
10 macro cells is simply too small. I compiled the post #15 design for MAX3000A, which has roughly a similar CPLD macro cell topology and it needs 54 macro cells.why it says this?its for a GAL 22V10D-25PC
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?