Files
lucisv/crates/vlog_formatter/tests/fixtures/counter.sv
T
lucioandClaude Fable 5 d3d9786791 Initial commit: vfmt — ruff-style Verilog/SystemVerilog formatter
Workspace with comment-preserving parser (vlog_parser), prettier-style
document IR + formatting rules (vlog_formatter), and CLI (vfmt).
Includes snapshot/idempotency tests and a TODO backlog of practices
adopted from ruff and Verible.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-18 23:12:01 -07:00

29 lines
713 B
Systemverilog

// Simple counter module
`timescale 1ns/1ps
module counter #(parameter WIDTH=8,parameter int DEPTH = 16) (input wire clk,input wire rst_n, // async reset
output logic [WIDTH-1:0] count,output logic overflow);
// internal signals
logic [WIDTH-1:0] next_count;wire enable;
assign next_count=count+1'b1;
assign overflow = (count=={WIDTH{1'b1}}) && enable;
always_ff @(posedge clk or negedge rst_n) begin
if(!rst_n) begin count<='0; end
else if(enable) count<=next_count;
else count<=count;
end
always_comb begin
case(count[1:0])
2'b00: dbg=4'd0;
2'b01,2'b10:dbg=4'd1;
default: dbg = 4'd2;
endcase
end
submod #(.W(WIDTH),.D(DEPTH)) u_sub (.clk(clk),.rst_n(rst_n),.data_out(data),.unused());
endmodule : counter