+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Member level 1
    Points: 409, Level: 4

    Join Date
    Jul 2017
    Posts
    38
    Helped
    0 / 0
    Points
    409
    Level
    4

    Want verilog code for generating Trigger signal for 500ns

    Hi,

    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.

    I am not very much familiar with Verilog code. So please can anyone the below code. If it is wrong, please update.

    Code:
    module counter(
        input clk,
        input reset,
        output [127:0] counter_out,                              // Output : 0 to 127 pins
        output trig
        );
        
        reg trig=0;
        reg [127:0] counter_out=0;
        reg [7:0] temp=0;
        
        always@(posedge clk)
        begin
        if(~reset)
            begin
            trig<=0;
            counter_out<=0;
            end
        else
            begin
            counter_out<=counter_out+1;
            temp<=temp+1;
            if(temp==25)
                begin
                temp<=0;
                trig<=~trig;
                end
            end
        end
    endmodule

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 4
    Points: 8,214, Level: 21
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    1,221
    Helped
    268 / 268
    Points
    8,214
    Level
    21
    Blog Entries
    1

    Re: Want verilog code for generating Trigger signal for 500ns

    So please can anyone the below code. If it is wrong, please update.
    You can do it yourself by writing a test-bench for your code and verifying in simulation if it is behaving as expected.

    Why are you using two counters? You can use the counter_out value for checking and the set the trigger accordingly.

    btw - Antiquated Verilog syntax used!
    FPGA enthusiast!



    •   AltAdvertisment

        
       

  3. #3
    Full Member level 5
    Points: 2,068, Level: 10

    Join Date
    Nov 2013
    Location
    Germany
    Posts
    268
    Helped
    27 / 27
    Points
    2,068
    Level
    10

    Re: Want verilog code for generating Trigger signal for 500ns

    Try writing a testbench and check what the counter does, as dpaul mentioned you do not need 2 counters. If you need the trigger at 500ns then I would suggest you to look at the counter value condition while setting the timescale in testbench.



    •   AltAdvertisment

        
       

  4. #4
    Super Moderator
    Points: 30,484, Level: 42
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,013
    Helped
    1677 / 1677
    Points
    30,484
    Level
    42

    Re: Want verilog code for generating Trigger signal for 500ns

    Quote Originally Posted by AbinayaSivam View Post
    Code:
        output [127:0] counter_out,                              // Output : 0 to 127 pins
        output trig
        );
    What the heck are you trying to accomplish with this counter!?

    A 128-bit counter could have started at the time of the big bang and been running at 500 MHz ever since and would have never rolled over.
    That counter, using 500 MHz clock, would take approximately 21,580,000,000,000,000,000,000 years to rollover.

    - - - Updated - - -

    A 60-bit counter running at 500 MHz is potentially testable on hardware if you're willing to support the test for 73 years.



  5. #5
    Full Member level 1
    Points: 775, Level: 6
    Achievements:
    Created Blog entry

    Join Date
    Apr 2018
    Location
    Gdańsk, Poland
    Posts
    101
    Helped
    24 / 24
    Points
    775
    Level
    6
    Blog Entries
    3

    Re: Want verilog code for generating Trigger signal for 500ns

    Quote Originally Posted by AbinayaSivam View Post
    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.
    If I understand you correctly, you have a PC computer that generates trigger signal in 500 ns cycles to the FPGA board. You want to start a counter on every 'first trigger' and on every 'second trigger' you want that counter to be read and reset?



    •   AltAdvertisment

        
       

  6. #6
    Super Moderator
    Points: 30,484, Level: 42
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,013
    Helped
    1677 / 1677
    Points
    30,484
    Level
    42

    Re: Want verilog code for generating Trigger signal for 500ns

    Quote Originally Posted by niciki View Post
    If I understand you correctly, you have a PC computer that generates trigger signal in 500 ns cycles to the FPGA board. You want to start a counter on every 'first trigger' and on every 'second trigger' you want that counter to be read and reset?
    Not according to their code, which generates a trig signal output.

    Unless the OP clarifies what they are attempting we can only guess their intent as they have a very confusing description of the problem and code that does not match the description



--[[ ]]--