Advertisement
NovaYoshi

pdm

Mar 6th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module pdm #(parameter BITS=8) (
  2.     input clk,
  3.     input [BITS-1:0] level,
  4.     output out
  5. );
  6.     reg [BITS-1:0] c;
  7.     reg [BITS-1:0] swap;
  8.     integer k;
  9.     always@*
  10.         for(k=0;k<BITS;k=k+1)
  11.             swap[k]=c[BITS-1-k];
  12.  
  13.     always@(posedge clk)
  14.         c<=c+1;
  15.     assign out=swap<level;
  16. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement