Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- always @ (posedge clk) begin
- // Increment on enable signal.
- if (en) begin
- if (x < MAX_X - 1) begin
- x <= x + 1;
- end else begin
- x <= 0;
- y <= y + 1;
- end
- end
- // Reset when no enable signal.
- if (!en) begin
- x <= 0;
- y <= 0;
- end
- // Signal done when reached max.
- // MAX_X - 2 is so that the signal is high during the last (x, y).
- if (x == MAX_X - 2 && y == MAX_Y - 1) begin
- done <= 1;
- end else begin
- done <= 0;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment