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

Subversion Repositories turbo8051

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

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 61 dinesha
integer i;
88 15 dinesha
//
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 61 dinesha
// Intialise the memory
97
 
98
initial
99
begin
100
  for (i=0; i<65536; i=i+1)
101
    buff [i] = 8'h00;
102
end
103
 
104 15 dinesha
//
105
// writing to ram
106
always @(posedge clk or posedge rst)
107
begin
108
  if (rst)
109
    ackw <= #1 1'b0;
110
  else if (wr && stb && ((DELAY==3'b000) || (cnt==3'b000))) begin
111 50 dinesha
    if(be[0]) buff[addr]   <= #1 data_in[7:0];
112
    if(be[1]) buff[addr+1] <= #1 data_in[15:8];
113
    if(be[2]) buff[addr+2] <= #1 data_in[23:16];
114
    if(be[3]) buff[addr+3] <= #1 data_in[31:24];
115 15 dinesha
    ackw <= #1 1'b1;
116
  end else ackw <= #1 1'b0;
117
end
118
 
119
always @(posedge clk or posedge rst)
120
  if (rst)
121
    ackr <= #1 1'b0;
122
  else if (stb && !wr && ((DELAY==3'b000) || (cnt==3'b000))) begin
123 50 dinesha
    data_out <= #1 {buff[addr+3], buff[addr+2], buff[addr+1], buff [addr]};
124 15 dinesha
    ackr <= #1 1'b1;
125
  end else begin
126
    ackr <= #1 1'b0;
127
    data_out <= #1 8'h00;
128
  end
129
 
130
always @(posedge clk or posedge rst)
131
begin
132
  if (rst)
133
    cnt <= #1 DELAY;
134
  else if (cnt==3'b000)
135
    cnt <= #1 DELAY;
136
  else if (stb)
137
    cnt <= #1 cnt - 3'b001;
138
  else cnt <= #1 DELAY;
139
end
140
 
141
 
142
endmodule

powered by: WebSVN 2.1.0

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