You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

47 lines
1006 B

  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 04.03.2021 11:54:49
  7. // Design Name:
  8. // Module Name: dwn_cntr
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21. module dwn_cntr(rst_n,clk, Enb,K_val,cnt_out, cnt_val_rst);
  22. input rst_n,Enb,clk;
  23. input [8:0]K_val;
  24. output [9:0]cnt_out,cnt_val_rst;
  25. reg [9:0]temp;
  26. always @ (posedge clk)
  27. begin
  28. if (!rst_n) //(!rst_n) // commented on 04032021 for chceking.
  29. begin
  30. temp <= 0;
  31. end
  32. else if (temp == K_val)
  33. temp <= temp; //10'd0;
  34. else if (Enb)
  35. temp <= temp + 1'b1;
  36. else
  37. temp <= temp;
  38. end
  39. assign cnt_out = K_val - temp;
  40. assign cnt_val_rst = temp;
  41. endmodule