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

Subversion Repositories turbo8051

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

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 50 dinesha
module oc8051_xram (clk, rst, wr, be, addr, data_in, data_out, ack, stb);
61 15 dinesha
//
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 50 dinesha
input [3:0]  be; // byte enable
79
input [31:0] data_in;
80 15 dinesha
input [15:0] addr;
81 50 dinesha
output [31:0] data_out;
82 15 dinesha
output ack;
83
 
84
reg ackw, ackr;
85 50 dinesha
reg [31:0] data_out;
86 15 dinesha
reg [2:0] cnt;
87
 
88
//
89
// buffer
90
reg [7:0] buff [65535:0];  //64kb
91
//reg [7:0] buff [8388607:0];  //8Mb
92
 
93
assign ack =  ackw || ackr;
94
 
95
 
96
//
97
// writing to ram
98
always @(posedge clk or posedge rst)
99
begin
100
  if (rst)
101
    ackw <= #1 1'b0;
102
  else if (wr && stb && ((DELAY==3'b000) || (cnt==3'b000))) begin
103 50 dinesha
    if(be[0]) buff[addr]   <= #1 data_in[7:0];
104
    if(be[1]) buff[addr+1] <= #1 data_in[15:8];
105
    if(be[2]) buff[addr+2] <= #1 data_in[23:16];
106
    if(be[3]) buff[addr+3] <= #1 data_in[31:24];
107 15 dinesha
    ackw <= #1 1'b1;
108
  end else ackw <= #1 1'b0;
109
end
110
 
111
always @(posedge clk or posedge rst)
112
  if (rst)
113
    ackr <= #1 1'b0;
114
  else if (stb && !wr && ((DELAY==3'b000) || (cnt==3'b000))) begin
115 50 dinesha
    data_out <= #1 {buff[addr+3], buff[addr+2], buff[addr+1], buff [addr]};
116 15 dinesha
    ackr <= #1 1'b1;
117
  end else begin
118
    ackr <= #1 1'b0;
119
    data_out <= #1 8'h00;
120
  end
121
 
122
always @(posedge clk or posedge rst)
123
begin
124
  if (rst)
125
    cnt <= #1 DELAY;
126
  else if (cnt==3'b000)
127
    cnt <= #1 DELAY;
128
  else if (stb)
129
    cnt <= #1 cnt - 3'b001;
130
  else cnt <= #1 DELAY;
131
end
132
 
133
 
134
endmodule

powered by: WebSVN 2.1.0

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