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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [model/] [oc8051_xram_32.v] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 external data ram                                      ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   external data ram                                          ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
// Revision 1.4  2002/10/17 18:53:04  simont
48
// added parameter DELAY
49
//
50
// Revision 1.3  2002/09/30 17:34:01  simont
51
// prepared header
52
//
53
//
54
 
55
 
56
module oc8051_xram (clk, rst, wr, be, addr, data_in, data_out, ack, stb);
57
//
58
// external data ram for simulation. part of oc8051_tb
59
// it's tehnology dependent
60
//
61
// clk          (in)  clock
62
// addr         (in)  addres
63
// data_in      (out) data input
64
// data_out     (in)  data output
65
// wr           (in)  write
66
// ack          (out) acknowlage
67
// stb          (in)  strobe
68
//
69
 
70
parameter DELAY=1;
71
 
72
 
73
input clk, wr, stb, rst;
74
input [3:0]  be; // byte enable
75
input [31:0] data_in;
76
input [15:0] addr;
77
output [31:0] data_out;
78
output ack;
79
 
80
reg ackw, ackr;
81
reg [31:0] data_out;
82
reg [2:0] cnt;
83
integer i;
84
//
85
// buffer
86
reg [7:0] buff [65535:0];  //64kb
87
//reg [7:0] buff [8388607:0];  //8Mb
88
 
89
assign ack =  ackw || ackr;
90
 
91
 
92
// Intialise the memory
93
 
94
initial
95
begin
96
  for (i=0; i<65536; i=i+1)
97
    buff [i] = 8'h00;
98
end
99
 
100
//
101
// writing to ram
102
always @(posedge clk or posedge rst)
103
begin
104
  if (rst)
105
    ackw <= #1 1'b0;
106
  else if (wr && stb && ((DELAY==3'b000) || (cnt==3'b000))) begin
107
    if(be[0]) buff[addr]   <= #1 data_in[7:0];
108
    if(be[1]) buff[addr+1] <= #1 data_in[15:8];
109
    if(be[2]) buff[addr+2] <= #1 data_in[23:16];
110
    if(be[3]) buff[addr+3] <= #1 data_in[31:24];
111
    ackw <= #1 1'b1;
112
  end else ackw <= #1 1'b0;
113
end
114
 
115
always @(posedge clk or posedge rst)
116
  if (rst)
117
    ackr <= #1 1'b0;
118
  else if (stb && !wr && ((DELAY==3'b000) || (cnt==3'b000))) begin
119
    data_out <= #1 {buff[addr+3], buff[addr+2], buff[addr+1], buff [addr]};
120
    ackr <= #1 1'b1;
121
  end else begin
122
    ackr <= #1 1'b0;
123
    data_out <= #1 8'h00;
124
  end
125
 
126
always @(posedge clk or posedge rst)
127
begin
128
  if (rst)
129
    cnt <= #1 DELAY;
130
  else if (cnt==3'b000)
131
    cnt <= #1 DELAY;
132
  else if (stb)
133
    cnt <= #1 cnt - 3'b001;
134
  else cnt <= #1 DELAY;
135
end
136
 
137
 
138
endmodule

powered by: WebSVN 2.1.0

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