+ Post New Thread
Results 1 to 20 of 35

5th June 2005, 15:48 #1
 Join Date
 Apr 2005
 Posts
 284
 Helped
 6 / 6
 Points
 2,789
 Level
 12
verilog sine wave
Anyone can tell me how to create a sine wave with verilog ? thanx !

5th June 2005, 23:07 #2
 Join Date
 Sep 2004
 Posts
 6
 Helped
 0 / 0
 Points
 1,506
 Level
 8
verilog sin
Do you want to make sine wave for the test bench or do you want to make a circuit which generates sine wave?
For the test bench you can make a look up table. If you want to make a digital circuit then try making a pwm generator.

6th June 2005, 06:20 #3
 Join Date
 Nov 2001
 Posts
 654
 Helped
 58 / 58
 Points
 7,781
 Level
 21
verilog sine
Originally Posted by feel_on_on
1 members found this post helpful.

6th June 2005, 08:19 #4
sine wave verilog
If you use sine wave to do simulation, you can use pli to achieve it
1 members found this post helpful.

6th June 2005, 08:44 #5
 Join Date
 Jul 2004
 Posts
 892
 Helped
 177 / 177
 Points
 9,432
 Level
 23
verilog sine generator
Here is the code ur looking for I am posting it here one more time!
Hope this helps!
Code: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
7 members found this post helpful.

Advertisment

6th June 2005, 09:18 #6
 Join Date
 Feb 2005
 Posts
 36
 Helped
 1 / 1
 Points
 2,078
 Level
 10
verilog sin cos
VerilogA maybe solve your problem.

Advertisment

6th June 2005, 18:37 #7
sine function in verilog
Hi, nand_gates
Could you paste your waveform? I don't think that it can bring the sine wave.
Thanks

7th June 2005, 02:59 #8
 Join Date
 Apr 2005
 Posts
 284
 Helped
 6 / 6
 Points
 2,789
 Level
 12
sine wave in verilog
Hi,nand_gates
what simulation tools should be used to create sine
wave with ur code?

7th June 2005, 05:46 #9
 Join Date
 May 2004
 Posts
 94
 Helped
 5 / 5
 Points
 1,978
 Level
 10
verilog sine cos
If you want to generate sin stimulus in a testbench, you can create sin wave in other tools such as matlab or SPW then write out the data to a file ,finally reading the file in testbench written in verilog.

Advertisment

7th June 2005, 06:11 #10
 Join Date
 Jul 2004
 Posts
 892
 Helped
 177 / 177
 Points
 9,432
 Level
 23
sine wave using verilog
Any simulation tool will do!
The trick here is the generated sine output is in two's complement
integer format or its signed integer. To conver it into unsigned you
will have to invert the msb.
If you are using modelsim wave form viewer you can change the format
of wave to signed integer analog you will see sine wave....

12th June 2005, 07:47 #11
 Join Date
 Jun 2005
 Posts
 373
 Helped
 8 / 8
 Points
 2,793
 Level
 12
sine in verilog
you can create a sine wave with DDS technology,
for detail, please visit <www.analog.com> and search DDS.
Originally Posted by feel_on_on

25th July 2005, 04:20 #12
 Join Date
 Apr 2005
 Posts
 284
 Helped
 6 / 6
 Points
 2,789
 Level
 12
generating sine wave in vhdl
nand_gates! please tell me the code theory?i never had understanded it!

25th July 2005, 06:27 #13
 Join Date
 Oct 2004
 Posts
 520
 Helped
 30 / 30
 Points
 4,439
 Level
 15
verilog generate sine wave
Another way: using the Taylor expansion coefficients of sin and cosine, for DDS which is basically same idea as using matlab, you need more tools and hence extra complexity.
Question: Can we use VerilogAMS for this sort of tasks? or even SystemC?

3rd August 2005, 01:11 #14
 Join Date
 Jan 2004
 Posts
 5
 Helped
 0 / 0
 Points
 1,615
 Level
 9
