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.

Looking for a 24 hour clock language template for Xilinx

Status
Not open for further replies.

L_E_D

Newbie level 5
Joined
May 2, 2006
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,398
Another help T_T

Hi to all,

Need some help on my assignment....

I'm using a spartan 3 FPGA board, need to create a 24 hours clock program using xilinx. Is there a 24 hour clock language template available? I search xilinx webby to no avail....or perhaps there is no such template.... pls help if you provide me a link or an example with regards to the 24 hours clock template....

Thank you very much...

:|

Added after 1 hours 8 minutes:

Or can anyone write me a sample code to slow down the internal clock of the board which is 50MHz...thanks again for your help
 

Another help T_T

A good starting point is the stopwatch example in IS7 in-depth tutorial:

**broken link removed**
Or can anyone write me a sample code to slow down the internal clock of the board which is 50MHz...thanks again for your help

Ya read the file ^^
 

Re: Another help T_T

I don't know if there is any template available, but I don't think describing a clock should be very difficult. The only thing you need is counters, not only one, you can for instance, create a time_base clock, let's say your base time is going to be a second. Then, the time_base counter will generate a single-clock pulse whenever it reaches the maximum count. Let's say you work with the Spartan-3 JTAG clock, which frequency is 50 MHz, then to generate a second base time, you need a counter that generates a pulse whenever it reaches 49,999,999, to indicate a second has elapsed. This pulse must be monitored by the minute counter, which will count up to 60 pulses (must be a programmable counter), and then generate a minute pulse, and so on. Do you catch the idea? If not, let me know, write me an email to mendozaulises@yahoo.com.

I am attaching the VHDL description of the 1_Sec_Time_Base generator, from a 50 MHz clock.

Do you know how to create and instantiate components?
That would be of much help.
 

Re: Another help T_T

Thanks to both for your kind replies, I will go for the tutorial instead...if I still got any problem, will catch up with you guyz again..
 

Re: Another help T_T

since to have some new problem here, kind advice is needed again..thanks in advance

I am creating a clock that will display 24 hr format on a spartan 3 fpga board. currently i am facing this problem where the clock will count till 29:59:59 --> 00:00:00. rather than 23:59:59 --> 00:00:00.. In the program, i had created a time counter. vhd file

-----------------------------------------------------------
part of the code that shows the count for hours only
------------------------------------------------------------
process (CLK, CLR)
begin
if CLR = '1' then
hr_ones <= "0000";
elsif CLK'event and CLK = '1' then
if (min_tens= "101" min_ones = "1001" and sec_tens = "101" and sec_ones = "1001" and tens = "101" and ones = "1001" and CE = '1') then
if hr_ones = "1001"then
hr_ones <= "0000";
else
hr_ones <= hr_ones + 1;
end if;
end if;
end if;
end process;

process (CLK, CLR)
begin
if CLR = '1' then
hr_tens <= "000";
elsif CLK'event and CLK = '1' then
if (hr_ones = "1001" and min_tens= "101" and min_ones = "1001" and sec_tens = "101" and sec_ones = "1001" and tens = "101" and ones = "1001" and CE = '1') then
if (hr_tens = "010" and hr_ones = "0011") then
hr_tens <= "000";
hr_ones <= "0000";
else
hr_tens <= hr_tens + 1;
end if;
end if;
end if;

end process;
--------------------------------------------------------------------------------
end of code (Remarks: the above code counts 29:59:59-->00:00:00)
---------------------------------------------------------------------------------

I will be thankful for any remarks and guidelines
 

Re: Another help T_T

ok problem solved up there....hope i'm not of a nuisance here but i got another problem...

Anyone got any experience in programming a push button on a spartan 3 board using VHDL code? I search the net and they are talking abt bounce and debounce stuff..can't really understand....

can anyone giveme a sample code? lets say when i press the push button, it will display the no. 1 on the 7 segs display, when i press again, it will display 2....and so on......your help is appreciated. thank you all again
 

Another help T_T

try this one...

Code:
-- use for my nios apex dev board

Library ieee;
Use ieee.std_logic_1164.ALL;

entity ssd_incr_decr_rst is
	port(
		 dp1, dp2 : out std_logic;
		 clk, incr_sw5, decr_sw6, rst_sw7	: in std_logic;
		 ssd_lsb, ssd_msb	: out std_logic_vector(6 downto 0));
end ssd_incr_decr_rst;

architecture ssd_incr_decr_rst_arc of ssd_incr_decr_rst is
begin
	dp1 <= '1';
	dp2 <= '1';
	
	process(clk, incr_sw5, decr_sw6, rst_sw7)
		variable mydelay : integer range 0 to 50_000000;--50M 
		constant bt_debounce : integer := 5000000;--5M
		constant rst_debounce : integer := 50_000000;--50M
		variable A, B : integer range -1 to 10;
	begin
		if rising_edge(clk) then					--*
