EmbDev.net

Forum: FPGA, VHDL & Verilog How to generate Trigger for 500ns in Verilog ?


von Saraswathy S. (saras015)


Rate this post
useful
not useful
I am working with FPGA board. For my test, i am going to add the trigger 
logic in one side [One PC], and in other side the counter design will be 
added in XILIXN VIVADO and should start to give its counter after 
receiving the trigger signal.

For every trigger [500ns], the counter should start. To execute this 
task, i need the verilog code for Creating the Trigger Signal.
1
module counter(
2
    input clk,
3
    input reset,
4
    output [127:0] counter_out,
5
    output trig
6
    );
7
    
8
    reg trig=0;
9
    reg [127:0] counter_out=0;
10
    reg [7:0] temp=0;
11
    
12
    always@(posedge clk)
13
    begin
14
    if(~reset)
15
        begin
16
        trig<=0;
17
        counter_out<=0;
18
        end
19
    else
20
        begin
21
        counter_out<=counter_out+1;
22
        temp<=temp+1;
23
        if(temp==25)
24
            begin
25
            temp<=0;
26
            trig<=~trig;
27
            end
28
        end
29
    end
30
endmodule

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.