data/full_repos/permissive/157135695/decoder_test.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:59: Unsupported: Ignoring delay on this delayed statement.\n    #100;\n    ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:75: Unsupported: Ignoring delay on this delayed statement.\n    #100;\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:120: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:162: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:204: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:246: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:287: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:328: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:370: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:412: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:454: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:496: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:538: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/157135695/decoder_test.v:580: Unsupported: Ignoring delay on this delayed statement.\n    #100; \n    ^\n%Error: data/full_repos/permissive/157135695/decoder_test.v:34: Cannot find file containing module: \'decoder\'\n  decoder dec(\n  ^~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/157135695,data/full_repos/permissive/157135695/decoder\n             data/full_repos/permissive/157135695,data/full_repos/permissive/157135695/decoder.v\n             data/full_repos/permissive/157135695,data/full_repos/permissive/157135695/decoder.sv\n             decoder\n             decoder.v\n             decoder.sv\n             obj_dir/decoder\n             obj_dir/decoder.v\n             obj_dir/decoder.sv\n%Error: Exiting due to 1 error(s), 14 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module decoder_test();


  reg  [15:0] INST;
  

  wire [2:0]  DR;
  wire [2:0]  SA;
  wire [2:0]  SB;
  wire [5:0]  IMM;
  wire		    MB;
  wire [2:0]  FS;
  wire 		    MD;
  wire		    LD;
  wire		    MW;
  
  reg  [2:0]  DR_REF;
  reg  [2:0]  SA_REF;
  reg  [2:0]  SB_REF;
  reg  [5:0]  IMM_REF;
  reg 		    MB_REF;
  reg  [2:0]  FS_REF;
  reg  		    MD_REF;
  reg 		    LD_REF;
  reg 		    MW_REF;
  
  decoder dec(
      .INST(INST),
      .DR(DR),
      .SA(SA),
      .SB(SB),
      .IMM(IMM),
      .MB(MB),
      .FS(FS),
      .MD(MD),
      .LD(LD),
      .MW(MW)
  );
  

  integer totalTests;
  integer numTestsFailed;
  



  initial
  begin
    
    numTestsFailed = 0;
    totalTests = 0;
    #100;
    



    INST =    16'b0;
    DR_REF =  3'b0;
    SA_REF =  3'b0;
    SB_REF =  3'b0;
    IMM_REF = 6'b0;
    MB_REF =  1'b0;
    FS_REF =  3'b0;
    MD_REF =  1'b0;
    LD_REF =  1'b0;
    MW_REF =  1'b0;
    
    #100;
  
    $display("MSIM> ");
    $display("MSIM> #%2d", totalTests);
    


    if (INST[15] == 1)
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]);
    else
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]);
    
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL");
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL");
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL");
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL");
    
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) ||
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF))
    begin
      numTestsFailed = numTestsFailed + 1;
    end
    
    totalTests = totalTests + 1;
    




    INST =    16'b0010001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b1; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
    

	  INST =    16'b0100001001000001; 
    DR_REF =  3'b000; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b0; 
    MW_REF =  1'b1; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b0101001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b0110001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b101; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;

	  INST =    16'b0111001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b110; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;

	  INST =    16'b1111001001001000; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b001; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001010; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b010; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001011; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b011; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001100; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b100; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001101; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b101; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001110; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b110; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;



    

    $display("MSIM> ");
    $display("MSIM> Prelab 5a Score: %2d / %2d", totalTests-numTestsFailed, totalTests);



    $stop;
  end

