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

Subversion Repositories or1k

[/] [or1k/] [tags/] [arelease/] [rc203soc/] [bench/] [models/] [zbtram.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1327 jcastillo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ZBT RAM Model                                               ////
4
////                                                              ////
5
////                                                              ////
6
////  Description                                                 ////
7
////  Emulates the behaviour of the ZBT RAM                       ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   - nothing really                                           ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - Javier Castillo, jcastillo@opensocdesign.com          ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2004 OpenCores                                 ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS Revision History
43
//
44
// $Log: not supported by cvs2svn $
45
 
46
 
47
// synopsys translate_off
48
`include "timescale.v"
49
// synopsys translate_on
50
 
51
 
52
module zbtram(clk,nBW,nCS,nRW,data,address);
53
 
54
   input        clk;
55
   input [3:0]  nBW;
56
   input        nCS;
57
   input        nRW;
58
   inout [31:0] data;
59
   input [19:0] address;
60
 
61
   reg   [19:0] addr_var;
62
   reg   [31:0] mem['h0:'h10000];
63
 
64
   reg control;
65
   reg [31:0] data_t;
66
 
67
   assign #1 data = control ? data_t : 32'hZ;
68
 
69
   integer i,file;
70
 
71
   initial
72
   begin
73
 
74
      #1
75
 
76
      for(i='h0;i<'h10000;i=i+1)
77
        mem[i]=0;
78
 
79
      //Load RAM with a initial program
80
 /*   $display("Initializing RAM");
81
      $readmemh("./hex/or1k-des.hex", mem); */
82
 
83
 
84
 
85
      data_t=0;
86
      control=0;
87
 
88
      while(1)
89
      begin
90
          @(posedge clk)
91
          if(nRW==1)
92
          begin
93
            addr_var = address;
94
 
95
            control = 1;
96
            data_t = mem[addr_var];
97
            if(addr_var==0) data_t=0;
98
//          $display("Read %X from address %X",data_t,addr_var);   
99
          end
100
          else
101
          begin
102
            addr_var = address;
103
            control = 0;
104
            @(posedge clk)
105
            case(nBW)
106
             4'b0000:
107
               mem[addr_var] = data;
108
             4'b0111:
109
               mem[addr_var][31:24] = data[7:0];
110
             4'b1011:
111
               mem[addr_var][23:16] = data[7:0];
112
             4'b1101:
113
               mem[addr_var][15:8] = data[7:0];
114
             4'b1110:
115
               mem[addr_var][7:0] = data[7:0];
116
             4'b0011:
117
               mem[addr_var][31:16] = data[15:0];
118
             4'b1100:
119
               mem[addr_var][15:0] = data[15:0];
120
            endcase
121
            control = 1;
122
//            $display("%d: Write %X in address %X sel= %b",$time,mem[addr_var],addr_var,nBW);   
123
          end
124
       end
125
    end
126
 
127
 
128
 
129
endmodule
130
 

powered by: WebSVN 2.1.0

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