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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_acc.v] - Blame information for rev 116

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 116 simont
// Revision 1.9  2003/01/13 14:14:40  simont
48
// replace some modules
49
//
50 82 simont
// Revision 1.8  2002/11/05 17:23:54  simont
51
// add module oc8051_sfr, 256 bytes internal ram
52
//
53 76 simont
// Revision 1.7  2002/09/30 17:33:59  simont
54
// prepared header
55
//
56
//
57
 
58
// synopsys translate_off
59
`include "oc8051_timescale.v"
60
// synopsys translate_on
61
 
62
`include "oc8051_defines.v"
63
 
64
 
65 116 simont
module oc8051_acc (clk, rst,
66
                 bit_in, data_in, data2_in,
67
                 data_out,
68
                 wr, wr_bit, wr_addr,
69
                 p, wr_sfr);
70 76 simont
 
71
 
72 82 simont
input clk, rst, wr, wr_bit, bit_in;
73 116 simont
input [2:0] wr_sfr;
74 82 simont
input [7:0] wr_addr, data_in, data2_in;
75 76 simont
 
76 116 simont
output p;
77 76 simont
output [7:0] data_out;
78
 
79
reg [7:0] data_out;
80
 
81
//
82
//calculates parity
83
assign p = ^data_out;
84
 
85
//
86
//writing to acc
87
//must check if write high and correct address
88
always @(posedge clk or posedge rst)
89
begin
90
  if (rst)
91
    data_out <= #1 `OC8051_RST_ACC;
92 82 simont
  else if ((wr_sfr==`OC8051_WRS_ACC2) || (wr_sfr==`OC8051_WRS_BA))
93 76 simont
    data_out <= #1 data2_in;
94 82 simont
  else if ((wr_sfr==`OC8051_WRS_ACC1))
95
    data_out <= #1 data_in;
96 76 simont
  else if (wr) begin
97
    if (!wr_bit) begin
98
      if (wr_addr==`OC8051_SFR_ACC)
99
        data_out <= #1 data_in;
100
    end else begin
101
      if (wr_addr[7:3]==`OC8051_SFR_B_ACC)
102
        data_out[wr_addr[2:0]] <= #1 bit_in;
103
    end
104
  end
105
end
106
 
107
endmodule
108
 

powered by: WebSVN 2.1.0

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