Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Vhdl codes for counter to start and purse

Altera_Forum
Honored Contributor II
2,261 Views

Hi, 

 

I need urgent help on how to design a stopwatch that can stop/purse using vhdl code. I will really appreciate any urgent reply to this. 

 

Thanks. 

 

Waiting for your replies.
0 Kudos
14 Replies
Altera_Forum
Honored Contributor II
1,515 Views

Use Quartus -> Right click -> Insert template -> Full design -> Counter

0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

I didnt get what you are saying. 

 

I have designed the counter but I want to work on the stop and start botton on the board to stop/start when i press stop/start without holding the button down. 

 

I will need quick reply from you and other members of this forum.
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

Add the following lines: 

 

--pseudocode -- on the clock edge if start = '1' then -- or may be '0' depending on key logic start_L <= '1'; elsif stop = '1' then start_L <= '0'; end if; if start_L = '1' then count <= count + 1; end if;
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

Can you make ce input to be for both start/stop/pause or you separate start, stop and purse as different input logic? 

I will appreciate your urgent reply
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

I assume CE is clkenable. You can apply it to all clocked registers at same time.

0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

can i separate the START AND PURSE with separate input i.e 

 

Start: IN_STD_LOGIC 

PAUSE: IN_STD_LOGIC
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

you can start, stop, reset, freeze reverse,...etc at will by choosing a switch for each decision

0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

is not working out at. I want to the button start to be pressed once and it will purse. I have been able to do it that if i press it down, it will purse. Now I want a code for CLockenable that can stop the counter, like clear it without changing and if i press it again, it should be able to start. 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

is not working out . I want the button start to be pressed once and it will purse. I have been able to do it such that if i press it down, it will purse. Now I want a code for CLockenable that can stop the counter, like clear it and if i press it again, it should start. 

thanks.
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

in that case it should not be called clock enable. 

 

-- on clock edge 

if sw = '1' then 

toggle <= not toggle; 

end if; 

 

if toggle = '1' then 

count <= 0; 

else 

count up... 

 

you will need to manage the logic of various switches now with care otherwise they might get in conflict. This where simulations helps.
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

how can i design the clock such that if i press pause at intial state, there should be something to remember that state so that Wwhen i do that, the button will change to the next state i.e 1 to 0.

0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

is majoprly on the start./stop and nothint else. thats all i need for now. 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

anybody with idea on how to implement this. I need it urgent.  

or If you know how to apply flip flop, logic gate to manipulate the start and stop button, I will appreciate it. Thanks 

 

 

one switch represent start and stop. All I want is that instead of holding the switch down to stop counting, I want it to stop counting if I also remove my hand. and again If I do same thing, i want it to start counting.... 

 

Please If you know what I mean, kindly help me out. 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
1,515 Views

The best way to achieve what you are asking is to draw yourself a flow chart. If you are looking for an on/off button with just one push then you would have something like this. 

 

process(clk) begin if(rising_edge(clk)) then button_prev <= button_curr; button_curr <= button; end if; end process Button_pulse <= button_curr AND (NOT button_prev); Now, you can register the pulse, add debounce, ect. It is up to you.  

 

Next, you need to create a state machine to handle the enable to your counter. From what you've described you have 2 states, on and off. you start in the off state, if the button_pulse = 1 then you go to the on state and again if the button pulse is 1 you go back to the off state. Then you describe your counter enable as 1 when in the on state and 0 when in the off. I recommend drawing this out and then creating your state machine to match your diagram.
0 Kudos
Reply