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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [bench/] [verilog/] [ram.v] - Blame information for rev 73

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

Line No. Rev Author Line
1 2 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2001 Authors
3
//
4
// This source file may be used and distributed without restriction provided
5
// that this copyright statement is not removed from the file and that any
6
// derivative work contains the original copyright notice and the associated
7
// disclaimer.
8
//
9
// This source file is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation; either version 2.1 of the License, or
12
// (at your option) any later version.
13
//
14
// This source is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
// License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public License
20
// along with this source; if not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
//
23
//----------------------------------------------------------------------------
24
// 
25
// *File Name: ram.v
26
// 
27
// *Module Description:
28
//                      Scalable RAM model
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34 17 olivier.gi
// $Rev: 72 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2010-08-01 20:54:37 +0200 (Sun, 01 Aug 2010) $
37
//----------------------------------------------------------------------------
38 23 olivier.gi
`include "timescale.v"
39
`include "openMSP430_defines.v"
40 2 olivier.gi
 
41
module ram (
42
 
43
// OUTPUTs
44
    ram_dout,                      // RAM data output
45
 
46
// INPUTs
47
    ram_addr,                      // RAM address
48
    ram_cen,                       // RAM chip enable (low active)
49
    ram_clk,                       // RAM clock
50
    ram_din,                       // RAM data input
51
    ram_wen                        // RAM write enable (low active)
52
);
53
 
54
// PARAMETERs
55
//============
56 72 olivier.gi
parameter ADDR_MSB   =  6;         // MSB of the address bus
57
parameter MEM_SIZE   =  256;       // Memory size in bytes
58 2 olivier.gi
 
59
// OUTPUTs
60
//============
61
output      [15:0] ram_dout;       // RAM data output
62
 
63
// INPUTs
64
//============
65
input [ADDR_MSB:0] ram_addr;       // RAM address
66
input              ram_cen;        // RAM chip enable (low active)
67
input              ram_clk;        // RAM clock
68
input       [15:0] ram_din;        // RAM data input
69
input        [1:0] ram_wen;        // RAM write enable (low active)
70
 
71
 
72
// RAM
73
//============
74
 
75 72 olivier.gi
reg         [15:0] mem [(MEM_SIZE/2)-1:0];
76 2 olivier.gi
reg   [ADDR_MSB:0] ram_addr_reg;
77
 
78
wire        [15:0] mem_val = mem[ram_addr];
79 72 olivier.gi
 
80
 
81 2 olivier.gi
always @(posedge ram_clk)
82 72 olivier.gi
  if (~ram_cen & ram_addr<(MEM_SIZE/2))
83 2 olivier.gi
    begin
84
      if      (ram_wen==2'b00) mem[ram_addr] <= ram_din;
85
      else if (ram_wen==2'b01) mem[ram_addr] <= {ram_din[15:8], mem_val[7:0]};
86
      else if (ram_wen==2'b10) mem[ram_addr] <= {mem_val[15:8], ram_din[7:0]};
87
      ram_addr_reg <= ram_addr;
88
    end
89
 
90
assign ram_dout = mem[ram_addr_reg];
91
 
92
 
93
endmodule // ram

powered by: WebSVN 2.1.0

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