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 RTL code help

Status
Not open for further replies.

tarek1984

Junior Member level 1
Joined
Jan 3, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
cairo
Activity points
1,406
Hi
i want to make this
pi = pi ⊕ pi−1

so i tried to use a d-flip flop to store the pi−1 to xor it with the new pi
51905d1293305920-xor-jpg

and i used this verilog code for it
module FDC (
D , // Data Input
C , // Clock Input
CLR , // Reset input
Q // Q output
);
//-----------Input Ports---------------
input D, C, CLR ;

//-----------Output Ports---------------
output Q;

//------------Internal Variables--------
reg Q;

//-------------Code Starts Here---------

always @ ( C )
if (~CLR) begin
Q <= 1'b0;
end else begin
Q <= D;
end

endmodule

but for some reasons this do not work well

in the beginning i give a clear pulse to the d-ff then i need it give a delayed value of the previous output .
Can any body help me by this verilog code

thanks
 

Attachments

  • xor.jpg
    xor.jpg
    7 KB · Views: 81
Last edited:

You have coded a synchronous reset for the DFF, is that what you intend?
but for some reasons this do not work well
Can you be more specific?

P.S.: I didn't see, that the always block misses an edge sensitive condition. It can't work.
A standard DFF with positive clock edge and low active clear looks like this:
Code:
always @ (posedge C or negedge CLR)
if (~CLR) begin
Q <= 1'b0;
end else begin
Q <= D;
end
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top