OpenCores
URL https://opencores.org/ocsvn/tiny_tate_bilinear_pairing/tiny_tate_bilinear_pairing/trunk

Subversion Repositories tiny_tate_bilinear_pairing

[/] [tiny_tate_bilinear_pairing/] [trunk/] [group_size_is_151_bits/] [testbench/] [test_tiny.v] - Diff between revs 14 and 15

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 14 Rev 15
 
/*
 
 * Copyright 2012, Homer Hsing <homer.hsing@gmail.com>
 
 *
 
 * Licensed under the Apache License, Version 2.0 (the "License");
 
 * you may not use this file except in compliance with the License.
 
 * You may obtain a copy of the License at
 
 *
 
 * http://www.apache.org/licenses/LICENSE-2.0
 
 *
 
 * Unless required by applicable law or agreed to in writing, software
 
 * distributed under the License is distributed on an "AS IS" BASIS,
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 * See the License for the specific language governing permissions and
 
 * limitations under the License.
 
 */
 
 
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`define P 20 // clock period 
`define P 20 // clock period 
 
 
module test_tiny;
module test_tiny;
 
 
        // Inputs
        // Inputs
        reg clk;
        reg clk;
        reg reset;
        reg reset;
        reg sel;
        reg sel;
        reg [5:0] addr;
        reg [5:0] addr;
        reg w;
        reg w;
        reg [197:0] data;
        reg [197:0] data;
 
 
        // Outputs
        // Outputs
        wire [197:0] out;
        wire [197:0] out;
        wire done;
        wire done;
 
 
        // Instantiate the Unit Under Test (UUT)
        // Instantiate the Unit Under Test (UUT)
        tiny uut (
        tiny uut (
                .clk(clk),
                .clk(clk),
                .reset(reset),
                .reset(reset),
                .sel(sel),
                .sel(sel),
                .addr(addr),
                .addr(addr),
                .w(w),
                .w(w),
                .data(data),
                .data(data),
                .out(out),
                .out(out),
                .done(done)
                .done(done)
        );
        );
 
 
        initial begin
        initial begin
                // Initialize Inputs
                // Initialize Inputs
                clk = 0;
                clk = 0;
                reset = 0;
                reset = 0;
                sel = 0;
                sel = 0;
                addr = 0;
                addr = 0;
                w = 0;
                w = 0;
                data = 0;
                data = 0;
 
 
                // Wait 100 ns for global reset to finish
                // Wait 100 ns for global reset to finish
                #100;
                #100;
 
 
                // Add stimulus here
                // Add stimulus here
        reset = 1; // keep FSM silent
        reset = 1; // keep FSM silent
            // init x, y
            // init x, y
            write(3, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
            write(3, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
            write(5, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            write(5, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            write(6, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
            write(6, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
            write(7, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            write(7, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            /* read back. uncomment me if error happens */
            /* read back. uncomment me if error happens */
            /* read(3);
            /* read(3);
            $display("xp = %h", out);
            $display("xp = %h", out);
            read(5);
            read(5);
            $display("yp = %h", out);
            $display("yp = %h", out);
            read(6);
            read(6);
            $display("xq = %h", out);
            $display("xq = %h", out);
            read(7);
            read(7);
            $display("yq = %h", out);*/
            $display("yq = %h", out);*/
        reset = 0;
        reset = 0;
        sel = 0; w = 0;
        sel = 0; w = 0;
        @(posedge done);
        @(posedge done);
        @(negedge clk);
        @(negedge clk);
            read(3);
            read(3);
            check(194'h21181940120548aa020568aa65a5989609251595a89a44599);
            check(194'h21181940120548aa020568aa65a5989609251595a89a44599);
            read(5);
            read(5);
            check(194'h0560aa60a0954548aa615069885106a16281162056945a084);
            check(194'h0560aa60a0954548aa615069885106a16281162056945a084);
            read(6);
            read(6);
            check(194'h21181940120548aa020568aa65a5989609251595a89a44598);
            check(194'h21181940120548aa020568aa65a5989609251595a89a44598);
            read(7);
            read(7);
            check(194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            check(194'h0a905590506a8a845592a09644a2095291422910a968a5048);
            read(9);
            read(9);
            check(194'h09a49266428495042842965645266a2164a1268408a669866);
            check(194'h09a49266428495042842965645266a2164a1268408a669866);
            read(10);
            read(10);
            check(194'h204446152452400968480544296829199a169a2562a908520);
            check(194'h204446152452400968480544296829199a169a2562a908520);
            read(11);
            read(11);
            check(194'h1699142918666651a156954a80544689590a5094624610281);
            check(194'h1699142918666651a156954a80544689590a5094624610281);
            read(12);
            read(12);
            check(194'h2461998924145511611291626a4a295888569280285884661);
            check(194'h2461998924145511611291626a4a295888569280285884661);
            read(13);
            read(13);
            check(194'h1040525045a404150a1881aa91a99156660a1658a090a1091);
            check(194'h1040525045a404150a1881aa91a99156660a1658a090a1091);
            read(14);
            read(14);
            check(194'h2400a94249694808254880924a06494816081900811198925);
            check(194'h2400a94249694808254880924a06494816081900811198925);
            $display("Good");
            $display("Good");
        $finish;
        $finish;
        end
        end
 
 
    initial #100 forever #(`P/2) clk = ~clk;
    initial #100 forever #(`P/2) clk = ~clk;
 
 
    task write;
    task write;
        input [6:0] adr;
        input [6:0] adr;
        input [197:0] dat;
        input [197:0] dat;
        begin
        begin
            sel = 1;
            sel = 1;
            w = 1;
            w = 1;
            addr = adr;
            addr = adr;
            data = dat;
            data = dat;
            #(`P);
            #(`P);
        end
        end
    endtask
    endtask
 
 
    task read;
    task read;
        input [6:0] adr;
        input [6:0] adr;
        begin
        begin
            sel = 1;
            sel = 1;
            w = 0;
            w = 0;
            addr = adr;
            addr = adr;
            #(`P);
            #(`P);
        end
        end
    endtask
    endtask
 
 
    task check;
    task check;
        input [197:0] wish;
        input [197:0] wish;
        begin
        begin
            if (out !== wish)
            if (out !== wish)
                begin $display("Error!"); $finish; end
                begin $display("Error!"); $finish; end
        end
        end
    endtask
    endtask
endmodule
endmodule
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.