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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [verif/] [model/] [oc8051_xram.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 15 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
// synopsys translate_off
56
`include "oc8051_timescale.v"
57
// synopsys translate_on
58
 
59
 
60
module oc8051_xram (clk, rst, wr, addr, data_in, data_out, ack, stb);
61
//
62
// external data ram for simulation. part of oc8051_tb
63
// it's tehnology dependent
64
//
65
// clk          (in)  clock
66
// addr         (in)  addres
67
// data_in      (out) data input
68
// data_out     (in)  data output
69
// wr           (in)  write
70
// ack          (out) acknowlage
71
// stb          (in)  strobe
72
//
73
 
74
parameter DELAY=1;
75
 
76
 
77
input clk, wr, stb, rst;
78
input [7:0] data_in;
79
input [15:0] addr;
80
output [7:0] data_out;
81
output ack;
82
 
83
reg ackw, ackr;
84
reg [7:0] data_out;
85
reg [2:0] cnt;
86
 
87
//
88
// buffer
89
reg [7:0] buff [65535:0];  //64kb
90
//reg [7:0] buff [8388607:0];  //8Mb
91
 
92
assign ack =  ackw || ackr;
93
 
94
 
95
//
96
// writing to ram
97
always @(posedge clk or posedge rst)
98
begin
99
  if (rst)
100
    ackw <= #1 1'b0;
101
  else if (wr && stb && ((DELAY==3'b000) || (cnt==3'b000))) begin
102
    buff[addr] <= #1 data_in;
103
    ackw <= #1 1'b1;
104
  end else ackw <= #1 1'b0;
105
end
106
 
107
always @(posedge clk or posedge rst)
108
  if (rst)
109
    ackr <= #1 1'b0;
110
  else if (stb && !wr && ((DELAY==3'b000) || (cnt==3'b000))) begin
111
    data_out <= #1 buff[addr];
112
    ackr <= #1 1'b1;
113
  end else begin
114
    ackr <= #1 1'b0;
115
    data_out <= #1 8'h00;
116
  end
117
 
118
always @(posedge clk or posedge rst)
119
begin
120
  if (rst)
121
    cnt <= #1 DELAY;
122
  else if (cnt==3'b000)
123
    cnt <= #1 DELAY;
124
  else if (stb)
125
    cnt <= #1 cnt - 3'b001;
126
  else cnt <= #1 DELAY;
127
end
128
 
129
 
130
endmodule

powered by: WebSVN 2.1.0

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