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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 homer.hsin
`timescale 1ns / 1ps
2
`define P 20
3
 
4
`define M     593         // M is the degree of the irreducible polynomial
5
`define WIDTH (2*`M-1)    // width for a GF(3^M) element
6
`define WIDTH_D0 1187
7
 
8
module test_pe;
9
 
10
        // Inputs
11
        reg clk;
12
        reg reset;
13
        reg [10:0] ctrl;
14
        reg [`WIDTH_D0:0] d0;
15
        reg [`WIDTH:0] d1;
16
        reg [`WIDTH:0] d2;
17
    reg [`WIDTH:0] wish;
18
 
19
        // Outputs
20
        wire [`WIDTH:0] out;
21
 
22
        // Instantiate the Unit Under Test (UUT)
23
        PE uut (
24
                .clk(clk),
25
                .reset(reset),
26
                .ctrl(ctrl),
27
                .d0(d0),
28
                .d1(d1),
29
        .d2(d2),
30
                .out(out)
31
        );
32
 
33
        initial begin
34
                // Initialize Inputs
35
                clk = 0;
36
                reset = 0;
37
                ctrl = 0;
38
                d0 = 0;
39
                d1 = 0;
40
        d2 = 0;
41
 
42
                // Wait 100 ns for global reset to finish
43
                #100;
44
 
45
                // Add stimulus here
46
        // test mult
47
        d0 = 1186'h245958540550916859984664a9559916599551944415826a8429555562950a5555a9661855015655694448585615852515916545158595955690a96a566591598660556a61880a410615585525454612010662a4a9116906410014611105015955161455804415166155815941116592650115564164556112804292528419450a45840158a926588250411118055565654556964;
48
        d1 = 1186'h212291922556595445146a555159a2414515699455212899424869242411a459a6a96954461552562556a11694912451a058440646451050819559181a546891566865542169546869551654262068564119555949915194580525869959a159444051555a01a11509919294620158600555158520569556a514684225201a255a586294585262195922250514115a05542946299;
49
        d2 = d1;
50
        wish = 1186'h21a0004a5961412a2068488080020408114aa1aa6296a615418a9a22220948905a4a119849a541100016a14141625a21a906a05024001559086584205a1241804215518688468146052485a40581824a1146915164288a904150960222022aa49555608086151504905a68065906122568a2188a22aa09004451464946201a689926105411588591198551a1085145a6846196910;
51
 
52
        @(negedge clk);
53
        reset=1;#`P reset=0;
54
        ctrl=11'b11111_000000; #`P;
55
        ctrl=11'b00000_111111; #(198*`P);
56
        check;
57
 
58
        // test cubic
59
        d0 = {6'b10101, 1182'd0};
60
        d1 = 1186'h198565655595622106a15596a98a5186101959554541466581244585515555665552584505511552650944484555052655692189595619806549462551a56051552069242a6555542014551599866559955466a604511499554654119144668125851211419566a645856592a55865458582952556a916189591194655519664218a5a9a64990415a516a5169865415a912605951;
61
        d2 = d1;
62
        wish = 1186'h01a1425a929600890401891a44129844120112246215a566842954a605aaa8aa08588091659481a062a8519a868aa1548569a18a642222490a80aa8026a22501a8492a10555158491155025a84686680984852046a88a1008249008541a550556181952208252029264a0a4151045415450886854129a9658608684901089910281a22a46262a18108451120145a2625904921a96;
63
 
64
        @(negedge clk);
65
        reset=1;#`P reset=0;
66
        ctrl=11'b11111_000000; #`P;
67
        ctrl=1; #(`P);
68
        check;
69
 
70
        // test add
71
        d0 = {6'b000101, 1182'd0};
72
        d1 = 1186'h00a6540512a166a914956a65149495511551891946505601545514458a955815a5596918a2195a565906902549a4954419294a5045199954951561555804612a6655256899454941a51a590259466611545a628496596845046015584a4455a5aa69858911112a9666549561252a156559564966195415951a41226620598145a0441915951185246145aa55615556585564965a5;
73
        d2 = 1186'h219146612691209655566446a585291504580155555689915a555564404562896415518a65915062459564695665590a11465845a6659441a515a50a656a0a809016195545425645a509895161841616a665599585a0115416a8952185954555564146a56025559466a85a098a68584564969965441822018992901511a954664a90555414555114149641a811854525452a65612;
74
        wish = 1186'h21449a6605425640692892a88959826619a98a6298a61092a2aa69a90a1a8a9219628a9614aaaa8592980452901922422a609695284261954a2a1650816268aa06680281128490865a1416508a0a49240a808859580949991a18aa4900199a0a01aa08624106406a9900206aa05661aa812916985160049694108248010615a82a146269a966160845182801421a98419a5208884;
75
 
76
        @(negedge clk);
77
        reset=1;#`P reset=0;
78
        ctrl=11'b11111_000000; #`P;
79
        ctrl=11'b10001; #(`P);
80
        check;
81
 
82
        // test sub
83
        d0 = {6'b001001, 1182'd0};
84
        d1 = 1186'h00a6540512a166a914956a65149495511551891946505601545514458a955815a5596918a2195a565906902549a4954419294a5045199954951561555804612a6655256899454941a51a590259466611545a628496596845046015584a4455a5aa69858911112a9666549561252a156559564966195415951a41226620598145a0441915951185246145aa55615556585564965a5;
85
        d2 = 1186'h219146612691209655566446a585291504580155555689915a555564404562896415518a65915062459564695665590a11465845a6659441a515a50a656a0a809016195545425645a509895161841616a665599585a0115416a8952185954555564146a56025559466a85a098a68584564969965441822018992901511a954664a90555414555114149641a811854525452a65612;
86
        wish = 1186'h1215119428104616824206226212a8481105888421099960090082114a5029584144185149480a24146168882642484908a6221a92a405162000885a2699666a9642181654062608001190a12882500aa125152211a95a212184406a85a2105054284214a128950200a84a646a8289202580a0019548269451a2525112a0691265a484818188641059a269a950901166104961296;
87
 
88
        @(negedge clk);
89
        reset=1;#`P reset=0;
90
        ctrl=11'b11111_000000; #`P;
91
        ctrl=11'b10001; #(`P);
92
        check;
93
 
94
        $display("Good!");
95
        $finish;
96
        end
97
 
98
    initial #100 forever #(`P/2) clk = ~clk;
99
 
100
    task check;
101
        begin
102
          if (out !== wish)
103
            begin $display("E %h %h", out, wish); $finish; end
104
        end
105
    endtask
106
endmodule
107
 

powered by: WebSVN 2.1.0

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