Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - LED decoder with CoolRunner II

 
Thread Tools Search this Thread
Old 01-09-2006, 09:38 PM   #1
Default LED decoder with CoolRunner II


Hi,

In a school project I'm going to make 7 segment LED decoder with CoolRunner
II xc2c32a. There will be 3 inputs and 3 outputs to the CoolRunner. An
enable signal will enable the LEDs, CS to select the LED, and a 4 bit data.
I made the following VHDL code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity LED_decoder is
Port ( E : in std_logic;
CS : in std_logic_vector(1 downto 0);
DATA : in std_logic_vector(3 downto 0);
LED1 : out std_logic_vector(6 downto 0);
LED2 : out std_logic_vector(6 downto 0);
LED3 : out std_logic_vector(6 downto 0));
end LED_decoder;

architecture Behavioral of LED_decoder is

begin
--DEC-to-seven-segment decoder
--
-- *** Common Anode
--
-- 0
-- ---
-- 5 | | 1
-- --- <- 6
-- 4 | | 2
-- ---
-- 3
--
process (E, CS, DATA)
begin
if (E='1') then
if(CS="01") then
case DATA is

when "0001" => LED1 <= "1111001"; --1
when "0010" => LED1 <= "0100100"; --2
when "0011" => LED1 <= "0110000"; --3
when "0100" => LED1 <= "0011001"; --4
when "0101" => LED1 <= "0010010"; --5
when "0110" => LED1 <= "0000010"; --6
when "0111" => LED1 <= "1111000"; --7
when "1000" => LED1 <= "1111111"; --8
when "1001" => LED1 <= "0010000"; --9
when others => LED1 <= "1000000"; --0
end case;

elsif(CS="10") then
case DATA is
when "0001" => LED2 <= "1111001"; --1
when "0010" => LED2 <= "0100100"; --2
when "0011" => LED2 <= "0110000"; --3
when "0100" => LED2 <= "0011001"; --4
when "0101" => LED2 <= "0010010"; --5
when "0110" => LED2 <= "0000010"; --6
when "0111" => LED2 <= "1111000"; --7
when "1000" => LED2 <= "1111111"; --8
when "1001" => LED2 <= "0010000"; --9
when others => LED2 <= "1000000"; --0
end case;
elsif(CS="11") then
case DATA is
when "0001" => LED3 <= "1111001"; --1
when "0010" => LED3 <= "0100100"; --2
when "0011" => LED3 <= "0110000"; --3
when "0100" => LED3 <= "0011001"; --4
when "0101" => LED3 <= "0010010"; --5
when "0110" => LED3 <= "0000010"; --6
when "0111" => LED3 <= "1111000"; --7
when "1000" => LED3 <= "1111111"; --8
when "1001" => LED3 <= "0010000"; --9
when others => LED3 <= "1000000"; --0
end case;
end if;
else
LED1 <= "1111111";
LED2 <= "1111111";
LED3 <= "1111111";
end if;
end process;
end Behavioral;

I get a warnin message that says that 7-bit latch for signal LED1, LED2 and
LED3. Syntax check says that the code is ok. But in Post-Fit VHDL Model
simulation with ModelSim there are some errors, I mean some undefined and
unexpected values. Any suggestion on what the cause could be? Or any
suggestion or examples for a code to the job?

Thanx in advance




Flemming Hansen
  Reply With Quote
Old 01-10-2006, 03:33 AM   #2
jens
 
Posts: n/a
Default Re: LED decoder with CoolRunner II
You're missing a condition for the remaining possible values of CS,
which is creating the latch. I would recommend using default
assignments- move the LEDx <= "1111111" assignments to the beginning of
the process (outside of the if statement) and remove them from the end,
and that should get rid of the latch.

Your "8" might look a little dark too.



jens
  Reply With Quote
Old 01-14-2006, 02:03 PM   #3
Brian Drummond
 
Posts: n/a
Default Re: LED decoder with CoolRunner II
On Mon, 9 Jan 2006 22:38:51 +0100, "Flemming Hansen"
<> wrote:

>Hi,
>
>In a school project I'm going to make 7 segment LED decoder with CoolRunner
>II xc2c32a. There will be 3 inputs and 3 outputs to the CoolRunner. An
>enable signal will enable the LEDs, CS to select the LED, and a 4 bit data.
>I made the following VHDL code:
>
>library IEEE;
>use IEEE.STD_LOGIC_1164.ALL;
>use IEEE.STD_LOGIC_ARITH.ALL;
>use IEEE.STD_LOGIC_UNSIGNED.ALL;


One question for your tutor;

why are schools STILL teaching the use of non-standard libraries?

- Brian


Brian Drummond
  Reply With Quote
Old 01-14-2006, 03:35 PM   #4
Mike Treseler
 
Posts: n/a
Default Re: LED decoder with CoolRunner II
Brian Drummond wrote:
> why are schools STILL teaching the use of non-standard libraries?


Schools depend on low cost tools from brands X and A.
Tutorials from these vendors use non-standard libraries.
Example code from these vendors use non-standard libraries.
This newsgroup is a rare source of good examples.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 01-23-2006, 12:13 PM   #5
Brian Drummond
 
Posts: n/a
Default Re: LED decoder with CoolRunner II
On Sat, 14 Jan 2006 07:35:12 -0800, "Mike Treseler"
<> wrote:

>Brian Drummond wrote:
>> why are schools STILL teaching the use of non-standard libraries?

>
>Schools depend on low cost tools from brands X and A.
>Tutorials from these vendors use non-standard libraries.
>Example code from these vendors use non-standard libraries.
>This newsgroup is a rare source of good examples.


That's reasonable. It is something of a chore to make a vendor example
numeric_std clean, and sometimes I don't bother either.

Though often enough they have blindly included std_logic_arith for a
module that doesn't even do any arithmetic, like a register! In that
case I'll simply delete the Library/Use clause; if the compiler doesn't
complain, nothing else will.

I suppose the answer is to apply gentle pressure to the vendors ...
would reporting use of non-std libraries be an inappropriate use of
WebCase?

- Brian


Brian Drummond
  Reply With Quote
Old 01-23-2006, 03:26 PM   #6
Mike Treseler
 
Posts: n/a
Default Re: LED decoder with CoolRunner II
Brian Drummond wrote:

> Though often enough they have blindly included std_logic_arith for a
> module that doesn't even do any arithmetic, like a register! In that
> case I'll simply delete the Library/Use clause; if the compiler doesn't
> complain, nothing else will.


Yes. I do this:

library ieee;
use ieee.std_logic_1164.all;
-- use ieee.std_logic_arith
use ieee.numeric_std.all;

Then I do a sim compiles from my editor
to jump right to the next offending line

> I suppose the answer is to apply gentle pressure to the vendors ...
> would reporting use of non-std libraries be an inappropriate use of
> WebCase?


A web case including a corrected version
of the example might get noticed and
maybe even used.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone 5.1 decoder Steve Kraus DVD Video 7 03-05-2007 07:15 AM
save cost advice: decoder chip for large printer lois8386 General Help Related Topics 0 11-03-2006 06:19 AM
ISO DVD standalone player with DTS decoder Bodo Malo DVD Video 0 02-12-2006 08:56 PM
DVD DECODER Barry day DVD Video 0 06-07-2004 03:32 AM
MPEG-2 decoder for nero Donny DVD Video 10 01-08-2004 07:54 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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