No shortcuts. Work for it.

2-bit Signal Generator (NCO) in Verilog

Recently started using version control BitBucket and I must say sharing code is definitely easier.

So here is the link to the code that generates sin and cos signals according to the required frequency.

It is 2 bit only because the range of values is between [-1,1].

If you are looking for something in the range of [0,1], that would make it a 1 bit NCO which is even easier (you just have to ignore the LSB). Focus only on sin[1] or cos[1].

This module is great if you have to quickly test something like demodulators etc.

If you figure there are issues or even found a simpler way please feel free to share them.

Alright, I’m onto figuring out the next task, atan in verilog!

P.S. I’m also going to make sharing the code easier on the blog… will try to embed it here.


  1. can you give me a test bench for it

    • surabhig

      December 5, 2018 at 8:50 pm

      You can write a brief testbench for it like this example below:

      module nco_sig_tb ();

      reg clk, reset;
      wire sin_out, cos_out;
      reg [63:0] phase_inc_carr;

      nco_sig (

      initial begin
      clk = 0;
      reset = 0;
      phase_inc_carr= 64’h00FFF; //value according to the desired frequency of sin/cos
      //See how to calculate here:

      reset = 1’b1;

      # clk = ~clk;


      Hopefully this is what you were looking for!
      Good luck,

Leave a Reply

© 2018

Theme by Anders NorenUp ↑