Advertisement
foreverfugazi

Untitled

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