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.

:? Verilog Pulse Generator

Status
Not open for further replies.

maheshkuruganti

Advanced Member level 4
Joined
May 18, 2007
Messages
106
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Location
India
Activity points
1,909
verilog pulse generator

I want to know how to generate a Pulse of Fixed Duration in Verilog on application of a Trigger.I wrote a code but it is not working.Can anyone help ??
Code:
 `timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:        Allied Electronics Co.
// Engineer:       K.V.Mahesh
// 
// Create Date:    00:38:39 05/24/2009 
// Design Name:    Dual Pulse Generator
// Module Name:    Pulse_Gen 
// Project Name:   Dual Pulse Generator
// Target Devices: XC3S400A FT256 -4 Speed Grade
// Tool versions:  10.1i
// Description:    This is a Pulse Generator Module that generates a Pulse on the negative edge 
//                 of the trigger signal.The Pulse_Width word is from the main module.
//
// Dependencies:   Main.v
//
// Revision:       v0.6
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module Pulse_Gen(
    input Trigger,
    output Pulse_Out,
    input [31:0] Pulse_Width,
    input Clock
    );
	 
//////////////////////////////////////////////////////////////////////////////////	 
//Register Declaration.																			  //
//////////////////////////////////////////////////////////////////////////////////
reg[31:0] PWidth;                              //To Hold Pulse Width Word.
reg Out_Enable;                                //For Triggering Purposes.
reg Pulse=0,Done;

//////////////////////////////////////////////////////////////////////////////////
//Triggering																						  //
//////////////////////////////////////////////////////////////////////////////////
always@(posedge Trigger)
 begin
 Out_Enable=~Out_Enable;
 end

//////////////////////////////////////////////////////////////////////////////////
//Actual Pulse Generation Section															  //
//////////////////////////////////////////////////////////////////////////////////
always@(posedge Clock)
 begin
 if(PWidth==Pulse_Width)
  begin
   PWidth<=32'h00000000;
	Pulse<=1'b0;
  end
 else
  begin
   PWidth<=PWidth+1;
   Pulse<=1'b1;
  end 	
 end
 
assign Pulse_Out=Pulse;

endmodule


Thank You Very Much.
 

pulse generator verilog

maheshkuruganti said:
I want to know how to generate a Pulse of Fixed Duration
fixed or controllable by Pulse_Width input ?
from the header in your file I guess you mean rather
a generator of a pulse of duration set by the input value;
the solution depends on a few factors:
- can you accept some clock latency between the trigger and output?
- is the trigger synchronous or not to the clock?
- if both above not - can you accept that the pulse lenght is 'close'
to desired numbers of clocks, but not always equal ?

you have a signal: Out_Enable which is not used;
so the input Trigger is optimized out as well;

below you have an example solution, one of possible solutions,
may be this one does not meet all your req.
but you can see the idea;
Code:
module pulse_gen
 (
   input        Trigger,
   output       Pulse_Out,
   input [31:0] Pulse_Width,
   input        Clock
 );
   
reg [1:0] trig;

always @(posedge Clock)
 trig <= {trig[0],Trigger};

wire ld_cnt = (trig == 2'b01) ? 1'b1 : 1'b0;
 
reg [32:0] cnt;

always @(posedge Clock)
  if      ( ld_cnt )   cnt <= {1'b1,Pulse_Width};
  else if ( !cnt[32] ) cnt <= cnt;
  else                 cnt <= cnt - 1'b1;
  
assign Pulse_Out = cnt[32];

endmodule


ld_cnt [load counter] and trig is a typical 'edge detector'
circuit to detect a pos. slope of the Trigger;
if the rising edge is detected, a counter cnt
is loaded with a value of Pulse_Width and '1' on MSB;
then the counter counts down until it counts defined number of clocks;

see the simulation waveforms;
----
 
one pulse verilog

Thanks a lot it is what I need.
Also is it possible to make the Latency equal to one clock cycle.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top