//----------------------------------------------------------------------------- // // Title : twoDigitDisplay_tf // Design : test_fixtures // Author : // Company : // //----------------------------------------------------------------------------- // // File : z:\my_designs\AlternativeLab4\test_fixtures\src\twoDigitDisplay_tf.v // Generated : Thu Oct 23 17:12:07 2014 // From : interface description file // By : Itf2Vhdl ver. 1.22 // //----------------------------------------------------------------------------- // // Description : // //----------------------------------------------------------------------------- `timescale 1 ns / 1 ps //{{ Section below this comment is automatically maintained // and may be overwritten //{module {hexShifter_tf}} module twoDigitDisplay_tf ( output reg clk, output reg [8:0] SW, input [6:0] HEX0, input [6:0] HEX1); //}} End of automatically maintained section integer resultFile, errors; reg [4:0] i; reg [6:0] expectedHi; reg [6:0] expectedLo; initial begin resultFile = $fopen("FA_tf_output.txt"); if (resultFile == 0) begin $fdisplay(resultFile, "Error: Unable to open file."); $finish; end resultFile = resultFile | 1; errors = 0; clk = 0; SW[8] = 1; clk = 1; #10 clk = 0; #10 if ((HEX0 != 64) || (HEX1 != 64)) begin $fdisplay(resultFile, "Error: Reset not functioning, returned %d and %d", HEX0, HEX1); errors = errors + 1; end else begin $fdisplay(resultFile, "Reset functionality test passed"); end SW[8] = 0; for (i = 0; i < 16; i = i + 1) begin SW[7:0] = (i * 16) + (15 - i); clk = 1; #10 clk = 0; #10 case(i) 7'd0: expectedHi = 63; 7'd1: expectedHi = 6; 7'd2: expectedHi = 91; 7'd3: expectedHi = 79; 7'd4: expectedHi = 102; 7'd5: expectedHi = 109; 7'd6: expectedHi = 125; 7'd7: expectedHi = 7; 7'd8: expectedHi = 127; 7'd9: expectedHi = 111; 7'd10: expectedHi = 119; 7'd11: expectedHi = 124; 7'd12: expectedHi = 57; 7'd13: expectedHi = 94; 7'd14: expectedHi = 121; 7'd15: expectedHi = 113; endcase case(15 - i) 7'd0: expectedLo = 63; 7'd1: expectedLo = 6; 7'd2: expectedLo = 91; 7'd3: expectedLo = 79; 7'd4: expectedLo = 102; 7'd5: expectedLo = 109; 7'd6: expectedLo = 125; 7'd7: expectedLo = 7; 7'd8: expectedLo = 127; 7'd9: expectedLo = 111; 7'd10: expectedLo = 119; 7'd11: expectedLo = 124; 7'd12: expectedLo = 57; 7'd13: expectedLo = 94; 7'd14: expectedLo = 121; 7'd15: expectedLo = 113; endcase if (HEX0 !== ~expectedHi) begin $fdisplay(resultFile, "Error: Pushed in %d - Got: %b for the first digit", SW[7:0], HEX0); errors = errors + 1; end else begin if (HEX1 !== ~expectedLo) begin $fdisplay(resultFile, "Error: Pushed in %d - Got: %b for the second digit", SW[7:0], HEX1); errors = errors + 1; end else begin $fdisplay(resultFile, "Case %d passed", i); end end end $fdisplay(resultFile, "End of test - %d errors found.", errors); $fclose(resultFile); end endmodule