Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
hi, I need to counting pulses of a input in 1 second in my project. I don't know how to create 1 second signal. would you help me?
hi, actually my problem is that I can't create 1 second "high" signal!
Dear ads-ee, K-J and barry! I shouldn't use a clock and a couter to create it!
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 `timescale 1ps/1ps localparam s = 1000000000; reg high_signal; initial begin high_signal <= 1'b0; #(0.1*s); // delay for 0.1 second high_signal <= 1'b1; #(1*s); // 1 second pulse on high_signal high_signal <= 1'b0; end
hi, actually my problem is that I can't create 1 second "high" signal!
Dear ads-ee, K-J and barry! I shouldn't use a clock and a couter to create it!
The solution I posted in #4 meets all of your stated requirements.hi, actually my problem is that I can't create 1 second "high" signal!
Dear ads-ee, K-J and barry! I shouldn't use a clock and a couter to create it!
The solution I posted in #4 meets all of your stated requirements.
Kevin
Synthesis has not been stated as a requirement.Except for the synthesizing part of it.
Kevin's karma just dropped 100 points.x <= '1', '0' after 1 sec;
Kevin
constant one_million : natural := 1000000 ;
signal counter : natural ;
signal pulse : std_logic ;
process ( clock ) is
begin
if reset = '1' then
pulse <= '1' ;
counter <= ( others => '0' ) ;
elsif rising_edge ( clock ) then
if counter = one_milion - 1 then
pulse <= '0' ;
else
counter <= counter + 1 ;
end if ;
end if ;
end process ;
According to post #6, the OP says this must be done without a clock so your solution does not meet requirements.Kevin's karma just dropped 100 points.
Assuming a 1MHz input clock, this will create a "one shot" ramp from '1' to '0'.
According to post #6, the OP says this must be done without a clock so your solution does not meet requirements.
Karma is still good. Mine is still the only solution that meets all of the stated requirements.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 [B]signal b: std_logic_vector(18 downto 0); Process (CLK_20M) variable counter: integer range 0 to 67108863 ; --26 bits 67108863 Begin if rising_edge(CLK_20M) then counter:=counter + 1; if (counter < 20000000) then if rising_edge(clock) then a <= a + 1; end if; end if; end if; end process;[/B]
Hi, dear friends. Maybe I didn’t explain enough at #6.
My problem: I have to counting a clock (that is unknown period and frequency) in just 1 second.
When I use another clock (like 20 MHz) to create 1 second, I faced to this error in ISE :
“Xst:1534 - Sequential logic for node <a> appears to be controlled by multiple clocks.”
My vhdl code:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 [B]signal b: std_logic_vector(18 downto 0); Process (CLK_20M) variable counter: integer range 0 to 67108863 ; --26 bits 67108863 Begin if rising_edge(CLK_20M) then counter:=counter + 1; if (counter < 20000000) then if rising_edge(clock) then a <= a + 1; end if; end if; end if; end process;[/B]
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 process (CLK_20M) constant a : std_logic := "1000111101110000000"; --293760 variable counter: std_logic_vector(25 downto 0) ; ;--26 bits 67108863 variable count:std_logic_vector(25 downto 0) ; ;--26 bits variable rps: std_logic_vector(7 downto 0) ; -- 8 bits 255 begin if rising_edge(CLK_20M) then counter:=counter + 1; if (counter > 20000000) then counter := (others => '0'); elsif rising_edge(ENCODER_HALLSENSOR_B) then count := count + 1; end if; end if; rpss := count/a;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -- count seconds process (clk20m) begin if rising_edge (clk20m) then sec_count <= sec_count + 1; if (sec_count = 20000000-1) then sec_count <= 0; one_sec <= not one_sec; end if; end if; end process; -- count encoder edge process (enc_clk) begin -- synchronizer one_sec_1 <= one_sec; one_sec_2 <= one_sec_1; -- edge detect one_sec_3 <= one_sec_2; one_second <= one_sec_3 xor one_sec_2; -- encoder counter if (one_sec_3) then encoder_count <= count; count <= 0; else count <= count + 1; end if; end process;