//----------------------------------------------------------------------------- // // Title : phase3_tf // Design : mips // Author : Steven // Company : University of Washington CSE // //----------------------------------------------------------------------------- // // File : phase3_tf.v // Generated : Mon Sep 4 14:00:52 2006 // From : e:\my_designs\NewLabs\mips378\mips378\mips\src\R_COMPARE\lab1_phase3_partb_TB_settings.txt // By : tb_verilog.pl ver. ver 1.2s // //----------------------------------------------------------------------------- // // Description : // //----------------------------------------------------------------------------- `timescale 1ps / 1ps module phase3_tf; //Internal signals declarations: reg CLK; reg SrcASel; reg SrcBSel; reg Load; reg WriteToRD; wire Zilch_actual; reg Zilch; wire Overflow_actual; reg Overflow; reg [1:0]ALUOp; wire [31:0]ALUOut_actual; reg [31:0]ALUOut; reg RegWrite; reg [1:0]ExtOp; reg [31:0]Inst; reg [31:0]CPUDataIn; wire [31:0]CPUDataOut_actual; reg [31:0]CPUDataOut; //LOG file declaration. integer report_file; //Wait time declaration used in ports monitoring. //One parameter is declared for every port. parameter Default_wait_time = 10; parameter Zilch_WaitTime = Default_wait_time;//WaitTime Parameter for port Zilch parameter Overflow_WaitTime = Default_wait_time;//WaitTime Parameter for port Overflow parameter ALUOut_WaitTime = Default_wait_time;//WaitTime Parameter for port ALUOut parameter CPUDataOut_WaitTime = Default_wait_time;//WaitTime Parameter for port CPUDataOut //Simulation time parameter SimulationTime = 64'd790000 + Default_wait_time + 1; //Errors counter integer errors_counter; //Block of Comparison functions declarations. A separate function for each output port is defined. //Comparison function for port "Zilch" function compare_Zilch; input UUT_output; input PATTERN; begin if (UUT_output !== PATTERN) compare_Zilch = 1'b1; else compare_Zilch = 1'b0; end endfunction //Comparison function for port "Overflow" function compare_Overflow; input UUT_output; input PATTERN; begin if (UUT_output !== PATTERN) compare_Overflow = 1'b1; else compare_Overflow = 1'b0; end endfunction //Comparison function for port "ALUOut" function compare_ALUOut; input [31:0] UUT_output; input [31:0] PATTERN; begin if (UUT_output !== PATTERN) compare_ALUOut = 1'b1; else compare_ALUOut = 1'b0; end endfunction //Comparison function for port "CPUDataOut" function compare_CPUDataOut; input [31:0] UUT_output; input [31:0] PATTERN; begin if (UUT_output !== PATTERN) compare_CPUDataOut = 1'b1; else compare_CPUDataOut = 1'b0; end endfunction // Unit Under Test port map Datapath UUT ( .CLK(CLK), .SrcASel(SrcASel), .SrcBSel(SrcBSel), .Load(Load), .WriteToRD(WriteToRD), .Zilch(Zilch_actual), .Overflow(Overflow_actual), .ALUOp(ALUOp), .ALUOut(ALUOut_actual), .RegWrite(RegWrite), .ExtOp(ExtOp), .Inst(Inst), .CPUDataIn(CPUDataIn), .CPUDataOut(CPUDataOut_actual)); initial begin report_file=$fopen("$DSN\\src\\Tests\\phase3_report.log"); errors_counter = 0; #SimulationTime; if (errors_counter) begin $display("Errors were encountered, differences are listed in phase3_report.log"); $fdisplay(report_file,"Some vectors failed."); end else begin $display("All vectors passed."); $fdisplay(report_file,"All vectors passed."); end $fclose(report_file); $finish; end //Below code was generated based on waveform file: "e:\my_designs\NewLabs\mips378\mips378\mips\compile\phase3.vhr" initial begin : STIMUL // begin of stimulus process #0 CLK = 1'b0; SrcASel = 1'b0; WriteToRD = 1'b0; Load = 1'b0; SrcBSel = 1'b1; ALUOp = 2'b11; Overflow = 1'b0; Zilch = 1'b0; RegWrite = 1'b1; Inst = 32'b00111100000001000001000000000000; ExtOp = 2'b10; ALUOut = 32'b00010000000000000000000000000000; CPUDataIn = 32'b000000000000000000000000XXXXXXXX; CPUDataOut = 32'b00000000000000000000000000000100; #350000; //0 CLK = 1'b1; Inst = 32'b00110101111011110111111010101111; ExtOp = 2'b00; ALUOut = 32'b00000000000000000111111010101111; CPUDataOut = 32'b00000000000000000000000000001111; #20000; //350000 CLK = 1'b0; #20000; //370000 CLK = 1'b1; ALUOp = 2'b00; RegWrite = 1'b0; Inst = 32'b10101100100011110000000000000000; ExtOp = 2'b01; ALUOut = 32'b00010000000000000000000000000000; CPUDataIn = 32'bXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; CPUDataOut = 32'b00000000000000000111111010101111; #20000; //390000 CLK = 1'b0; #20000; //410000 CLK = 1'b1; Inst = 32'b10100100100011110000000000000010; ALUOut = 32'b00010000000000000000000000000010; CPUDataIn = 32'b00000000000000000000000000000000; #20000; //430000 CLK = 1'b0; #20000; //450000 CLK = 1'b1; Inst = 32'b10100000100011110000000000000011; ALUOut = 32'b00010000000000000000000000000011; CPUDataIn = 32'b00000000000000000000000001111110; #20000; //470000 CLK = 1'b0; #20000; //490000 CLK = 1'b1; Load = 1'b1; RegWrite = 1'b1; Inst = 32'b10001100100010000000000000000000; ALUOut = 32'b00010000000000000000000000000000; CPUDataIn = 32'b10101111101011110111111010101111; CPUDataOut = 32'b00000000000000000000000000001000; #20000; //510000 CLK = 1'b0; #20000; //530000 CLK = 1'b1; Load = 1'b1; SrcBSel = 1'b1; RegWrite = 1'b1; Inst = 32'b10010100100010010000000000000010; ExtOp = 2'b01; ALUOut = 32'b00010000000000000000000000000010; CPUDataIn = 32'b00000000000000001010111110101111; CPUDataOut = 32'b00000000000000000000000000001001; #20000; //550000 CLK = 1'b0; #20000; //570000 CLK = 1'b1; Inst = 32'b10000100100010100000000000000010; CPUDataIn = 32'b11111111111111111010111110101111; CPUDataOut = 32'b00000000000000000000000000001010; #20000; //590000 CLK = 1'b0; #20000; //610000 CLK = 1'b1; Inst = 32'b10010000100010110000000000000000; ALUOut = 32'b00010000000000000000000000000000; CPUDataIn = 32'b00000000000000000000000010101111; CPUDataOut = 32'b00000000000000000000000000001011; #20000; //630000 CLK = 1'b0; #20000; //650000 CLK = 1'b1; Inst = 32'b10000000100011000000000000000000; CPUDataIn = 32'b11111111111111111111111110101111; CPUDataOut = 32'b00000000000000000000000000001100; #20000; //670000 CLK = 1'b0; #20000; //690000 CLK = 1'b1; Inst = 32'b10010000100011010000000000000001; ALUOut = 32'b00010000000000000000000000000001; CPUDataIn = 32'b00000000000000000000000001111110; CPUDataOut = 32'b00000000000000000000000000001101; #20000; //710000 CLK = 1'b0; #20000; //730000 CLK = 1'b1; Inst = 32'b10000000100011100000000000000001; CPUDataOut = 32'b00000000000000000000000000001110; #20000; //750000 CLK = 1'b0; #20000; //770000 end // end of stimulus process //Set of always bloks for ports monitoring. //One block per output port. //Always block for monitoring port "Zilch"; always @(Zilch or Zilch_actual) begin #Zilch_WaitTime if (compare_Zilch(Zilch,Zilch_actual)) begin errors_counter = errors_counter + 1; $fdisplay(report_file,$realtime,,"ps; Port Zilch: Expected value is %b, Actual value is %b",Zilch,Zilch_actual); $display($realtime,,"ps; Error on port Zilch: Expected value is %b, Actual value is %b",Zilch,Zilch_actual); end end //Always block for monitoring port "Overflow"; always @(Overflow or Overflow_actual) begin #Overflow_WaitTime if (compare_Overflow(Overflow,Overflow_actual)) begin errors_counter = errors_counter + 1; $fdisplay(report_file,$realtime,,"ps; Port Overflow: Expected value is %b, Actual value is %b",Overflow,Overflow_actual); $display($realtime,,"ps; Error on port Overflow: Expected value is %b, Actual value is %b",Overflow,Overflow_actual); end end //Always block for monitoring port "ALUOut"; always @(ALUOut or ALUOut_actual) begin #ALUOut_WaitTime if (compare_ALUOut(ALUOut,ALUOut_actual)) begin errors_counter = errors_counter + 1; $fdisplay(report_file,$realtime,,"ps; Port ALUOut: Expected value is %b, Actual value is %b",ALUOut,ALUOut_actual); $display($realtime,,"ps; Error on port ALUOut: Expected value is %b, Actual value is %b",ALUOut,ALUOut_actual); end end //Always block for monitoring port "CPUDataOut"; always @(CPUDataOut or CPUDataOut_actual) begin #CPUDataOut_WaitTime if (compare_CPUDataOut(CPUDataOut,CPUDataOut_actual)) begin errors_counter = errors_counter + 1; $fdisplay(report_file,$realtime,,"ps; Port CPUDataOut: Expected value is %b, Actual value is %b",CPUDataOut,CPUDataOut_actual); $display($realtime,,"ps; Error on port CPUDataOut: Expected value is %b, Actual value is %b",CPUDataOut,CPUDataOut_actual); end end endmodule