default.txt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. `timescale 1ns / 1ps
  2. /**
  3. * counter: a generic clearable up-counter
  4. */
  5. module counter
  6. #(parameter WIDTH=64, NAME="world")
  7. (
  8. input clk,
  9. input ce,
  10. input arst_n,
  11. output reg [WIDTH-1:0] q
  12. );
  13. string name = "counter";
  14. localparam val0 = 12'ha1f;
  15. localparam val1 = 12'h1fa;
  16. localparam val2 = 12'hfa1;
  17. // some child
  18. clock_buffer #(WIDTH) buffer_inst (
  19. .clk(clk),
  20. .ce(ce),
  21. .reset(arst_n)
  22. );
  23. // Simple gated up-counter with async clear
  24. always @(posedge clk or negedge arst_n) begin
  25. if (arst_n == 1'b0) begin
  26. q <= {WIDTH {1'b0}};
  27. end
  28. else begin
  29. q <= q;
  30. if (ce == 1'b1) begin
  31. q <= q + 1;
  32. end
  33. end
  34. end
  35. function int add_one(int x);
  36. return x + 1;
  37. endfunction : add_one
  38. `ifdef SIMULATION
  39. initial $display("Hello %s", NAME);
  40. `endif
  41. endmodule : counter
  42. class my_data extends uvm_data;
  43. int x, y;
  44. function add_one();
  45. x++;
  46. y++;
  47. endfunction : add_one
  48. endclass : my_data