Advertisement
asharma

lab3

Mar 12th, 2019
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module LabL3;
  2.  
  3.    reg   [31:0] a, b, expect;
  4.    reg   c;
  5.    wire   [31:0] z;
  6.    integer     i, j, k;
  7.    yMux #(.SIZE(32)) mux(z, a, b, c);
  8.  
  9.    initial
  10.      begin
  11.         repeat (500)
  12.           begin
  13.              a = $random;
  14.              b = $random;
  15.              c = $random % 2;
  16.  
  17.              expect = c ? b : a;
  18.  
  19.              #1; // wait for z
  20.  
  21.             if (z === expect)
  22.                $display("PASS: a=%d \n      b=%d \n      c=%d z=%d", a, b, c, z);
  23.              else
  24.                $display("FAIL: a=%b \n      b=%b \n      c=%b z=%b", a, b, c, z);
  25.  
  26.              if (z !== expect)
  27.                $display("FAIL: a=%b \n      b=%b \n      c=%b \n      z=%b \n      expect=%b", a, b, c, z, expect);
  28.           end
  29.         $finish;
  30.      end
  31.  
  32. endmodule // LabL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement