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

Subversion Repositories 8051

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

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

Line No. Rev Author Line
1 2 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 46 simont
// CVS Revision History
46 2 simont
//
47 46 simont
// $Log: not supported by cvs2svn $
48
//
49 2 simont
 
50
// synopsys translate_off
51
`include "oc8051_timescale.v"
52
// synopsys translate_on
53
 
54
 
55
module oc8051_indi_addr (clk, rst, addr, data_in, wr, wr_bit, data_out, sel, bank);
56
//
57
// clk          (in)  clock
58
// rst          (in)  reset
59
// addr         (in)  write address [oc8051_ram_wr_sel.out]
60
// data_in      (in)  data input (alu destination1) [oc8051_alu.des1]
61
// wr           (in)  write [oc8051_decoder.wr -r]
62
// wr_bit       (in)  write bit addresable [oc8051_decoder.bit_addr -r]
63
// data_out     (out) data output [oc8051_ram_rd_sel.ri, oc8051_ram_wr_sel.ri -r]
64
// sel          (in)  select register [oc8051_op_select.op1_out[0] ]
65
// bank         (in)  select register bank: [oc8051_psw.data_out[4:3] ]
66
//
67
 
68
 
69
input clk, rst, wr, sel, wr_bit;
70
input [1:0] bank;
71
input [7:0] addr, data_in;
72
 
73
output [7:0] data_out;
74
 
75
reg [7:0] buff [7:0];
76
 
77
//
78
//write to buffer
79
always @(posedge clk or posedge rst)
80
begin
81
  if (rst) begin
82 5 markom
    buff[3'b000] = #1 8'h00;
83
    buff[3'b001] = #1 8'h00;
84
    buff[3'b010] = #1 8'h00;
85
    buff[3'b011] = #1 8'h00;
86
    buff[3'b100] = #1 8'h00;
87
    buff[3'b101] = #1 8'h00;
88
    buff[3'b110] = #1 8'h00;
89
    buff[3'b111] = #1 8'h00;
90 2 simont
  end else begin
91
    if ((wr) & !(wr_bit)) begin
92
      case (addr)
93 5 markom
        8'h00: buff[3'b000] = #1 data_in;
94
        8'h01: buff[3'b001] = #1 data_in;
95
        8'h08: buff[3'b010] = #1 data_in;
96
        8'h09: buff[3'b011] = #1 data_in;
97
        8'h10: buff[3'b100] = #1 data_in;
98
        8'h11: buff[3'b101] = #1 data_in;
99
        8'h18: buff[3'b110] = #1 data_in;
100
        8'h19: buff[3'b111] = #1 data_in;
101 2 simont
      endcase
102
    end
103
  end
104
end
105
 
106
//
107
//read from buffer
108 5 markom
assign data_out = (({3'b000, bank, 2'b00, sel}==addr) & (wr)) ?
109
  data_in : buff[{bank, sel}];
110 2 simont
 
111 4 markom
endmodule

powered by: WebSVN 2.1.0

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