verilog sine wave generator
Here is my result for easy implement sinewave, including control
[1] Frequency (phase Step)
[2] Phase offset

17th November 2009, 10:58 #15
 Join Date
 Oct 2009
 Location
 INDIA
 Posts
 1
 Helped
 0 / 0
 Points
 558
 Level
 5
Re: How to create a sine wave with verilog ?
you try to make a look up table considering the values for a sine wave and store it in its internal RAM.. i hope u got..

1st December 2009, 20:31 #16
 Join Date
 Oct 2005
 Posts
 23
 Helped
 1 / 1
 Points
 1,796
 Level
 9
Re: How to create a sine wave with verilog ?
I found the nice code by nand_gates here. So thank you!
The code works fine, but unfortunately I'm too stupid to discover what is happening inside it.
Can anyone explain this code in more details? Please!!!
What is the main idea in the algorithm?
What if I want to change the bit width for example?
Warmly thanks for any explanation!

2nd December 2009, 05:35 #17
 Join Date
 Nov 2009
 Location
 Nagercoil
 Posts
 26
 Helped
 1 / 1
 Points
 658
 Level
 5
Re: How to create a sine wave with verilog ?
Whats is being done in the code is 'signed magnitude extension'. This is done by appending digits to the most significant side of the number.
If you want to increase the width then you should be extending the MSB instead of 7 (which is the MSB in this case).

2nd December 2009, 06:06 #18
 Join Date
 May 2008
 Location
 Shang Hai
 Posts
 972
 Helped
 82 / 82
 Points
 6,706
 Level
 19
Re: How to create a sine wave with verilog ?
can you use lookup table to create?

Advertisment

2nd December 2009, 08:00 #19
 Join Date
 Jan 2008
 Location
 Bochum, Germany
 Posts
 44,445
 Helped
 13540 / 13540
 Points
 255,114
 Level
 100
Re: How to create a sine wave with verilog ?
It's a second order difference equation acting as an oscillator with zero dampening.
Code:sin(n) = sin(n1) + a*cos(n1) cos(n) = cos(n1)  a*sin(n1)
As the design is effectively rotating a complex vector, it's also related to CORDIC.

2nd December 2009, 13:20 #20
 Join Date
 May 2009
 Posts
 8
 Helped
 0 / 0
 Points
 680
 Level
 5
Re: How to create a sine wave with verilog ?
// sine wave generation
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.sine_package.all;
entity sine_wave is
port( clock, reset, enable: in std_logic;
wave_out: out sine_vector_type);
end;
architecture arch1 of sine_wave is
type state_type is ( counting_up, change_down, counting_down, change_up );
signal state, next_state: state_type;
signal table_index: table_index_type;
signal positive_cycle: boolean;
begin
process( clock, reset )
begin
if reset = '1' then
state <= counting_up;
elsif rising_edge( clock ) then
if enable = '1' then
state <= next_state;
end if;
end if;
end process;
process( state, table_index )
begin
next_state <= state;
case state is
when counting_up =>
if table_index = max_table_index then
next_state <= change_down;
end if;
when change_down =>
next_state <= counting_down;
when counting_down =>
if table_index = 0 then
next_state <= change_up;
end if;
when others =>  change_up
next_state <= counting_up;
end case;
end process;
process( clock, reset )
begin
if reset = '1' then
table_index <= 0;
positive_cycle <= true;
elsif rising_edge( clock ) then
if enable = '1' then
case next_state is
when counting_up =>
table_index <= table_index + 1;
when counting_down =>
table_index <= table_index  1;
when change_up =>
positive_cycle <= not positive_cycle;
when others =>
 nothing to do
end case;
end if;
end if;
end process;
process( table_index, positive_cycle )
variable table_value: table_value_type;
begin
table_value := get_table_value( table_index );
if positive_cycle then
wave_out <= std_logic_vector(to_signed(table_value,sine_vector _type'length));
else
wave_out <= std_logic_vector(to_signed(table_value,sine_vector_type'length));
end if;
end process;
end;
+ Post New Thread
Please login