bcd-7segment decoder

A

arthur merlo

Hi guys, I'm new in VHDL and would be glad if anyone could help me
with
my bcd-7segments decoder. I dont know why its not compiling

LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY decod_7seg IS
PORT (
a : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
HEX0 : OUT STD_LOGIC_VECTOR(6 DOWNTO 0)
);
END decod_7seg;
ARCHITECTURE behaviour OF decod_7seg IS
BEGIN


HEX0 <= "1000000";
when a="0000"
else
HEX0 <= "1111001";
when a="0001"
else
HEX0<= "0100100";
when a="0010"
else
HEX0<= "0110000";
when a="0011"
else
HEX0 <= "0011001";
when a="0100"
else
HEX0<= "0100010";
when a="0101"
else
HEX0 <= "0000010";
when a="0110"
else
HEX0 <= "1111000";
when a="0111"
else
HEX0 <= "0000000";
when a="1000"
else
HEX0 <= "0010000";
when a="1001"


END behaviour;
 
K

KJ

Hi guys, I'm new in VHDL and would be glad if anyone could help me
with
my bcd-7segments decoder. I dont know why its not compiling

LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY decod_7seg IS
PORT (
a : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
HEX0 : OUT STD_LOGIC_VECTOR(6 DOWNTO 0)
);
END decod_7seg;
ARCHITECTURE behaviour OF decod_7seg IS
BEGIN


HEX0 <= "1000000";
when a="0000"
else
HEX0 <= "1111001";
when a="0001"
else
HEX0 <= "0010000";
when a="1001"

The correct form is
HEX0 <= "1000000"
when a="0000"
else
"1111001"
when a="0001"
else
....

Also, if you're planning on turning this into hardware, you need to end thestatement without the final condition like this...

"0000000" when a="1000"
else "0010000"; -- when a="1001"

Get rid of the last conditional check. If you don't you'll be defining something that gets implemented as a form of latch which in programmable devices is generally a 'no-no'. Just from a logic perspective, ask yourself what should be the output if the input does not match any of the expected inputs? You have to output something, so choose it. That is the value to use on the final 'else' without any additional 'when a= ...' conditions.

Kevin Jennings
 
E

Enrik Berkhan

arthur merlo said:
Hi guys, I'm new in VHDL and would be glad if anyone could help me
with
my bcd-7segments decoder. I dont know why its not compiling

You should look at the syntax specification of concurrent assignments again.

It's _one_ assignment, i.e. _one_ signal assignment operator '<=' and _one_
semicolon.

Try something like this:

HEX0 <= "1000000" when a = "0000" else
"1111001" when a = "0001" else
"0100100" when a = "0010" else
"0110000" when a = "0011" else
"0011001" when a = "0100" else
"0100010" when a = "0101" else
"0000010" when a = "0110" else
"1111000" when a = "0111" else
"0000000" when a = "1000" else
"0010000" when a = "1001" else
"-------";

Enrik
 
P

Paul Uiterlinden

arthur said:
Hi guys, I'm new in VHDL and would be glad if anyone could help me
with
my bcd-7segments decoder. I dont know why its not compiling

LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY decod_7seg IS
PORT (
a : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
HEX0 : OUT STD_LOGIC_VECTOR(6 DOWNTO 0)
);
END decod_7seg;

Besides the other two replies you already got: input 'a' needs to be 4 bits
wide: 3 DOWNTO 0. The values you compare with are 4 bits wide.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top