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/] [rtl/] [tiny.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
/*
2
    Copyright 2012 Homer Hsing
3
 
4
    This file is part of Tiny Tate Bilinear Pairing Core.
5
 
6
    Tiny Tate Bilinear Pairing Core is free software: you can redistribute it and/or modify
7
    it under the terms of the GNU Lesser General Public License as published by
8
    the Free Software Foundation, either version 3 of the License, or
9
    (at your option) any later version.
10
 
11
    Tiny Tate Bilinear Pairing Core is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU Lesser General Public License for more details.
15
 
16
    You should have received a copy of the GNU Lesser General Public License
17
    along with Tiny Tate Bilinear Pairing Core.  If not, see http://www.gnu.org/licenses/lgpl.txt
18
*/
19
 
20
`define M     593         // 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 1187
23
 
24
module tiny(clk, reset, sel, addr, w, data, out, done);
25
    input clk, reset;
26
    input sel;
27
    input [5:0] addr;
28
    input w;
29
    input [`WIDTH_D0:0] data;
30
    output [`WIDTH_D0:0] out;
31
    output done;
32
 
33
    /* for FSM */
34
    wire [5:0] fsm_addr;
35
    /* for RAM */
36
    wire [5:0] ram_a_addr, ram_b_addr;
37
    wire [`WIDTH_D0:0] ram_b_data_in;
38
    wire ram_a_w, ram_b_w;
39
    wire [`WIDTH_D0:0] ram_a_data_out, ram_b_data_out;
40
    /* for const */
41
    wire [`WIDTH_D0:0] const0_out, const1_out;
42
    wire const0_effective, const1_effective;
43
    /* for muxer */
44
    wire [`WIDTH_D0:0] muxer0_out, muxer1_out;
45
    /* for ROM */
46
    wire [8:0] rom_addr;
47
    wire [28:0] rom_q;
48
    /* for PE */
49
    wire [10:0] pe_ctrl;
50
 
51
    assign out = ram_a_data_out;
52
 
53
    select
54
        select0 (sel, addr, fsm_addr, w, ram_a_addr, ram_a_w);
55
    rom
56
        rom0 (clk, rom_addr, rom_q);
57
    FSM
58
        fsm0 (clk, reset, rom_addr, rom_q, fsm_addr, ram_b_addr, ram_b_w, pe_ctrl, done);
59
    const_
60
        const0 (clk, ram_a_addr, const0_out, const0_effective),
61
        const1 (clk, ram_b_addr, const1_out, const1_effective);
62
    ram
63
        ram0 (clk, ram_a_w, ram_a_addr, data, ram_a_data_out, ram_b_w, ram_b_addr[5:0], ram_b_data_in, ram_b_data_out);
64
    muxer
65
        muxer0 (ram_a_data_out, const0_out, const0_effective, muxer0_out),
66
        muxer1 (ram_b_data_out, const1_out, const1_effective, muxer1_out);
67
    PE
68
        pe0 (clk, reset, pe_ctrl, muxer1_out, muxer0_out[`WIDTH:0], muxer0_out[`WIDTH:0], ram_b_data_in[`WIDTH:0]);
69
 
70
    assign ram_b_data_in[`WIDTH_D0:`WIDTH+1] = 0;
71
endmodule
72
 
73
module select(sel, addr_in, addr_fsm_in, w_in, addr_out, w_out);
74
    input sel;
75
    input [5:0] addr_in;
76
    input [5:0] addr_fsm_in;
77
    input w_in;
78
    output [5:0] addr_out;
79
    output w_out;
80
 
81
    assign addr_out = sel ? addr_in : addr_fsm_in;
82
    assign w_out = sel & w_in;
83
endmodule
84
 
85
module muxer(from_ram, from_const, const_effective, out);
86
    input [`WIDTH_D0:0] from_ram, from_const;
87
    input const_effective;
88
    output [`WIDTH_D0:0] out;
89
 
90
    assign out = const_effective ? from_const : from_ram;
91
endmodule

powered by: WebSVN 2.1.0

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