URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [common/] [opencores.org/] [cde/] [ip/] [sram/] [rtl/] [verilog/] [sram_dp] - Rev 135
Compare with Previous | Blame | View Log
// Memory Arrayreg [WIDTH-1:0] mem [0:WORDS-1];// If used as Rom then load a memory image at startupinitialbegin$display("SRAM dp %m.mem");$display(" AddrBits=%d DataBits = %d Words = %d ",ADDR,WIDTH,WORDS);end// Write functionalways@(posedge clk)if( wr && cs ) mem[waddr[ADDR-1:0]] <= wdata[WIDTH-1:0];reg [ADDR-1:0] l_raddr;reg l_cycle;always@(posedge clk)beginl_raddr <= raddr;l_cycle <= rd && cs ;endgenerateif( WRITETHRU)begin// Read function gets new data if also a write cycle// latch the read addr for next cycle// Read into a wire and then pass to rdata because some synth tools can't handle a memory in a always blockwire [WIDTH-1:0] tmp_rdata;assign tmp_rdata = (l_cycle )?mem[{l_raddr[ADDR-1:0]}]:{WIDTH{1'b1}};always@(*) rdata = tmp_rdata;endelsebegin// Read function gets old data if also a write cyclealways@(posedge clk)if( rd && cs ) rdata <= mem[{raddr[ADDR-1:0]}];else rdata <= {WIDTH{1'b1}};endendgenerate
