OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_peripheral/] [ethmac/] [eth_generic_ram.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
 
2
/****************
3
*simple_dual_port_ram
4
*
5
*****************/
6
 
7
// synthesis translate_off
8
`timescale 1ns / 1ps
9
// synthesis translate_on
10
 
11
 
12
 
13
// Quartus II Verilog Template
14
// Simple Dual Port RAM with separate read/write addresses and
15
// single read/write clock
16
 
17
module eth_simple_dual_port_ram #(
18
        parameter Dw=8,
19
        parameter Aw=6
20
)
21
(
22
        data,
23
        read_addr,
24
        write_addr,
25
        we,
26
        clk,
27
        q
28
);
29
 
30
        input   [Dw-1   :0] data;
31
        input   [Aw-1   :0] read_addr;
32
        input   [Aw-1   :0] write_addr;
33
        input we;
34
        input clk;
35
        output reg [Dw-1        :0] q;
36
 
37
 
38
        // Declare the RAM variable
39
        reg [Dw-1:0] ram [2**Aw-1:0];
40
 
41
        always @ (posedge clk)
42
        begin
43
                // Write
44
                if (we)
45
                        ram[write_addr] <= data;
46
 
47
                // Read (if read_addr == write_addr, return OLD data).  To return
48
                // NEW data, use = (blocking write) rather than <= (non-blocking write)
49
                // in the write assignment.      NOTE: NEW data may require extra bypass
50
                // logic around the RAM.
51
                q <= ram[read_addr];
52
        end
53
 
54
endmodule
55
 
56
 
57
 
58
 
59
 
60
 
61
 
62
 
63
/*****************************
64
 
65
        single_port_ram
66
 
67
 
68
*****************************/
69
 
70
// Quartus II Verilog Template
71
// Single port RAM with single read/write address 
72
 
73
module eth_single_port_ram #(
74
    parameter Dw=8,
75
    parameter Aw=6
76
)
77
(
78
    data,
79
    addr,
80
    we,
81
    clk,
82
    q
83
);
84
 
85
    input [(Dw-1):0] data;
86
    input [(Aw-1):0] addr;
87
    input we, clk;
88
    output [(Dw-1):0] q;
89
 
90
    // Declare the RAM variable
91
    reg [Dw-1:0] ram[2**Aw-1:0];
92
 
93
    // Variable to hold the registered read address
94
    reg [Aw-1:0] addr_reg;
95
 
96
    always @ (posedge clk)
97
    begin
98
        // Write
99
        if (we)
100
            ram[addr] <= data;
101
            addr_reg <= addr;
102
    end
103
 
104
    // Continuous assignment implies read returns NEW data.
105
    // This is the natural behavior of the TriMatrix memory
106
    // blocks in Single Port mode.  
107
    assign q = ram[addr_reg];
108
 
109
endmodule

powered by: WebSVN 2.1.0

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