//----------------------------------------------------------------------------- // // Title : alu_tf // Design : y86v2 // Author : // Company : // //----------------------------------------------------------------------------- // // File : z:\my_designs\AlternativeLab4\y86v2\src\alu_tf.v // Generated : Thu May 22 11:03:45 2014 // From : interface description file // By : Itf2Vhdl ver. 1.22 // //----------------------------------------------------------------------------- // // Description : // //----------------------------------------------------------------------------- `timescale 1 ns / 1 ns //{{ Section below this comment is automatically maintained // and may be overwritten //{module {alu_tf}} module alu_tf ( output reg [7:0] valA, output reg [7:0] valB, output reg OP, input [7:0] valE); integer results, errors, i; reg [7:0] Rexp; initial begin results = $fopen("alu_tf_output.txt"); if (results == 0) begin $display("Error: Unable to open file."); $finish; end results = results | 1; errors = 0; for(i= 0; i<1000; i=i+1) begin valA = $random; valB = $random; OP = $random; if ($random & 1) valB = ~valA; case (OP) 0: begin Rexp = valA + valB; end 1: begin Rexp = valB - valA; end 2: begin Rexp = valA & valB; end 3: begin Rexp = valA ^ valB; end endcase // case (OP) #20 $fdisplay(results, "Calculating: valA=%x valB=%x Op=%x: Expected result=%x", valA, valB, OP, Rexp); if ((valE !== Rexp[7:0])) begin $fdisplay(results, "Error: Got =%x", valE); errors = errors + 1; end end // for (i= 0; i<1000; i=i+1) $fdisplay(results, "END of test - %d errors found", errors); $fclose(results); end endmodule