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

powered by: WebSVN 2.1.0

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