Advertisement
Guest User

Circuits #1.1

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module name (
  2.     input clk,    // Clock
  3.     input rst, // Clock Enable
  4.     input [7:0] a,  // Asynchronous reset active low
  5.     input [7:0] y
  6. );
  7.  
  8. reg[7:0] sum;
  9. reg[7:0] ctr;
  10.  
  11. always @(posedge clk, negedge rst)
  12. begin
  13.     if(clk)
  14.         ctr <= ctr + 1
  15.     // rst signal ended
  16.     else
  17.         ctr <= 0
  18. end
  19.  
  20. always @*
  21. begin
  22.     sum = ctr + a;
  23.     if( ctr[7] == 0 )
  24.         y = sum;
  25.     else
  26.         y = a;
  27. end
  28.  
  29. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement