Interested In VHDL Training? Click Here

0 votes
in Verilog by (200 points)

What is posedge in Verilog, and how do I use it?

2 Answers

0 votes
by (220 points)

The posedge is the event of changing a value of either a variable or net with a direction toward the value 1. The posedge is detected on the transition from 0 to (x, z, or 1), and from (x or z) to 1. I use it to define either a flip-flop or a flip-flop with an asynchronous reset in a sequential logic.

always @(posedge clk) q <= d;
always @(posedge clk or negedge reset_n) begin
if (!reset_n) q <= 1'b0;
else q <= d;
end
0 votes
by (200 points)

posedge means that the block will trigger on the rising (positive) edge of the clock. The syntax is:

always @(posedge clk) begin
// codes here
end
This means that when there is a rising edge of signal 'clk', the code inside the begin-end statement will execute. Another way to use poseedge is:
@(posedge clk);
// code2 here
The above given code means that the statements in 'code2' will not execute until a positive edge of 'clk' occurs.

Want to improve your VHDL skills?

Click Here - Sign Up For VHDL Training

© 2022 by Hardware Coder. User contributions are licensed under cc by-sa 4.0 with attribution required. Attribution means a link to the question, answer, user, etc on this site.

This site is owned and operated by Hardware Coder in McKinney, Texas.

Send Us A Message
About Us

By using this site, you agree to the following:

Privacy Policy
Terms and Conditions
DMCA Policy
Earnings Disclaimer
Legal Disclaimer

...