Functional Counter
module cntr(q, aclr, clk, func, d);
input aclr, clk;
input [7:0] d;
input [1:0] func; // Controls the functionality
output [7:0] q;
reg [7:0]q;
always @(posedge clk or posedge aclr) begin
if (aclr)
q <= 8'h00;
else
case (func)
2'b00: q <= d; // Loads the counter
2'b01: q <= q + 1; // Counts up
2'b10: q <= q - 1; // Counts down
2'b11: q <= q;
endcase
end
endmodule
ÀÌÀü ½½¶óÀ̵å
´ÙÀ½ ½½¶óÀ̵å
ù ½½¶óÀ̵å·Î À̵¿
±×·¡ÇÈ ¹öÀü º¸±â