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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_indi_addr.v] - Blame information for rev 82

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

Line No. Rev Author Line
1 82 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 indirect address                                       ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   Contains ragister 0 and register 1. used for indirrect     ////
10
////   addressing.                                                ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   nothing                                                    ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Simon Teran, simont@opencores.org                     ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.4  2002/09/30 17:33:59  simont
49
// prepared header
50
//
51
//
52
 
53
// synopsys translate_off
54
`include "oc8051_timescale.v"
55
// synopsys translate_on
56
 
57
 
58
module oc8051_indi_addr (clk, rst, rd_addr, wr_addr, data_in, wr, wr_bit, rn_out, ri_out, sel, bank);
59
//
60
// clk          (in)  clock
61
// rst          (in)  reset
62
// addr         (in)  write address [oc8051_ram_wr_sel.out]
63
// data_in      (in)  data input (alu destination1) [oc8051_alu.des1]
64
// wr           (in)  write [oc8051_decoder.wr -r]
65
// wr_bit       (in)  write bit addresable [oc8051_decoder.bit_addr -r]
66
// data_out     (out) data output [oc8051_ram_rd_sel.ri, oc8051_ram_wr_sel.ri -r]
67
// sel          (in)  select register [oc8051_op_select.op1_out[0] ]
68
// bank         (in)  select register bank: [oc8051_psw.data_out[4:3] ]
69
//
70
 
71
 
72
input clk, rst, wr, wr_bit;
73
input [1:0] bank;
74
input [2:0] sel;
75
input [7:0] data_in;
76
input [7:0] rd_addr, wr_addr;
77
 
78
output [7:0] rn_out, ri_out;
79
 
80
reg [7:0] rn_out;
81
 
82
reg [7:0] buff [31:0];
83
reg wr_bit_r;
84
wire rd_ram, rd_ind;
85
 
86
 
87
wire tmp;
88
assign tmp = ~|wr_addr[7:5];
89
//
90
//write to buffer
91
always @(posedge clk or posedge rst)
92
begin
93
  if (rst) begin
94
    buff[0] <= #1 8'h00;
95
    buff[1] <= #1 8'h00;
96
    buff[2] <= #1 8'h00;
97
    buff[3] <= #1 8'h00;
98
    buff[4] <= #1 8'h00;
99
    buff[5] <= #1 8'h00;
100
    buff[6] <= #1 8'h00;
101
    buff[7] <= #1 8'h00;
102
    buff[8] <= #1 8'h00;
103
    buff[9] <= #1 8'h00;
104
    buff[10] <= #1 8'h00;
105
    buff[11] <= #1 8'h00;
106
    buff[12] <= #1 8'h00;
107
    buff[13] <= #1 8'h00;
108
    buff[14] <= #1 8'h00;
109
    buff[15] <= #1 8'h00;
110
    buff[16] <= #1 8'h00;
111
    buff[17] <= #1 8'h00;
112
    buff[18] <= #1 8'h00;
113
    buff[19] <= #1 8'h00;
114
    buff[20] <= #1 8'h00;
115
    buff[21] <= #1 8'h00;
116
    buff[22] <= #1 8'h00;
117
    buff[23] <= #1 8'h00;
118
    buff[24] <= #1 8'h00;
119
    buff[25] <= #1 8'h00;
120
    buff[26] <= #1 8'h00;
121
    buff[27] <= #1 8'h00;
122
    buff[28] <= #1 8'h00;
123
    buff[29] <= #1 8'h00;
124
    buff[30] <= #1 8'h00;
125
    buff[31] <= #1 8'h00;
126
  end else if ((wr) && !(wr_bit_r) && (tmp)) begin
127
    buff[wr_addr[4:0]] <= #1 data_in;
128
  end
129
end
130
 
131
//
132
//read from buffer
133
assign rd_ram = (rd_addr== wr_addr);
134
assign rd_ind = ({3'h0, bank,  2'b00, sel[0]}==wr_addr);
135
assign ri_out = ( rd_ind & (wr) & !wr_bit) ? data_in : buff[{bank, 2'b00, sel[0]}];
136
 
137
always @(posedge clk or posedge rst)
138
  if (rst) begin
139
    rn_out <= #1 8'h00;
140
  end else if ( rd_ram & (wr) & !wr_bit) begin
141
    rn_out <= #1 data_in;
142
  end else begin
143
    rn_out <= #1 buff[rd_addr[4:0]];
144
  end
145
 
146
 
147
always @(posedge clk or posedge rst)
148
  if (rst) begin
149
    wr_bit_r <= #1 1'b0;
150
  end else begin
151
    wr_bit_r <= #1 wr_bit;
152
  end
153
 
154
endmodule

powered by: WebSVN 2.1.0

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