Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `timescale 1ns / 1ps
- ////////////////////////////////////////////////////////////////////////////////
- // Company:
- // Engineer:
- //
- // Create Date: 17:22:48 05/21/2017
- // Design Name: serdes
- // Module Name: C:/Users/root/Documents/WSC/SERDES/test.v
- // Project Name: SERDES
- // Target Device:
- // Tool versions:
- // Description:
- //
- // Verilog Test Fixture created by ISE for module: serdes
- //
- // Dependencies:
- //
- // Revision:
- // Revision 0.01 - File Created
- // Additional Comments:
- //
- ////////////////////////////////////////////////////////////////////////////////
- module test;
- // test file
- integer plik_wej, plik_wyj;
- integer i = 0;
- reg [7:0] test_wyj = 8'b0;
- reg [7:0] test_wej [3:0];
- // Inputs
- reg [7:0] par_in;
- reg clk;
- reg reset;
- // Outputs
- wire [7:0] par_out;
- // Instantiate the Unit Under Test (UUT)
- serdes uut (
- .par_in(par_in),
- .par_out(par_out),
- .clk(clk),
- .reset(reset)
- );
- always #1 clk = ~clk;
- initial begin
- // Initialize Inputs
- par_in = 0;
- clk = 0;
- reset = 0;
- test_wej[0][7:0] = 8'b0;
- test_wej[1][7:0] = 8'b0;
- test_wej[2][7:0] = 8'b0;
- test_wej[3][7:0] = 8'b0;
- // Wait 10 ns for global reset to finish
- #16;
- reset = 1;
- end
- always @ (posedge clk) begin
- plik_wej = $fopen("dane.dat", "r");
- plik_wyj = $fopen("wyjscie.dat", "w");
- // main test code
- while(!$feof(plik_wej)) begin
- #16;
- $fscanf(plik_wej, "%h\n", par_in[7:0]);
- $fwrite(plik_wyj, "%h\n", par_out[7:0]);
- end
- $fclose(plik_wyj);
- $fclose(plik_wej);
- //match test
- plik_wyj = $fopen("wyjscie.dat", "r");
- plik_wej = $fopen("dane.dat", "r");
- while(!$feof(plik_wej)) begin
- test_wej[3][7:0] = test_wej[2][7:0];
- test_wej[2][7:0] = test_wej[1][7:0];
- test_wej[1][7:0] = test_wej[0][7:0];
- $fscanf(plik_wej, "%h\n", test_wej[0][7:0]);
- $fscanf(plik_wyj, "%h\n", test_wyj[7:0]);
- if (test_wej[3][7:0] == test_wyj[7:0] && i < 8) begin
- i = i + 1;
- $display("odebrano %d. bajt, wynik zgodny z oczekiwaniami, biezaca wartosc [%h]",i ,test_wyj[7:0]);
- if (i == 8) begin
- $display("wykryto koniec ramki");
- end
- end
- else begin
- if (test_wyj[7:0] != test_wej[3][7:0] && test_wej[3][7:0] == 8'h81) begin
- $display("wykryto poczatek ramki");
- i = 0;
- end
- else begin
- if (i < 8) begin
- $display("wynik !!!niezgodny!!! z oczekiwaniami, biezaca wartosc wyjsciowa [%h], wejsciowa [%h]", test_wyj[7:0], test_wej[3][7:0]);
- end
- else begin
- $display("przeslano bajt [%h] poza ramka", test_wej[3][7:0]);
- end
- end
- end
- end
- $fclose(plik_wej);
- $fclose(plik_wyj);
- $finish;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement