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-3.1/] [rtl/] [verilog/] [mor1kx_simple_dpram_sclk.v] - Blame information for rev 38

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 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 ENABLE_BYPASS = 1
20
    )
21
   (
22
    input                   clk,
23
    input [ADDR_WIDTH-1:0]  raddr,
24
    input                   re,
25
    input [ADDR_WIDTH-1:0]  waddr,
26
    input                   we,
27
    input [DATA_WIDTH-1:0]  din,
28
    output [DATA_WIDTH-1:0] dout
29
    );
30
 
31
   reg [DATA_WIDTH-1:0]     mem[(1<<ADDR_WIDTH)-1:0];
32
   reg [DATA_WIDTH-1:0]     rdata;
33
 
34
generate
35
if (ENABLE_BYPASS) begin : bypass_gen
36
   reg [DATA_WIDTH-1:0]     din_r;
37
   reg                      bypass;
38
 
39
   assign dout = bypass ? din_r : rdata;
40
 
41
   always @(posedge clk)
42
     if (re)
43
       din_r <= din;
44
 
45
   always @(posedge clk)
46
     if (waddr == raddr && we && re)
47
       bypass <= 1;
48
     else if (re)
49
       bypass <= 0;
50
end else begin
51
   assign dout = rdata;
52
end
53
endgenerate
54
 
55
   always @(posedge clk) begin
56
      if (we)
57
        mem[waddr] <= din;
58
      if (re)
59
        rdata <= mem[raddr];
60
   end
61
 
62
endmodule

powered by: WebSVN 2.1.0

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