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] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 homer.hsin
/*
2
 * Copyright 2012, Homer Hsing <homer.hsing@gmail.com>
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17 5 homer.hsin
`timescale 1ns / 1ps
18
`define P 20 // clock period 
19
 
20
module test_tiny;
21
 
22
        // Inputs
23
        reg clk;
24
        reg reset;
25
        reg sel;
26
        reg [5:0] addr;
27
        reg w;
28
        reg [197:0] data;
29
 
30
        // Outputs
31
        wire [197:0] out;
32
        wire done;
33
 
34
        // Instantiate the Unit Under Test (UUT)
35
        tiny uut (
36
                .clk(clk),
37
                .reset(reset),
38
                .sel(sel),
39
                .addr(addr),
40
                .w(w),
41
                .data(data),
42
                .out(out),
43
                .done(done)
44
        );
45
 
46
        initial begin
47
                // Initialize Inputs
48
                clk = 0;
49
                reset = 0;
50
                sel = 0;
51
                addr = 0;
52
                w = 0;
53
                data = 0;
54
 
55
                // Wait 100 ns for global reset to finish
56
                #100;
57
 
58
                // Add stimulus here
59
        reset = 1; // keep FSM silent
60
            // init x, y
61 14 homer.hsin
            write(3, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
62
            write(5, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
63
            write(6, 194'h21181940120548aa020568aa65a5989609251595a89a44598);
64
            write(7, 194'h0a905590506a8a845592a09644a2095291422910a968a5048);
65 5 homer.hsin
            /* read back. uncomment me if error happens */
66
            /* read(3);
67
            $display("xp = %h", out);
68
            read(5);
69
            $display("yp = %h", out);
70
            read(6);
71
            $display("xq = %h", out);
72
            read(7);
73
            $display("yq = %h", out);*/
74
        reset = 0;
75
        sel = 0; w = 0;
76
        @(posedge done);
77
        @(negedge clk);
78
            read(9);
79 14 homer.hsin
            check(194'h09a49266428495042842965645266a2164a1268408a669866);
80 5 homer.hsin
            read(10);
81 14 homer.hsin
            check(194'h204446152452400968480544296829199a169a2562a908520);
82 5 homer.hsin
            read(11);
83 14 homer.hsin
            check(194'h1699142918666651a156954a80544689590a5094624610281);
84 5 homer.hsin
            read(12);
85 14 homer.hsin
            check(194'h2461998924145511611291626a4a295888569280285884661);
86 5 homer.hsin
            read(13);
87 14 homer.hsin
            check(194'h1040525045a404150a1881aa91a99156660a1658a090a1091);
88 5 homer.hsin
            read(14);
89 14 homer.hsin
            check(194'h2400a94249694808254880924a06494816081900811198925);
90 5 homer.hsin
            $display("Good");
91
        $finish;
92
        end
93
 
94
    initial #100 forever #(`P/2) clk = ~clk;
95
 
96
    task write;
97
        input [6:0] adr;
98
        input [197:0] dat;
99
        begin
100
            sel = 1;
101
            w = 1;
102
            addr = adr;
103
            data = dat;
104
            #(`P);
105
        end
106
    endtask
107
 
108
    task read;
109
        input [6:0] adr;
110
        begin
111
            sel = 1;
112
            w = 0;
113
            addr = adr;
114
            #(`P);
115
        end
116 7 homer.hsin
    endtask
117 5 homer.hsin
 
118
    task check;
119
        input [197:0] wish;
120
        begin
121
            if (out !== wish)
122
                begin $display("Error!"); $finish; end
123
        end
124
    endtask
125
endmodule
126
 

powered by: WebSVN 2.1.0

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