Skip to content

Instantly share code, notes, and snippets.

@jpf91
Created May 23, 2025 09:45
Show Gist options
  • Save jpf91/48a21475b77ff3c2a79051f29c51235a to your computer and use it in GitHub Desktop.
Save jpf91/48a21475b77ff3c2a79051f29c51235a to your computer and use it in GitHub Desktop.
Saw wave generator
/*
* Saw wave generator
*/
module oscillator(
input clk,
input rstn,
input[11:0] count_max,
output[7:0] data
);
reg[11:0] counter;
always @(posedge clk) begin
if (rstn == 0) begin
counter <= 0;
end else begin
counter <= counter + count_max;
end
end
assign data = counter[11:4];
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment