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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [cde/] [ip/] [sram/] [rtl/] [verilog/] [sram_byte] - Diff between revs 134 and 135

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

Rev 134 Rev 135
// Memory Array
// Memory Array
reg [7:0] mem[0:WORDS-1];
reg [7:0] mem [0:WORDS-1];
initial
initial
  begin
  begin
  $display("SRAM byte %m.mem");
  $display("SRAM byte %m.mem");
  $display("  AddrBits=%d DataBits = 8  Words = %d  ",ADDR,WORDS);
  $display("  AddrBits=%d DataBits = 8  Words = %d  ",ADDR,WORDS);
  end
  end
// Write function
// Write function
always@(posedge clk)
always@(posedge clk)
        if( wr && cs && be ) mem[addr[ADDR-1:0]] <= wdata[7:0];
        if( wr && cs && be ) mem[addr[ADDR-1:0]] <= wdata[7:0];
generate
generate
if( WRITETHRU)
if( WRITETHRU)
  begin
  begin
  // Read function gets new data if also a write cycle
  // Read function gets new data if also a write cycle
  // latch the read addr for next cycle
  // latch the read addr for next cycle
  reg   [ADDR-1:0]          l_raddr;
  reg   [ADDR-1:0]          l_raddr;
  reg                       l_cycle;
  reg                       l_cycle;
  always@(posedge clk)
  always@(posedge clk)
    begin
    begin
       l_raddr    <=  addr;
       l_raddr    <=  addr;
       l_cycle    <=  rd && cs ;
       l_cycle    <=  rd && cs ;
    end
    end
  // Read into a wire and then pass to rdata because some synth tools can't handle a memory in a always block
  // Read into a wire and then pass to rdata because some synth tools can't handle a memory in a always block
  wire  [7:0] tmp_rdata;
  wire  [7:0] tmp_rdata;
  assign         tmp_rdata  =      (l_cycle )?mem[{l_raddr[ADDR-1:0]}]:8'hff;
  assign         tmp_rdata  =      (l_cycle )?mem[{l_raddr[ADDR-1:0]}]:8'hff;
  always@(*)         rdata  =      tmp_rdata;
  always@(*)         rdata  =      tmp_rdata;
  end
  end
else
else
  begin
  begin
  // Read function gets old data if also a write cycle
  // Read function gets old data if also a write cycle
  always@(posedge clk)
  always@(posedge clk)
        if( rd && cs ) rdata             <= mem[{addr[ADDR-1:0]}];
        if( rd && cs ) rdata             <= mem[{addr[ADDR-1:0]}];
        else           rdata             <= 8'hff;
        else           rdata             <= 8'hff;
  end
  end
endgenerate
endgenerate
 
 

powered by: WebSVN 2.1.0

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