how to solve implantation design with 4leds and 3DIP switches

Joined
Sep 24, 2008
Messages
2
Reaction score
0
how to solve implantation design!!! urgently

need yr help to solve troubleshooting. cos it is not working.

i need to hand my final project by this fri asap since i am poor in VHDL program.

Here is the code that I have created to test and simulate one of my design blocks. I am creating tic tac toe warning, and this part reads an input from 3DIP switches for index, reg and error in each and output from a 4LEDs for LCD and 3LEDs for done. it is only shown example to test whether it is working or not.

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 prog4 is
Port ( reset , clk : in std_logic;
		 index : std_logic_vector(3 downto 0); 
       errorX , errorO : in std_logic;
		 reg : in std_logic_vector(3 downto 0);
		 done : out std_logic_vector(2 downto 0);
		 lcd  : out std_logic_vector(3 downto 0));
end prog4;

architecture Behavioral of prog4 is
	type STATE is (S0,S1,S2,S3,S4,S5,S6);
	signal ps, ns: STATE;
	signal mask: std_logic_vector(3 downto 0);
begin												   
										  
	Process (clk, reset)
	begin
			if reset = '0' then 
			ps <= S0;
			elsif (clk'event and clk ='1') then 
			ps <= ns;
			end if;
	end process;

	Process (clk, index)
		begin
		case index is 
		when "0001" => if errorX = '1' then mask <= "1000";	-- X had been selected
					 elsif errorO = '1' then mask <= "0100";  -- O had been selected
					 else mask <= "0000"; -- no error
					 end if;

		when "0010" => if errorX = '1' then mask <= "0010";	-- X had been selected
					 elsif errorO = '1' then mask <= "0001";  -- O had been selected
					 else mask <= "0000"; -- no error
					 end if;

		
		when others =>	null;

			end case;
			end Process;

	Process (clk ,ps)
		begin 
		
		case ps is
		when S0 => ns <= S1; lcd <= reg;  done <= "000";
		when S1 => lcd <= reg xor mask; ns <= S2; -- lcd segment off
					done <= "001";
		when S2 => lcd <= reg; ns <= S3; -- lcd segment on
					done <= "010";
		when S3 => lcd <= reg xor mask; ns <= S4;
					done <= "011";					  
		when S4 => lcd <= reg; ns <= S5;
					done <= "100";
		when S5 => lcd <= reg xor mask; ns <= S6;
					done <= "101";
		when S6 => lcd <= reg; ns <= S0; done <= "110";
		end case;
	end process;
end Behavioral;

thanks alot

regards
mitsui
 
Last edited:

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top