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

Subversion Repositories openmsp430

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

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: 17 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2009-08-04 23:15:39 +0200 (Tue, 04 Aug 2009) $
37
//----------------------------------------------------------------------------
38 2 olivier.gi
`timescale 1ns / 100ps
39
 
40
module ram (
41
 
42
// OUTPUTs
43
    ram_dout,                      // RAM data output
44
 
45
// INPUTs
46
    ram_addr,                      // RAM address
47
    ram_cen,                       // RAM chip enable (low active)
48
    ram_clk,                       // RAM clock
49
    ram_din,                       // RAM data input
50
    ram_wen                        // RAM write enable (low active)
51
);
52
 
53
// PARAMETERs
54
//============
55
parameter ADDR_MSB   =  6;
56
 
57
// OUTPUTs
58
//============
59
output      [15:0] ram_dout;       // RAM data output
60
 
61
// INPUTs
62
//============
63
input [ADDR_MSB:0] ram_addr;       // RAM address
64
input              ram_cen;        // RAM chip enable (low active)
65
input              ram_clk;        // RAM clock
66
input       [15:0] ram_din;        // RAM data input
67
input        [1:0] ram_wen;        // RAM write enable (low active)
68
 
69
 
70
// RAM
71
//============
72
 
73
reg         [15:0] mem [(1<<(ADDR_MSB+1))-1:0];
74
reg   [ADDR_MSB:0] ram_addr_reg;
75
 
76
wire        [15:0] mem_val = mem[ram_addr];
77
 
78
always @(posedge ram_clk)
79
  if (~ram_cen)
80
    begin
81
      if      (ram_wen==2'b00) mem[ram_addr] <= ram_din;
82
      else if (ram_wen==2'b01) mem[ram_addr] <= {ram_din[15:8], mem_val[7:0]};
83
      else if (ram_wen==2'b10) mem[ram_addr] <= {mem_val[15:8], ram_din[7:0]};
84
      ram_addr_reg <= ram_addr;
85
    end
86
 
87
assign ram_dout = mem[ram_addr_reg];
88
 
89
 
90
endmodule // ram

powered by: WebSVN 2.1.0

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