Advertisement
foreverfugazi

Untitled

Oct 16th, 2023
1,885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //code
  2.  
  3. module dff(
  4.     input logic clk, d, rst,
  5.     output logic q
  6.     );
  7.     always @(posedge rst, posedge clk)
  8.     begin
  9.     if(rst)
  10.     q<=0;
  11.     else
  12.     q<=d;
  13.     end
  14. endmodule
  15.  
  16. //testbench
  17.  
  18. module test_tb();
  19. logic clk, d, rst;
  20. logic q;
  21. dff uut(clk, d, rst, q);
  22.  
  23. initial
  24. begin
  25. clk = 0;
  26. forever #10
  27. clk = ~clk;
  28. end
  29.  
  30. initial
  31. begin
  32. rst = 1; d=0;
  33. #10
  34. rst = 0; d = 1;
  35. #5
  36. rst = 1;
  37. #10
  38. rst = 0; d = 0;
  39. #10
  40. rst = 0; d = 0;
  41. #10
  42. $finish;
  43. end
  44. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement