Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Writing a verilog code to generate a single pulse?

Status
Not open for further replies.

BALU@FPGA

Newbie
Newbie level 1
Joined
Jul 23, 2024
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12

Code Verilog - [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
31
32
33
34
`timescale 1ns / 1ps
 
module trigger_sync (
    input wire clk,
    input wire rst_n,
    input wire trigger_in,
    output reg trigger_out
);
 
    reg trigger_sync_d1;
    reg trigger_sync_d2;
    reg trigger_edge_detect;
 
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            trigger_sync_d1 <= 1'b0;
            trigger_sync_d2 <= 1'b0;
            trigger_edge_detect <= 1'b0;
        end else begin
            trigger_sync_d1 <= trigger_in;
            trigger_sync_d2 <= trigger_sync_d1;
            trigger_edge_detect <= trigger_sync_d1 & ~trigger_sync_d2;
        end
    end
 
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            trigger_out <= 1'b0;
        end else begin
            trigger_out <= trigger_edge_detect;
        end
    end
 
endmodule


[Added syntax tags]
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top