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/] [ram.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 ram #(
25
    parameter DATA = 1188,
26
    parameter ADDR = 6
27
) (
28
    input                       clk,
29
 
30
    // Port A
31
    input   wire                a_wr,
32
    input   wire    [ADDR-1:0]  a_addr,
33
    input   wire    [DATA-1:0]  a_din,
34
    output  reg     [DATA-1:0]  a_dout,
35
 
36
    // Port B
37
    input   wire                b_wr,
38
    input   wire    [ADDR-1:0]  b_addr,
39
    input   wire    [DATA-1:0]  b_din,
40
    output  reg     [DATA-1:0]  b_dout
41
);
42
 
43
    // Shared memory
44
    reg [DATA-1:0] mem [(2**ADDR)-1:0];
45
 
46
    initial begin : init
47
        integer i;
48
        for(i = 0; i < (2**ADDR); i = i + 1)
49
            mem[i] = 0;
50
    end
51
 
52
    // Port A
53
    always @(posedge clk) begin
54
        a_dout      <= mem[a_addr];
55
        if(a_wr) begin
56
            a_dout      <= a_din;
57
            mem[a_addr] <= a_din;
58
        end
59
    end
60
 
61
    // Port B
62
    always @(posedge clk) begin
63
        b_dout      <= mem[b_addr];
64
        if(b_wr) begin
65
            b_dout      <= b_din;
66
            mem[b_addr] <= b_din;
67
        end
68
    end
69
 
70
endmodule

powered by: WebSVN 2.1.0

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