OpenCores
URL https://opencores.org/ocsvn/xge_mac/xge_mac/trunk

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [generic_mem_medium.v] - Diff between revs 22 and 25

Only display areas with differences | Details | Blame | View Log

Rev 22 Rev 25
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  File name "generic_mem_medium.v"                            ////
////  File name "generic_mem_medium.v"                            ////
////                                                              ////
////                                                              ////
////  This file is part of the "10GE MAC" project                 ////
////  This file is part of the "10GE MAC" project                 ////
////  http://www.opencores.org/cores/xge_mac/                     ////
////  http://www.opencores.org/cores/xge_mac/                     ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - A. Tanguay (antanguay@opencores.org)                  ////
////      - A. Tanguay (antanguay@opencores.org)                  ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
 
 
`include "defines.v"
`include "defines.v"
 
 
/* synthesis ramstyle = "M4K" */
/* synthesis ramstyle = "M4K" */
 
 
module generic_mem_medium(
module generic_mem_medium(
 
 
    wclk,
    wclk,
    wrst_n,
    wrst_n,
    wen,
    wen,
    waddr,
    waddr,
    wdata,
    wdata,
 
 
    rclk,
    rclk,
    rrst_n,
    rrst_n,
    ren,
    ren,
    roen,
    roen,
    raddr,
    raddr,
    rdata
    rdata
);
);
 
 
//---
//---
// Parameters
// Parameters
 
 
parameter DWIDTH = 32;
parameter DWIDTH = 32;
parameter AWIDTH = 3;
parameter AWIDTH = 3;
parameter RAM_DEPTH = (1 << AWIDTH);
parameter RAM_DEPTH = (1 << AWIDTH);
parameter REGISTER_READ = 0;
parameter REGISTER_READ = 0;
 
 
//---
//---
// Ports
// Ports
 
 
input               wclk;
input               wclk;
input               wrst_n;
input               wrst_n;
input               wen;
input               wen;
input  [AWIDTH-1:0] waddr;
input  [AWIDTH-1:0] waddr;
input  [DWIDTH-1:0] wdata;
input  [DWIDTH-1:0] wdata;
 
 
input               rclk;
input               rclk;
input               rrst_n;
input               rrst_n;
input               ren;
input               ren;
input               roen;
input               roen;
input  [AWIDTH-1:0] raddr;
input  [AWIDTH-1:0] raddr;
output [DWIDTH-1:0] rdata;
output [DWIDTH-1:0] rdata;
 
 
// Registered outputs
// Registered outputs
reg    [DWIDTH-1:0] rdata;
reg    [DWIDTH-1:0] rdata;
 
 
 
 
//---
//---
// Local declarations
// Local declarations
 
 
// Registers
// Registers
 
 
reg  [DWIDTH-1:0] mem_rdata;
reg  [DWIDTH-1:0] mem_rdata;
reg  [AWIDTH-1:0] raddr_d1;
reg  [AWIDTH-1:0] raddr_d1;
 
 
// Memory
// Memory
 
 
reg  [DWIDTH-1:0] mem [0:RAM_DEPTH-1];
reg  [DWIDTH-1:0] mem [0:RAM_DEPTH-1];
 
 
// Variables
// Variables
 
 
integer         i;
integer         i;
 
 
 
 
//---
//---
// Memory Write
// Memory Write
 
 
// Generate synchronous write
// Generate synchronous write
always @(posedge wclk)
always @(posedge wclk)
begin
begin
    if (wen) begin
    if (wen) begin
        mem[waddr[AWIDTH-1:0]] <= wdata;
        mem[waddr[AWIDTH-1:0]] <= wdata;
    end
    end
end
end
 
 
//---
//---
// Memory Read
// Memory Read
 
 
// Generate registered memory read
// Generate registered memory read
 
 
`ifdef XIL
`ifdef XIL
 
 
//always @(posedge rclk)
//always @(posedge rclk)
//begin
//begin
//    if (ren) begin
//    if (ren) begin
//        raddr_d1 <= raddr;
//        raddr_d1 <= raddr;
//    end
//    end
//end
//end
//always @(raddr_d1, rclk)
//always @(raddr_d1, rclk)
//begin
//begin
//    mem_rdata = mem[raddr_d1[AWIDTH-1:0]];
//    mem_rdata = mem[raddr_d1[AWIDTH-1:0]];
//end
//end
 
 
always @(posedge rclk)
always @(posedge rclk)
begin
begin
    if (!rrst_n) begin
    if (!rrst_n) begin
        mem_rdata <= {(DWIDTH){1'b0}};
        mem_rdata <= {(DWIDTH){1'b0}};
    end else if (ren) begin
    end else if (ren) begin
        mem_rdata <= mem[raddr[AWIDTH-1:0]];
        mem_rdata <= mem[raddr[AWIDTH-1:0]];
    end
    end
end
end
 
 
`else
`else
 
 
always @(posedge rclk or negedge rrst_n)
//always @(posedge rclk or negedge rrst_n)
 
//begin
 
//    if (!rrst_n) begin
 
//        mem_rdata <= {(DWIDTH){1'b0}};
 
//    end else if (ren) begin
 
//        mem_rdata <= mem[raddr[AWIDTH-1:0]];
 
//    end
 
//end
 
 
 
always @(posedge rclk)
begin
begin
    if (!rrst_n) begin
    if (ren) begin
        mem_rdata <= {(DWIDTH){1'b0}};
        raddr_d1 <= raddr;
    end else if (ren) begin
    end
        mem_rdata <= mem[raddr[AWIDTH-1:0]];
 
    end
    end
 
always @(raddr_d1, rclk)
 
begin
 
    mem_rdata = mem[raddr_d1[AWIDTH-1:0]];
end
end
 
 
`endif
`endif
 
 
generate
generate
    if (REGISTER_READ) begin
    if (REGISTER_READ) begin
 
 
        // Generate registered output
        // Generate registered output
        always @(posedge rclk or negedge rrst_n)
        always @(posedge rclk or negedge rrst_n)
        begin
        begin
            if (!rrst_n) begin
            if (!rrst_n) begin
                rdata <= {(DWIDTH){1'b0}};
                rdata <= {(DWIDTH){1'b0}};
            end else if (roen) begin
            end else if (roen) begin
                rdata <= mem_rdata;
                rdata <= mem_rdata;
            end
            end
        end
        end
 
 
    end
    end
    else begin
    else begin
 
 
        // Generate unregisters output
        // Generate unregisters output
        always @(mem_rdata)
        always @(mem_rdata)
        begin
        begin
            rdata = mem_rdata;
            rdata = mem_rdata;
        end
        end
 
 
    end
    end
endgenerate
endgenerate
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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