Advertisement
STANAANDREY

aclab3 pb5

Oct 11th, 2023 (edited)
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module mul5bcd (
  2.   input [3:0] i,
  3.   output reg [3:0] d,
  4.   output reg [3:0] u
  5. );
  6.     always @(*)
  7.         u = (i*5) % 10;
  8.     always @(*)
  9.         d = ((i*5)/10) % 10;
  10. endmodule
  11.  
  12. module mul5bcd_tb;
  13.   reg [3:0] i;
  14.   wire [3:0] d, u;
  15.  
  16.   mul5bcd mul5bcd_i (.i(i), .d(d), .u(u));
  17.  
  18.   integer k;
  19.   initial begin
  20.     $display("Time\ti\t\td\t\tu");
  21.     $monitor("%0t\t%b(%4d)\t%b(%4d)\t%b(%4d)", $time, i, i, d, d, u, u);
  22.     i = 0;
  23.     for (k = 1; k < 10; k = k + 1)
  24.       #10 i = k;
  25.   end
  26. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement