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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [versatile_library.v] - Diff between revs 145 and 146

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 145 Rev 146
Line 4995... Line 4995...
 
 
`ifdef REG_FILE
`ifdef REG_FILE
`define MODULE reg_file
`define MODULE reg_file
module `BASE`MODULE (
module `BASE`MODULE (
`undef MODULE
`undef MODULE
    a1, a2, a3, wd3, we3, rd1, rd2, clk
    a1, a2, a3, wd3, we3, rd1, rd2, clk, rst );
);
parameter dw = 32;
parameter data_width = 32;
parameter aw = 5;
parameter addr_width = 5;
 
parameter debug = 0;
parameter debug = 0;
input [addr_width-1:0] a1, a2, a3;
input [aw-1:0] a1, a2, a3;
input [data_width-1:0] wd3;
input [dw-1:0] wd3;
input we3;
input we3;
output [data_width-1:0] rd1, rd2;
output [dw-1:0] rd1, rd2;
input clk;
input clk;
 
wire [dw-1:0] rd1mem, rd2mem;
 
reg [dw-1:0] wreg;
 
reg sel1, sel2;
 
 
generate
generate
if (debug==1) begin : debug_we
if (debug==1) begin : debug_we
    always @ (posedge clk)
    always @ (posedge clk)
        if (we3)
        if (we3)
            $display ("Value %h written at register %h : time %t", wd3, a3, $time);
            $display ("Value %h written at register %h : time %t", wd3, a3, $time);
end
end
endgenerate
endgenerate
 
 
`ifdef ACTEL
 
reg [data_width-1:0] wd3_reg;
 
reg [addr_width-1:0] a1_reg, a2_reg, a3_reg;
 
reg we3_reg;
 
reg [data_width-1:0] ram1 [(1<<addr_width)-1:0] `SYN_NO_RW_CHECK;
 
reg [data_width-1:0] ram2 [(1<<addr_width)-1:0] `SYN_NO_RW_CHECK;
 
always @ (posedge clk or posedge rst)
 
if (rst)
 
    {wd3_reg, a3_reg, we3_reg} <= {(data_width+addr_width+1){1'b0}};
 
else
 
    {wd3_reg, a3_reg, we3_reg} <= {wd3,a3,wd3};
 
 
 
    always @ (negedge clk)
 
    if (we3_reg)
 
        ram1[a3_reg] <= wd3;
 
    always @ (posedge clk)
 
        a1_reg <= a1;
 
    assign rd1 = ram1[a1_reg];
 
 
 
    always @ (negedge clk)
 
    if (we3_reg)
 
        ram2[a3_reg] <= wd3;
 
    always @ (posedge clk)
 
        a2_reg <= a2;
 
    assign rd2 = ram2[a2_reg];
 
 
 
`else
 
 
 
`define MODULE dpram_1r1w
`define MODULE dpram_1r1w
`BASE`MODULE
`BASE`MODULE
    # ( .data_width(data_width), .addr_width(addr_width))
    # ( .data_width(dw), .addr_width(aw))
    ram1 (
    ram1 (
        .d_a(wd3),
        .d_a(wd3),
        .adr_a(a3),
        .adr_a(a3),
        .we_a(we3),
        .we_a(we3),
        .clk_a(clk),
        .clk_a(clk),
        .q_b(rd1),
        .q_b(rd1mem),
        .adr_b(a1),
        .adr_b(a1),
        .clk_b(clk) );
        .clk_b(clk) );
 
 
`BASE`MODULE
`BASE`MODULE
    # ( .data_width(data_width), .addr_width(addr_width))
    # ( .data_width(dw), .addr_width(aw))
    ram2 (
    ram2 (
        .d_a(wd3),
        .d_a(wd3),
        .adr_a(a3),
        .adr_a(a3),
        .we_a(we3),
        .we_a(we3),
        .clk_a(clk),
        .clk_a(clk),
        .q_b(rd2),
        .q_b(rd2mem),
        .adr_b(a2),
        .adr_b(a2),
        .clk_b(clk) );
        .clk_b(clk) );
`undef MODULE
`undef MODULE
 
 
`endif
always @ (posedge clk or posedge rst)
 
if (rst)
 
    {sel1, sel2, wreg} <= {1'b0,1'b0,{data_width{1'b0}}};
 
else
 
    {sel1,sel2,wreg} <= {we3 & a1==a3, we3 & a2==a3,wd3};
 
assign rd1 = (sel1) ? wreg : rd1mem;
 
assign rd2 = (sel2) ? wreg : rd2mem;
 
 
endmodule
endmodule
`endif
`endif
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////

powered by: WebSVN 2.1.0

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