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/] [rtl/] [tiny.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
`define M     503         // M is the degree of the irreducible polynomial
18
`define WIDTH (2*`M-1)    // width for a GF(3^M) element
19
`define WIDTH_D0 (1008-1)
20
 
21
module tiny(clk, reset, sel, addr, w, data, out, done);
22
    input clk, reset;
23
    input sel;
24
    input [5:0] addr;
25
    input w;
26
    input [`WIDTH_D0:0] data;
27
    output [`WIDTH_D0:0] out;
28
    output done;
29
 
30
    /* for FSM */
31
    wire [5:0] fsm_addr;
32
    /* for RAM */
33
    wire [5:0] ram_a_addr, ram_b_addr;
34
    wire [`WIDTH_D0:0] ram_b_data_in;
35
    wire ram_a_w, ram_b_w;
36
    wire [`WIDTH_D0:0] ram_a_data_out, ram_b_data_out;
37
    /* for const */
38
    wire [`WIDTH_D0:0] const0_out, const1_out;
39
    wire const0_effective, const1_effective;
40
    /* for muxer */
41
    wire [`WIDTH_D0:0] muxer0_out, muxer1_out;
42
    /* for ROM */
43
    wire [8:0] rom_addr;
44
    wire [27:0] rom_q;
45
    /* for PE */
46
    wire [10:0] pe_ctrl;
47
 
48
    assign out = ram_a_data_out;
49
 
50
    select
51
        select0 (sel, addr, fsm_addr, w, ram_a_addr, ram_a_w);
52
    rom
53
        rom0 (clk, rom_addr, rom_q);
54
    FSM
55
        fsm0 (clk, reset, rom_addr, rom_q, fsm_addr, ram_b_addr, ram_b_w, pe_ctrl, done);
56
    const_
57
        const0 (clk, ram_a_addr, const0_out, const0_effective),
58
        const1 (clk, ram_b_addr, const1_out, const1_effective);
59
    ram
60
        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);
61
    muxer
62
        muxer0 (ram_a_data_out, const0_out, const0_effective, muxer0_out),
63
        muxer1 (ram_b_data_out, const1_out, const1_effective, muxer1_out);
64
    PE
65
        pe0 (clk, reset, pe_ctrl, muxer1_out, muxer0_out[`WIDTH:0], muxer0_out[`WIDTH:0], ram_b_data_in[`WIDTH:0]);
66
 
67
    assign ram_b_data_in[`WIDTH_D0:`WIDTH+1] = 0;
68
endmodule
69
 
70
module select(sel, addr_in, addr_fsm_in, w_in, addr_out, w_out);
71
    input sel;
72
    input [5:0] addr_in;
73
    input [5:0] addr_fsm_in;
74
    input w_in;
75
    output [5:0] addr_out;
76
    output w_out;
77
 
78
    assign addr_out = sel ? addr_in : addr_fsm_in;
79
    assign w_out = sel & w_in;
80
endmodule
81
 
82
module muxer(from_ram, from_const, const_effective, out);
83
    input [`WIDTH_D0:0] from_ram, from_const;
84
    input const_effective;
85
    output [`WIDTH_D0:0] out;
86
 
87
    assign out = const_effective ? from_const : from_ram;
88
endmodule

powered by: WebSVN 2.1.0

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