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 42

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 42 alirezamon
`timescale       1ns/1ps
15 38 alirezamon
 
16
module mor1kx_simple_dpram_sclk
17
  #(
18
    parameter ADDR_WIDTH = 32,
19
    parameter DATA_WIDTH = 32,
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 (ENABLE_BYPASS) begin : bypass_gen
37
   reg [DATA_WIDTH-1:0]     din_r;
38
   reg                      bypass;
39
 
40
   assign dout = bypass ? din_r : rdata;
41
 
42
   always @(posedge clk)
43
     if (re)
44
       din_r <= din;
45
 
46
   always @(posedge clk)
47
     if (waddr == raddr && we && re)
48
       bypass <= 1;
49
     else if (re)
50
       bypass <= 0;
51
end else begin
52
   assign dout = rdata;
53
end
54
endgenerate
55
 
56
   always @(posedge clk) begin
57
      if (we)
58
        mem[waddr] <= din;
59
      if (re)
60
        rdata <= mem[raddr];
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.