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 15

Go to most recent revision | 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(3);
79 14 homer.hsin
            check(194'h21181940120548aa020568aa65a5989609251595a89a44599);
80 5 homer.hsin
            read(5);
81 14 homer.hsin
            check(194'h0560aa60a0954548aa615069885106a16281162056945a084);
82 5 homer.hsin
            read(6);
83 14 homer.hsin
            check(194'h21181940120548aa020568aa65a5989609251595a89a44598);
84 5 homer.hsin
            read(7);
85 14 homer.hsin
            check(194'h0a905590506a8a845592a09644a2095291422910a968a5048);
86 5 homer.hsin
            read(9);
87 14 homer.hsin
            check(194'h09a49266428495042842965645266a2164a1268408a669866);
88 5 homer.hsin
            read(10);
89 14 homer.hsin
            check(194'h204446152452400968480544296829199a169a2562a908520);
90 5 homer.hsin
            read(11);
91 14 homer.hsin
            check(194'h1699142918666651a156954a80544689590a5094624610281);
92 5 homer.hsin
            read(12);
93 14 homer.hsin
            check(194'h2461998924145511611291626a4a295888569280285884661);
94 5 homer.hsin
            read(13);
95 14 homer.hsin
            check(194'h1040525045a404150a1881aa91a99156660a1658a090a1091);
96 5 homer.hsin
            read(14);
97 14 homer.hsin
            check(194'h2400a94249694808254880924a06494816081900811198925);
98 5 homer.hsin
            $display("Good");
99
        $finish;
100
        end
101
 
102
    initial #100 forever #(`P/2) clk = ~clk;
103
 
104
    task write;
105
        input [6:0] adr;
106
        input [197:0] dat;
107
        begin
108
            sel = 1;
109
            w = 1;
110
            addr = adr;
111
            data = dat;
112
            #(`P);
113
        end
114
    endtask
115
 
116
    task read;
117
        input [6:0] adr;
118
        begin
119
            sel = 1;
120
            w = 0;
121
            addr = adr;
122
            #(`P);
123
        end
124 7 homer.hsin
    endtask
125 5 homer.hsin
 
126
    task check;
127
        input [197:0] wish;
128
        begin
129
            if (out !== wish)
130
                begin $display("Error!"); $finish; end
131
        end
132
    endtask
133
endmodule
134
 

powered by: WebSVN 2.1.0

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