init
This commit is contained in:
26
code/vezba1/v1_counter.sv
Normal file
26
code/vezba1/v1_counter.sv
Normal file
@@ -0,0 +1,26 @@
|
||||
module counter
|
||||
(input clk,
|
||||
input rst,
|
||||
input ce_i,
|
||||
input up_i,
|
||||
output logic [3:0] q_o);
|
||||
|
||||
logic [3:0] count;
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
if (rst) begin
|
||||
count <= 4'b0000;
|
||||
end
|
||||
else if(ce_i) begin
|
||||
if(up_i) begin
|
||||
count <= count + 1'b1;
|
||||
end
|
||||
else begin
|
||||
count <= count - 1'b1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assign q_o = count;
|
||||
|
||||
endmodule : counter
|
||||
Reference in New Issue
Block a user