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_697_bits/] [testbench/] [test_pe.v] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 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
`timescale 1ns / 1ps
18
`define P 20
19
 
20
`define M     503         // M is the degree of the irreducible polynomial
21
`define WIDTH (2*`M-1)    // width for a GF(3^M) element
22
`define WIDTH_D0 (1008-1)
23
 
24
module test_pe;
25
 
26
        // Inputs
27
        reg clk;
28
        reg reset;
29
        reg [10:0] ctrl;
30
        reg [`WIDTH_D0:0] d0;
31
        reg [`WIDTH:0] d1;
32
        reg [`WIDTH:0] d2;
33
    reg [`WIDTH:0] wish;
34
 
35
        // Outputs
36
        wire [`WIDTH:0] out;
37
 
38
        // Instantiate the Unit Under Test (UUT)
39
        PE uut (
40
                .clk(clk),
41
                .reset(reset),
42
                .ctrl(ctrl),
43
                .d0(d0),
44
                .d1(d1),
45
        .d2(d2),
46
                .out(out)
47
        );
48
 
49
        initial begin
50
                // Initialize Inputs
51
                clk = 0;
52
                reset = 0;
53
                ctrl = 0;
54
                d0 = 0;
55
                d1 = 0;
56
        d2 = 0;
57
 
58
                // Wait 100 ns for global reset to finish
59
                #100;
60
 
61
                // Add stimulus here
62
        // test mult
63
        d0 = 1006'h1119248464094a51549514585519508512555548915458194454a95a5a6550224816556284a5412965419544014a511556aa55955144aa5699655618601a19691a6691682455451456154a4585906a8615595595560656a15511545a9029959510158140619554a45a96a199aa69010216541569025125a4999591561495;
64
        d1 = 1006'h1a55960985561659551851556895049209954912568a591559455151a6a96614a415025691809658645a12a415a665241565a565896195925a558154045551590a9610255981a119295065a605955445a165985126506828941554156694564a29585611655965010115198aa64986559214641456656425290954464964;
65
        d2 = d1;
66
        wish = 1006'h296690698528561902a89185a6682428590645221996249986180602212996548298118549a161545666651980291a9806a99a9911a2044444908214800aaa04402a2209496440aa11991aa5949a0152899416598196510996a5a50629996aa68a4a9150058552196045aa42209094906684805604282410248094120a61;
67
 
68
        @(negedge clk);
69
        reset=1;#`P reset=0;
70
        ctrl=11'b11111_000000; #`P;
71
        ctrl=11'b00000_111111; #(168*`P);
72
        check;
73
 
74
        // test cubic
75
        d0 = {6'b10101, 1002'd0};
76
        d1 = 1006'h1119248464094a51549514585519508512555548915458194454a95a5a6550224816556284a5412965419544014a511556aa55955144aa5699655618601a19691a6691682455451456154a4585906a8615595595560656a15511545a9029959510158140619554a45a96a199aa69010216541569025125a4999591561495;
77
        d2 = d1;
78
        wish = 1006'h25025a210a560a450298548062454110aa9458192245809a45964889a65a258440598a41411492199a15615080a4159911826049059a691598688804a991996924864959490519956855484104849a08904919aa59886a56859269504516a0aa604a49215a25a129458a6944aa5495981061589105441842001a50899565;
79
 
80
        @(negedge clk);
81
        reset=1;#`P reset=0;
82
        ctrl=11'b11111_000000; #`P;
83
        ctrl=1; #(`P);
84
        check;
85
 
86
        // test add
87
        d0 = {6'b000101, 1002'd0};
88
        d1 = 1006'h1119248464094a51549514585519508512555548915458194454a95a5a6550224816556284a5412965419544014a511556aa55955144aa5699655618601a19691a6691682455451456154a4585906a8615595595560656a15511545a9029959510158140619554a45a96a199aa69010216541569025125a4999591561495;
89
        d2 = 1006'h1a55960985561659551851556895049209954912568a591559455151a6a96614a415025691809658645a12a415a665241565a565896195925a558154045551590a9610255981a119295065a605955445a165985126506828941554156694564a29585611655965010115198aa64986559214641456656425290954464964;
90
        wish = 1006'h28628a81295051aaa9a165a181a25454182a925a2412a52291990aa80112860620285485556514459998a4281621860968100a0a1aa54025248a146064606a861509a151411626214065a0288a65820886822126495682992926a8600681281009611451962289a558a88a5451a68454a568494155865999869225995109;
91
 
92
        @(negedge clk);
93
        reset=1;#`P reset=0;
94
        ctrl=11'b11111_000000; #`P;
95
        ctrl=11'b10001; #(`P);
96
        check;
97
 
98
        // test sub
99
        d0 = {6'b001001, 1002'd0};
100
        d1 = 1006'h1119248464094a51549514585519508512555548915458194454a95a5a6550224816556284a5412965419544014a511556aa55955144aa5699655618601a19691a6691682455451456154a4585906a8615595595560656a15511545a9029959510158140619554a45a96a199aa69010216541569025125a4999591561495;
101
        d2 = 1006'h1a55960985561659551851556895049209954912568a591559455151a6a96614a415025691809658645a12a415a665241565a565896195925a558154045551590a9610255981a119295065a605955445a165985126506828941554156694564a29585611655965010115198aa64986559214641456656425290954464964;
102
        wish = 1006'h0684518aa2a664040289860629445826158018694a9902042a125809a488291a940156182625aa9101268690289428214145a060941615844210958468858810109081469a94940a69851592800a16416424894460a62a85810800456955425a26896a62084822a65981941204204aa94440a155a8288182a09849109a61;
103
 
104
        @(negedge clk);
105
        reset=1;#`P reset=0;
106
        ctrl=11'b11111_000000; #`P;
107
        ctrl=11'b10001; #(`P);
108
        check;
109
 
110
        $display("Good!");
111
        $finish;
112
        end
113
 
114
    initial #100 forever #(`P/2) clk = ~clk;
115
 
116
    task check;
117
        begin
118
          if (out !== wish)
119
            begin $display("E %h %h", out, wish); $finish; end
120
        end
121
    endtask
122
endmodule
123
 

powered by: WebSVN 2.1.0

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