Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21613 Discussions

I want to use clock oscillator...

Altera_Forum
Honored Contributor II
1,860 Views

Hi. I have DE0 board and it has 50MHz clock oscillator. 

I want to make a digital clock, and I know How to change 50MHZ to 1Hz, 

But I don't know how to make the 50MHz oscillator start. 

When i push the button or swich, I want to make the 50MHz oscillator start to work. 

How can I do that? 

I have user manual , but it doesn't tell me how to do that.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
783 Views

to slow down your clock: 

 

process(n_clr, clk) 

begin 

if(n_clr='0') then 

cont_reg <= ( others => '0' ); 

elsif(clk'event and clk='1') then 

cont_reg <= cont_prox; 

end if; 

end process; 

 

cont_prox <= cont_reg + 1 when ( cont_reg < 50000000 and cont_on='1' ) else 

( others => '0' ) when ( cont_reg = 50000000 and cont_on='1' ) else 

cont_reg; 

 

tick_1s = '1' when ( cont_reg = 50000000 ) else 

'0'; 

 

 

to start your clock with a button make a state machine: 

 

process... 

if(n_clr='0') then 

est_reg = ini; 

elsif(clk.... 

est_reg <= est_prox; 

end.... 

 

process(... 

 

est_prox <= est_reg; 

cont_on <= '0'; 

 

case est_reg is 

when ini => 

if (button ='0' ) then 

est_prox <= contando; 

end if; 

when contando => 

cont_on <='1'; 

 

...
0 Kudos
Altera_Forum
Honored Contributor II
783 Views

Try to use your clock to create a ramp... that's how you can slow down the clock.

0 Kudos
Altera_Forum
Honored Contributor II
783 Views

Thanks buddy! but.. what is the est_prox, est_reg, contando?

0 Kudos
Altera_Forum
Honored Contributor II
783 Views

est_reg, est_prox are current and next value of the state register of the state machine. You can declare this way: 

 

architecture blablabla of... 

type estado is ( ini, contando,.. ); -- only 2 states. I don't know if your design need more. 

signal est_reg, est_prox : estado; 

begin 

..... 

-- here starts the code, process, etc. 

 

As you see, contando is a state of the state machine.
0 Kudos
Reply