Button clock

Hi to everyone!

This is my first message here so first of all thanks to everyone to let me post here!

I have a homework, it consists on writing a processor and make it work in a Spartan 3. I did the first but the second one is getting difficult. I just want to show my profesor that processor is working well so I want to generate a clock event with a button or switch just like here:

formatting link

My UCF is this one:

#PACE: Start of Constraints generated by PACE

NET "act_reg3" CLOCK_DEDICATED_ROUTE = FALSE;

#PACE: Start of PACE I/O Pin Assignments NET "an0" LOC = "E13" ; NET "an3" LOC = "F14" ; NET "an2" LOC = "G14" ; NET "an1" LOC = "d14" ;

#This is a button to simulate a clock NET "simulated_clk" LOC = "M13" ;

######################### 8 Leds ###########################################

NET "mult_lec" LOC = "K12" ; NET "mult_esc" LOC = "P14" ; NET "mult_ret" LOC = "L12" ; NET "mult_pc" LOC = "N14" ; NET "reg_w" LOC = "P13" ; NET "call_w" LOC = "N12" ; NET "sel_alu" LOC = "P12" ;

#I use this for another thing NET "clk" LOC = "T9" ;

###################################### Segments ##########################################

NET "segmentos" LOC = "E14" ; NET "segmentos" LOC = "G13" ; NET "segmentos" LOC = "N15" ; NET "segmentos" LOC = "P15" ; NET "segmentos" LOC = "R16" ; NET "segmentos" LOC = "F13" ; NET "segmentos" LOC = "N16" ; NET "segmentos" LOC = "P16" ;

####################################### Switches ###########################################

NET "act_reg1" LOC = "F12" ; NET "act_reg2" LOC = "G12" ; NET "act_reg3" LOC = "H14" ;

#PACE: Start of PACE Area Constraints

#PACE: Start of PACE Prohibit Constraints

#PACE: End of Constraints generated by PACE

-------------------------------------------------------------------

And here is a fragment of my processor:

----PC process process(inicio,simulated_clk) variable pc_out: std_logic_vector (15 downto 0); variable pc_high : std_logic_vector(15 downto 0); begin --Si es la primera vez que se carga if inicio='0' then pc

Reply to
tupadre
Loading thread data ...

Le 18/01/2013 21:32, tupadre a écrit :

[...]

Hello Your clock edge condition looks wrong, it should be : elsif simulated_clk = '1' and simulated_clk'event then or you can use the rising_edge function instead : elsif rising_edge(simulated_clk) then

Nicolas

Reply to
Nicolas Matringe

clock

(instruction

First of all thanks for answering.

Yeah, you are right the code is wrong but is due to the translation from spanish to english (my real code is fine). However, I will try with rising_edge()...

--------------------------------------- Posted through

formatting link

Reply to
tupadre

rising_edge() doesn't work...

I modified the .ucf file in order to test if the "pulsador" switch is working by adding this line "NET "pulsador" LOC = "P11" ;" so when I switch on pulsador it should be turned on the P11 led but it doesn't light up...

My new .ucf:

#PACE: Start of Constraints generated by PACE

NET "pulsador" CLOCK_DEDICATED_ROUTE = FALSE; NET "act_reg3" CLOCK_DEDICATED_ROUTE = FALSE;

#PACE: Start of PACE I/O Pin Assignments NET "an0" LOC = "E13" ; NET "an3" LOC = "F14" ; NET "an2" LOC = "G14" ; NET "an1" LOC = "d14" ;

######################### 8 Leds ########################################### NET "mult_lec" LOC = "K12" ; NET "mult_esc" LOC = "P14" ; NET "mult_ret" LOC = "L12" ; NET "mult_pc" LOC = "N14" ; NET "reg_w" LOC = "P13" ; NET "call_w" LOC = "N12" ; NET "sel_alu" LOC = "P12" ; NET "pulsador" LOC = "P11" ;

NET "clk" LOC = "T9" ; #Frecuencia de 50 MHz

###################################### Aquí va el marcador ########################################## NET "segmentos" LOC = "E14" ; NET "segmentos" LOC = "G13" ; NET "segmentos" LOC = "N15" ; NET "segmentos" LOC = "P15" ; NET "segmentos" LOC = "R16" ; NET "segmentos" LOC = "F13" ; NET "segmentos" LOC = "N16" ; NET "segmentos" LOC = "P16" ;

####################################### Switches ########################################### ###### Indicar registro 1 ##### NET "act_reg1" LOC = "F12" ; ###### Indicar registro 2 ##### NET "act_reg2" LOC = "G12" ; ###### Indicar registro 2 ##### NET "act_reg3" LOC = "H14" ; ######### My button clock ############ NET "pulsador" LOC = "H13" ;

#PACE: Start of PACE Area Constraints

#PACE: Start of PACE Prohibit Constraints

#PACE: End of Constraints generated by PACE

Hope you can help!

--------------------------------------- Posted through

formatting link

Reply to
tupadre

You don't say exactly what doesn't work, but the obvious problem with using a button for a clock is that if it is a typical mechanical switch it will bounce, and then each button press will generate many clocks to your circuit.

You need to debounce the switch in order to use it as a clock.

-- Gabor

Reply to
GaborSzakacs

Ok, it didn't work because the 'start' port was always to 0 so the processor couldn't start working :)

--------------------------------------- Posted through

formatting link

Reply to
tupadre

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.