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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [lib/] [fasm/] [fasm_tpsram_rbw.v] - Blame information for rev 195

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 195 sybreon
/* $Id: fasm_tpsram.v,v 1.1 2008/06/05 20:51:56 sybreon Exp $
2
**
3
** FASM MEMORY LIBRARY
4
** Copyright (C) 2004-2009 Shawn Tan <shawn.tan@aeste.net>
5
** All rights reserved.
6
**
7
** FASM is free software: you can redistribute it and/or modify it
8
** under the terms of the GNU Lesser General Public License as
9
** published by the Free Software Foundation, either version 3 of the
10
** License, or (at your option) any later version.
11
**
12
** FASM is distributed in the hope that it will be useful, but WITHOUT
13
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
15
** Public License for more details.
16
**
17
** You should have received a copy of the GNU Lesser General Public
18
** License along with FASM. If not, see <http:**www.gnu.org/licenses/>.
19
*/
20
/*
21
 * TWO PORT SYNCHRONOUS RAM - READ-BEFORE-WRITE
22
 * Synthesis proven on:
23
 * - Xilinx ISE
24
 * - Altera Quartus (>=8.0)
25
 */
26
 
27
module fasm_tpsram_rbw (/*AUTOARG*/
28
   // Outputs
29
   dat_o, xdat_o,
30
   // Inputs
31
   dat_i, adr_i, wre_i, stb_i, rst_i, clk_i, xdat_i, xadr_i, xwre_i,
32
   xstb_i, xrst_i, xclk_i
33
   );
34
 
35
   parameter AW = 8;  ///< address space (2^AW) words
36
   parameter DW = 32; ///< data word width bits
37
 
38
   // wishbone port a
39
   output [DW-1:0] dat_o; // DO
40
   input [DW-1:0]  dat_i; // DI - unused
41
   input [AW-1:0]  adr_i; // A
42
   input           wre_i; // WE - unused
43
   input           stb_i; // CS
44
 
45
   input           rst_i,
46
                   clk_i;
47
 
48
   // wishbone port x
49
   output [DW-1:0] xdat_o; // DO - unused
50
   input [DW-1:0]  xdat_i; // DI
51
   input [AW-1:0]  xadr_i; // A
52
   input           xwre_i; // WE
53
   input           xstb_i; // CS
54
 
55
   input           xrst_i,
56
                   xclk_i;
57
 
58
   // address latch
59
   reg [AW-1:0]    rA, rX;
60
 
61
   // memory block
62
   reg [DW-1:0]    bram [(1<<AW)-1:0];
63
 
64
   always @(posedge xclk_i)
65
     if (xstb_i)
66
       begin
67
          rX <= #1 bram[xadr_i];
68
       end
69
 
70
   always @(posedge clk_i)
71
     if (stb_i)
72
       begin
73
          rA <= #1 bram[adr_i];
74
          if (wre_i) // strobe and write-enable
75
            bram[adr_i] <= #1 dat_i;
76
       end
77
 
78
   assign          xdat_o = rX; // write-thru
79
   assign          dat_o = rA; // write-thru
80
 
81
   // ### SIMULATION ONLY ###
82
   // synopsys translate_off
83
   integer i;
84
   initial begin
85
      for (i=0; i<(1<<AW); i=i+1) begin
86
         bram[i] <= $random;
87
      end
88
   end
89
   // synopsys translate_on
90
 
91
endmodule // fasm_dpsram

powered by: WebSVN 2.1.0

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