25 lines
505 B
Systemverilog
25 lines
505 B
Systemverilog
`timescale 1ns / 1ps
|
|
|
|
module counter_4b (
|
|
input logic clk,
|
|
input logic rst,
|
|
input logic en,
|
|
input logic load,
|
|
input logic [3:0] data_in,
|
|
output logic [3:0] count,
|
|
output logic max_tick
|
|
);
|
|
|
|
always_ff @(posedge clk) begin
|
|
if(rst) begin
|
|
count <= 4'b0000;
|
|
end else if(load) begin
|
|
count <= data_in;
|
|
end else if(en) begin
|
|
count <= count + 4'd1;
|
|
end
|
|
end
|
|
|
|
assign max_tick = (count == 4'b1111);
|
|
|
|
endmodule |