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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_12/] [rtl/] [verilog/] [oc8051_acc.v] - Blame information for rev 76

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

Line No. Rev Author Line
1 76 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 cores acccumulator                                     ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   accumulaor register for 8051 core                          ////
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.7  2002/09/30 17:33:59  simont
48
// prepared header
49
//
50
//
51
 
52
// synopsys translate_off
53
`include "oc8051_timescale.v"
54
// synopsys translate_on
55
 
56
`include "oc8051_defines.v"
57
 
58
 
59
module oc8051_acc (clk, rst, bit_in, data_in, data2_in, wr, wr_bit, wad2, wr_addr, rd_addr,
60
                data_out, bit_out, p, rd_x, xdata);
61
// clk          (in)  clock
62
// rst          (in)  reset
63
// bit_in       (in)  bit input - used in case of writing bits to acc (bit adddressable memory space - alu carry) [oc8051_alu.desCy]
64
// data_in      (in)  data input - used to write to acc (from alu destiantion 1) [oc8051_alu.des1]
65
// data2_in     (in)  data 2 input - write to acc, from alu detination 2 - instuctions mul and div [oc8051_alu.des2]
66
// wr           (in)  write - actine high [oc8051_decoder.wr -r]
67
// wr_bit       (in)  write bit addresable - actine high [oc8051_decoder.bit_addr -r]
68
// wad2         (in)  write data 2 [oc8051_decoder.wad2 -r]
69
// wr_addr      (in)  write address (if is addres of acc and white high must be written to acc) [oc8051_ram_wr_sel.out]
70
// data_out     (out) data output [oc8051_alu_src1_sel.acc oc8051_alu_src2_sel.acc oc8051_comp.acc oc8051_ram_sel.acc]
71
// p            (out) parity [oc8051_psw.p]
72
// rd_x         (in)  read external
73
// xdata        (in)  external data input
74
//
75
 
76
 
77
input clk, rst, wr, wr_bit, wad2, bit_in, rd_x;
78
input [2:0] rd_addr;
79
input [7:0] wr_addr, data_in, data2_in, xdata;
80
 
81
output p, bit_out;
82
output [7:0] data_out;
83
 
84
reg [7:0] data_out;
85
reg bit_out;
86
 
87
//
88
//calculates parity
89
assign p = ^data_out;
90
 
91
//
92
//writing to acc
93
//must check if write high and correct address
94
always @(posedge clk or posedge rst)
95
begin
96
  if (rst)
97
    data_out <= #1 `OC8051_RST_ACC;
98
  else if (rd_x)
99
    data_out <= #1 xdata;
100
  else if (wad2)
101
    data_out <= #1 data2_in;
102
  else if (wr) begin
103
    if (!wr_bit) begin
104
      if (wr_addr==`OC8051_SFR_ACC)
105
        data_out <= #1 data_in;
106
    end else begin
107
      if (wr_addr[7:3]==`OC8051_SFR_B_ACC)
108
        data_out[wr_addr[2:0]] <= #1 bit_in;
109
    end
110
  end
111
end
112
 
113
always @(posedge clk or posedge rst)
114
begin
115
  if (rst) bit_out <= #1 1'b0;
116
  else if ((rd_addr==wr_addr[2:0]) & wr & wr_bit) begin
117
      bit_out <= #1 bit_in;
118
  end else if ((wr_addr==`OC8051_SFR_ACC) & wr & !wr_bit) begin
119
      bit_out <= #1 data_in[rd_addr];
120
  end else bit_out <= #1 data_out[rd_addr];
121
end
122
 
123
endmodule
124
 

powered by: WebSVN 2.1.0

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