feel_on_on
Full Member level 5
![Full Member level 5](/styles/images/ranks/flevel2.gif)
verilog sine wave
Anyone can tell me how to create a sine wave with verilog ? thanx !
Anyone can tell me how to create a sine wave with verilog ? thanx !
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
feel_on_on said:Anyone can tell me how to create a sine wave with verilog ? thanx !
module sine_cos(clk, reset, en, sine, cos);
input clk, reset, en;
output [7:0] sine,cos;
reg [7:0] sine_r, cos_r;
assign sine = sine_r + {cos_r[7], cos_r[7], cos_r[7], cos_r[7:3]};
assign cos = cos_r - {sine[7], sine[7], sine[7], sine[7:3]};
always@(posedge clk or negedge reset)
begin
if (!reset) begin
sine_r <= 0;
cos_r <= 120;
end else begin
if (en) begin
sine_r <= sine;
cos_r <= cos;
end
end
end
endmodule // sine_cos
feel_on_on said:Anyone can tell me how to create a sine wave with verilog ? thanx !
sin(n) = sin(n-1) + a*cos(n-1)
cos(n) = cos(n-1) - a*sin(n-1)