Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

For Spartan3 Kit beginners

Status
Not open for further replies.

SphinX

Advanced Member level 3
Joined
Jan 25, 2002
Messages
822
Helped
58
Reputation
116
Reaction score
29
Trophy points
1,308
Location
EGYPT
Activity points
7,045
spartan3 kit

Salam,

Ok now, you have Spartan3 Kit and you want to build some projects.
I have choosed LED Blink proj. for you :)
This project blinks LED attached to FPGA every 1 seconds using on-board 50Mhz clock..

Lets start

Here is VHDL Code for divide 50Mhz to 1Hz

Code:
process (Clk50,rst)
begin
	if Rst='1' then
		mhertz_en<='0';
		mhertz_count<=(others=>'0');
	elsif Clk50'event and Clk50='1' then
		mhertz_count<=mhertz_count + 1;
		if mhertz_count="110010" then
			mhertz_en<='1';
			mhertz_count<=(others=>'0');
		else
			mhertz_en<='0';
		end if;
	end if;
end process;


-- Generate 1HZ signal from 1Mhz signal
process (Clk50,rst)
begin
	if Rst='1' then
		 hertz_en<='0';
		 hertz_count<=(others=>'0');
	elsif Clk50'event and Clk50='1' then
		if mhertz_en='1' then
			 hertz_count<=hertz_count + 1;
			if hertz_count="11110100001001000000" then
				 hertz_en<='1';
				 hertz_count<=(others=>'0');
			else
				 hertz_en<='0';
			end if;
		else
			 hertz_en<='0';
		end if;
	end if;
end process;

To blink a led every 1 sec, you have to creat a new process, and inside this process test Hertz_en value, if it's 1 then flip a signal called ClkBit,
Finally assign the IO port to this signal.

Here is the code

Code:
-- Blink LED every 1 Second :-)
process (Clk50,Rst)
begin
if Rst='1' then
	ClkOut<='0';
elsif Clk50'event and Clk50='1' then
	if hertz_en='1' then
		ClkBit<= not ClkBit;
    	end if;
end if;
ClkOut<=ClkBit;
end process;


FPGA IO connections

Clk50 = T9
Rst = M13
ClkOut = K12

Sphinx
Bye
 

spartan 3 kit

How do you the the 1Mhz signal to your module? Is it externally supplied?
 

spartan3 kit+discussions

andy1 said:
How do you the the 1Mhz signal to your module? Is it externally supplied?

Salam andy1,

No you don't need any external clocks but on-board 50 Mhz only.

The first code snippet consist of two process and its function to convert 50Mhz to 1Hz using two steps(process)

1-

Code:
-- Generate 1MHZ signal from 50Mhz signal 
process (Clk50,rst) 
begin 
   if Rst='1' then 
      mhertz_en<='0'; 
      mhertz_count<=(others=>'0'); 
   elsif Clk50'event and Clk50='1' then 
      mhertz_count<=mhertz_count + 1; 
      if mhertz_count="110010" then 
         mhertz_en<='1'; 
         mhertz_count<=(others=>'0'); 
      else 
         mhertz_en<='0'; 
      end if; 
   end if; 
end process;


2-

Code:
-- Generate 1HZ signal from 1Mhz signal 
process (Clk50,rst) 
begin 
   if Rst='1' then 
       hertz_en<='0'; 
       hertz_count<=(others=>'0'); 
   elsif Clk50'event and Clk50='1' then 
      if mhertz_en='1' then 
          hertz_count<=hertz_count + 1; 
         if hertz_count="11110100001001000000" then 
             hertz_en<='1'; 
             hertz_count<=(others=>'0'); 
         else 
             hertz_en<='0'; 
         end if; 
      else 
          hertz_en<='0'; 
      end if; 
   end if; 
end process;


SphinX
Eng. Amr Ahmed
 

how to divide 50mhz to get 1mhz in vhdl

@SphinX

That was a nice project , i even think i understand it :)

Thank you for giving small understandable examples

The name Clk50 is that referring to the 50Mhz clock or could you have choosen "any name" ??

Edit : Ahh i see ...

You refer to the pin T9 , anr the 50Mhz is comming in there isnt it ??


/Bingo
 

spartan3 blinking led example vhdl

Salam Bingo,

Clk50 is just a name, you can choose any name :)
Yes T9 is the on-board clock 50Mhz input.


SphinX
 

spartan3 kits

Sure you will need the following UCF file
It defines the pins of the Spartan 3 board.
good luck


Ahmed Abdel Hamid
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top