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/] [rtl/] [tiny.v] - Blame information for rev 15

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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