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

Subversion Repositories nysa_sata

[/] [nysa_sata/] [trunk/] [rtl/] [generic/] [blk_mem.v] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cospan
//library ieee;
2
//use ieee.std_logic_1164.all;
3
//use ieee.std_logic_unsigned.all;
4
 
5
//-----------------------------------------------------
6
// Design Name : ram_dp_sr_sw
7
// File Name   : ram_dp_sr_sw.v
8
// Function    : Synchronous read write RAM
9
// Coder       : Deepak Kumar Tala
10
//-----------------------------------------------------
11
 
12
`timescale 1ns/1ps
13
 
14
module blk_mem #(
15
  parameter DATA_WIDTH    = 8,
16
  parameter ADDRESS_WIDTH = 4
17
)(
18
  input                             clka,
19
  input                             wea,
20
  input   [ADDRESS_WIDTH - 1  :0]   addra,
21
  input   [DATA_WIDTH - 1:0]        dina,
22
  input                             clkb,
23
  input   [ADDRESS_WIDTH - 1:0]     addrb,
24
  output  [DATA_WIDTH - 1:0]        doutb
25
);
26
 
27
//Parameters
28
//Registers/Wires
29
reg [DATA_WIDTH - 1:0] mem [0:2 ** ADDRESS_WIDTH];
30
reg [DATA_WIDTH - 1:0] dout;
31
 
32
//Submodules
33
//Asynchronous Logic
34
assign doutb = dout;
35
 
36
//Synchronous Logic
37
//write only on the A side
38
`ifdef SIMULATION
39
//Only initialize in simulation... somthing gets fucked when you try and do it on an FPGA
40
integer i;
41
initial begin
42
  i = 0;
43
  for (i = 0; i < (2 ** ADDRESS_WIDTH); i = i + 1) begin
44
    mem[i]  <=  0;
45
  end
46
end
47
`endif
48
 
49
always @ (posedge clka)
50
begin
51
  if ( wea ) begin
52
     mem[addra] <= dina;
53
  end
54
end
55
 
56
//read only on the b side
57
always @ (posedge clkb)
58
begin
59
     dout <= mem[addrb];
60
end
61
 
62
 
63
endmodule
64
 

powered by: WebSVN 2.1.0

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