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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [model/] [oc8051_xram.v] - Blame information for rev 23

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

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

powered by: WebSVN 2.1.0

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