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

powered by: WebSVN 2.1.0

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