----------------------------------------------------------
			if rst_sw7 = '0' then						--**
				mydelay := mydelay + 1;
				if mydelay = rst_debounce then
					A := 0;
					B := 0;
					mydelay := 0;
				end if;
			elsif incr_sw5 = '0' then						--**
				mydelay := mydelay + 1;
				if mydelay = bt_debounce then
					mydelay := 0;
					if (A = 9 and B = 9) then
						A := 9;
						B := 9;
					else
						A := A + 1;
						if A = 10 then
							A := 0;
							B := B + 1;
						end if;
					end if;
				end if;
			elsif (A = 0 and B = 0) then	-- this elsif statement is to make sure tht when both A B are zero, decr button cannot be pressed.
				A := 0;
				B := 0;
				mydelay := 0; -- without this line, after reset, the incr button would hav to press unpredictable long in order to increase count.
			elsif decr_sw6 = '0' then					--**					
				mydelay := mydelay + 1;
				if mydelay = bt_debounce then
					mydelay := 0;
					A := A - 1;
					if A = (-1) then
						A := 9;
						B := B - 1;
					end if; 
				end if;
			else										--**
				mydelay := 0;			
			end if;										--**			
-------------------------------------------------------
		end if;										--*	

		CASE A IS
				WHEN 0 => ssd_lsb <= "1000000";
				WHEN 1 => ssd_lsb <= "1111001";
				WHEN 2 => ssd_lsb <= "0100100";
				WHEN 3 => ssd_lsb <= "0110000";
				WHEN 4 => ssd_lsb <= "0011001";
				WHEN 5 => ssd_lsb <= "0010010";
				WHEN 6 => ssd_lsb <= "0000010";
				WHEN 7 => ssd_lsb <= "1111000";
				WHEN 8 => ssd_lsb <= "0000000";
				WHEN 9 => ssd_lsb <= "0011000";
				when others => ssd_lsb <= "0000000";
		END CASE;
		
		CASE B IS
				WHEN 0 => ssd_msb <= "1000000";
				WHEN 1 => ssd_msb <= "1111001";
				WHEN 2 => ssd_msb <= "0100100";
				WHEN 3 => ssd_msb <= "0110000";
				WHEN 4 => ssd_msb <= "0011001";
				WHEN 5 => ssd_msb <= "0010010";
				WHEN 6 => ssd_msb <= "0000010";
				WHEN 7 => ssd_msb <= "1111000";
				WHEN 8 => ssd_msb <= "0000000";
				WHEN 9 => ssd_msb <= "0011000";
				when others => ssd_msb <= "0000000";
		END CASE;

	end process;
end ssd_incr_decr_rst_arc;
 

Re: Another help T_T

sp said:
variable mydelay : integer range 0 to 50_000000;--50M
constant bt_debounce : integer := 5000000;--5M
constant rst_debounce : integer := 50_000000;--50M

Hi sp, you have been a great help, mind I ask you what is the purposes of declaring the above statement. what is mydelay used for, kindly explain?
 

Another help T_T

the mydelay is used for button function...

so tht when u press the button, u need to press it for certain amount of time (equal to mydelay) to assert the button..

this is also determine the auto-repeat rate of the button

there is two button one is increment button, another is decrement button.

the increment button (incr_sw5) is used to increase the ssd (seven segment display)

and the decrement button (decr_sw6) is used to decrease the ssd...

any question(s), dont hasitate to ask...

regards,
sp
 

Re: Another help T_T

Err...how abt the reason for you to put a different value for bt_debounce = 5M and rst_debounce = 50M and mydelay = 50M also? Kindly enlighten me..thanks again
 

Another help T_T

my apex nios dev. board come wth a 33.33MHz crystal as the clk (T = 30ns)... so using the counter for 5M (for the buton counter)... it become 5M x 30n = 0.15 second... so when u press the increment/decrement buttons, it will increase or decrease (depend on the button pressed) at a rate of 0.15s.. tht mean if u press it continuosly, it will increase/decrease after every 0.15s

for reset, people prefer to hav longer time (50M x 30n = 1.5s) so the rst need to press for 1.5s to assert the rst button. it is safer to prevent user accidentally pressing the rst... when the count is already 899584845... accidentally press will cause the value to rst to '0', which will b terrible to re-count...

mydelay is a vhdl variable use to count, and the "rst_debounce" & "bt_debounce" is the constant for rst and incr/decr buttons

regards,
sp
 

Re: Another help T_T

All thanks goes to sp, appreciate your friendly replies and thanks again for sharing..:D
 

Another help T_T

welcome, this community has been very helpful to me... whenever i can, i will try to contribute... :)

can ur xilinx dev. board work on my VHDL code with some modification?

i just familiar wth the altera dev. board... i hav nvr used xilinx stuff b4...

regards,
sp
 

Re: Another help T_T

Oh yes it works with a few modifications, I'm quite new to VHDL and Xilinx ...just started these modules 3 months back...well I only can say that I am not very good in programming but at least this is better than turbo c++ :D....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top