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/] [src_processor/] [mor1kx-5.0/] [rtl/] [verilog/] [mor1kx_simple_dpram_sclk.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
/******************************************************************************
2
 This Source Code Form is subject to the terms of the
3
 Open Hardware Description License, v. 1.0. If a copy
4
 of the OHDL was not distributed with this file, You
5
 can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt
6
 
7
 Description:
8
 Simple single clocked dual port ram (separate read and write ports),
9
 with optional bypass logic.
10
 
11
 Copyright (C) 2012 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
12
 
13
 ******************************************************************************/
14
 
15
module mor1kx_simple_dpram_sclk
16
  #(
17
    parameter ADDR_WIDTH = 32,
18
    parameter DATA_WIDTH = 32,
19
    parameter CLEAR_ON_INIT = 0,
20
    parameter ENABLE_BYPASS = 1
21
    )
22
   (
23
    input                   clk,
24
    input [ADDR_WIDTH-1:0]  raddr,
25
    input                   re,
26
    input [ADDR_WIDTH-1:0]  waddr,
27
    input                   we,
28
    input [DATA_WIDTH-1:0]  din,
29
    output [DATA_WIDTH-1:0] dout
30
    );
31
 
32
   reg [DATA_WIDTH-1:0]     mem[(1<<ADDR_WIDTH)-1:0];
33
   reg [DATA_WIDTH-1:0]     rdata;
34
 
35
generate
36
if(CLEAR_ON_INIT) begin :clear_on_init
37
   integer                  idx;
38
   initial
39
     for(idx=0; idx < (1<<ADDR_WIDTH); idx=idx+1)
40
       mem[idx] = {DATA_WIDTH{1'b0}};
41
end
42
endgenerate
43
 
44
generate
45
if (ENABLE_BYPASS) begin : bypass_gen
46
   reg [DATA_WIDTH-1:0]     din_r;
47
   reg                      bypass;
48
 
49
   assign dout = bypass ? din_r : rdata;
50
 
51
   always @(posedge clk)
52
     if (re)
53
       din_r <= din;
54
 
55
   always @(posedge clk)
56
     if (waddr == raddr && we && re)
57
       bypass <= 1;
58
     else if (re)
59
       bypass <= 0;
60
end else begin
61
   assign dout = rdata;
62
end
63
endgenerate
64
 
65
   always @(posedge clk) begin
66
      if (we)
67
        mem[waddr] <= din;
68
      if (re)
69
        rdata <= mem[raddr];
70
   end
71
 
72
endmodule

powered by: WebSVN 2.1.0

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