endmodule
module decoder_test();



  reg  [15:0] INST;
  

  wire [2:0]  DR;
  wire [2:0]  SA;
  wire [2:0]  SB;
  wire [5:0]  IMM;
  wire		    MB;
  wire [2:0]  FS;
  wire 		    MD;
  wire		    LD;
  wire		    MW;
  
  reg  [2:0]  DR_REF;
  reg  [2:0]  SA_REF;
  reg  [2:0]  SB_REF;
  reg  [5:0]  IMM_REF;
  reg 		    MB_REF;
  reg  [2:0]  FS_REF;
  reg  		    MD_REF;
  reg 		    LD_REF;
  reg 		    MW_REF;
  
  decoder dec(
      .INST(INST),
      .DR(DR),
      .SA(SA),
      .SB(SB),
      .IMM(IMM),
      .MB(MB),
      .FS(FS),
      .MD(MD),
      .LD(LD),
      .MW(MW)
  );
  

  integer totalTests;
  integer numTestsFailed;
  



  initial
  begin
    
    numTestsFailed = 0;
    totalTests = 0;
    #100;
    



    INST =    16'b0;
    DR_REF =  3'b0;
    SA_REF =  3'b0;
    SB_REF =  3'b0;
    IMM_REF = 6'b0;
    MB_REF =  1'b0;
    FS_REF =  3'b0;
    MD_REF =  1'b0;
    LD_REF =  1'b0;
    MW_REF =  1'b0;
    
    #100;
  
    $display("MSIM> ");
    $display("MSIM> #%2d", totalTests);
    


    if (INST[15] == 1)
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]);
    else
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]);
    
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL");
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL");
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL");
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL");
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL");
    
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) ||
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF))
    begin
      numTestsFailed = numTestsFailed + 1;
    end
    
    totalTests = totalTests + 1;
    




    INST =    16'b0010001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b1; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
    

	  INST =    16'b0100001001000001; 
    DR_REF =  3'b000; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b0; 
    MW_REF =  1'b1; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b0101001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b0110001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b101; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;

	  INST =    16'b0111001001000001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000001; 
    MB_REF =  1'b1; 
    FS_REF =  3'b110; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;

	  INST =    16'b1111001001001000; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b000; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001001; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b001; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001010; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b010; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001011; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b011; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001100; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b000; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b100; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001101; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b101; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;
	 

	  INST =    16'b1111001001001110; 
    DR_REF =  3'b001; 
    SA_REF =  3'b001; 
    SB_REF =  3'b001; 
    IMM_REF = 6'b000000; 
    MB_REF =  1'b0; 
    FS_REF =  3'b110; 
    MD_REF =  1'b0; 
    LD_REF =  1'b1; 
    MW_REF =  1'b0; 
     
    #100; 
   
    $display("MSIM> "); 
    $display("MSIM> #%2d", totalTests); 
     


    if (INST[15] == 1) 
      $display("MSIM> INST = [%4b][%3b][%3b][%3b][%3b] (r2r)", INST[15:12], INST[11:9], INST[8:6], INST[5:3], INST[2:0]); 
    else 
      $display("MSIM> INST = [%4b][%3b][%3b][%6b] (imm)", INST[15:12], INST[11:9], INST[8:6], INST[5:0]); 
     
    $display("MSIM>   DR  = %3b\t\t\t[%s]", DR, DR==DR_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SA  = %3b\t\t\t[%s]", SA, SA==SA_REF ? " OK " : "FAIL"); 
    $display("MSIM>   SB  = %3b\t\t\t[%s]", SB, SB==SB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   IMM = %6b\t\t[%s]",   IMM, IMM==IMM_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MB, MB==MB_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %3b\t\t\t[%s]", FS, FS==FS_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MD, MD==MD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", LD, LD==LD_REF ? " OK " : "FAIL"); 
    $display("MSIM>   MB  = %1b\t\t\t[%s]", MW, MW==MW_REF ? " OK " : "FAIL"); 
     
    if((DR!=DR_REF) || (SA!=SA_REF) || (SB!=SB_REF) || (IMM!=IMM_REF) || 
       (MB!=MB_REF) || (FS!=FS_REF) || (MD!=MD_REF) || (LD!=LD_REF) || (MW!=MW_REF)) 
    begin 
      numTestsFailed = numTestsFailed + 1; 
    end 
     
    totalTests = totalTests + 1;



    

    $display("MSIM> ");
    $display("MSIM> Prelab 5a Score: %2d / %2d", totalTests-numTestsFailed, totalTests);



    $stop;
  end

endmodule