Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me write a code for NCO in Verilog

Status
Not open for further replies.

rajsrikanth

Full Member level 2
Joined
Apr 19, 2006
Messages
130
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Location
Hyderabad
Activity points
1,947
can any one help me to write code for NCO (numerical control oscillator in verilog.

if anyone have the code pls can u send me.

thanx
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
638
Reputation
1,274
Reaction score
89
Trophy points
1,328
Location
USA
Activity points
33,176
NCO

An NCO can be quite simple: a delta-phase constant repeatedly added to an accumulator. It generates a sawtooth output value, and requires only a few lines of code.

Code:
module top (clk, out);
  input             clk;
  output reg [31:0] out = 0;  // assumes Verilog 2001

  always @ (posedge clk)
    out <= out + 170000 * 64'h100000000 / 50000000;  // 170 kHz output, 50 MHz clock
endmodule
Do you need anything fancier than that?
If you need a sinewave output, then you can feed the sawtooth into a sine lookup table.

Plenty of NCO/DDS info available on the web, such as this page:
https://www.hit.bme.hu/~papay/sci/DDS/start.htm
 

rajsrikanth

Full Member level 2
Joined
Apr 19, 2006
Messages
130
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Location
Hyderabad
Activity points
1,947
Re: NCO

thanx for ur reply.
and i want something in this to be clear. in the above what is the 64bit data.

actually my need is . iam taking samples from ADC and i get modulated data from that and i need to Multiply this NCO output to the ADC output . so in this case how i have to write the code.
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
638
Reputation
1,274
Reaction score
89
Trophy points
1,328
Location
USA
Activity points
33,176
NCO

The value 64'h100000000 equals 2^32, where 32 is the accumulator width, which I chose arbitrarily. I made the value 64 bits wide simply to avoid overflow during the multiplication.

I think you meant to say "i need to Multiply this NCO output by the ADC output". If that's correct, then it sounds like you intend to use the NCO as a local oscillator feeding into a mixer. If that's true, then you probably don't want to use my example until you have converted its sawtooth output into a sinewave. Check your synthesis software libraries for a sinewave table generator, or create your own module.

Depending on your overall system architecture and your synthesis software capabilities, you may be able to simply use Verilog's * multiply operator to mix the NCO and ADC outputs.
 

rajsrikanth

Full Member level 2
Joined
Apr 19, 2006
Messages
130
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Location
Hyderabad
Activity points
1,947
Re: NCO

in nco how do u take the frequency, and can u tell me how to design frequency syntehsizer,
i have to track the frequency that is obtained from adc. (this is part of a demodulation technique)
 

rajsrikanth

Full Member level 2
Joined
Apr 19, 2006
Messages
130
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Location
Hyderabad
Activity points
1,947
Re: NCO

track means. carrier tracking. as the signal i obtained is a modulated one so i have to remove the carrier then process actual signal
no confusion mine is a basic demodulation technique. i want to do the demodulation.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top