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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [8051/] [oc8051_acc.v] - Blame information for rev 76

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 cores acccumulator                                     ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6 76 dinesha
////  http://www.opencores.org/cores/turbo8051/                   ////
7 2 dinesha
////                                                              ////
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 76 dinesha
////      - Dinesh Annayya, dinesha@opencores.org                 ////
17 2 dinesha
////                                                              ////
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.13  2003/06/03 17:16:16  simont
49
// `ifdef added.
50
//
51
// Revision 1.12  2003/04/09 16:24:03  simont
52
// change wr_sft to 2 bit wire.
53
//
54
// Revision 1.11  2003/04/09 15:49:42  simont
55
// Register oc8051_sfr dato output, add signal wait_data.
56
//
57
// Revision 1.10  2003/04/07 14:58:02  simont
58
// change sfr's interface.
59
//
60
// Revision 1.9  2003/01/13 14:14:40  simont
61
// replace some modules
62
//
63
// Revision 1.8  2002/11/05 17:23:54  simont
64
// add module oc8051_sfr, 256 bytes internal ram
65
//
66
// Revision 1.7  2002/09/30 17:33:59  simont
67
// prepared header
68
//
69
//
70
 
71 76 dinesha
`include "top_defines.v"
72 2 dinesha
 
73
 
74
module oc8051_acc (clk, rst,
75
                 bit_in, data_in, data2_in,
76
                 data_out,
77
                 wr, wr_bit, wr_addr,
78
                 p, wr_sfr);
79
 
80
 
81
input clk, rst, wr, wr_bit, bit_in;
82
input [1:0] wr_sfr;
83
input [7:0] wr_addr, data_in, data2_in;
84
 
85
output p;
86
output [7:0] data_out;
87
 
88
reg [7:0] data_out;
89
reg [7:0] acc;
90
 
91
wire wr_acc, wr2_acc, wr_bit_acc;
92
//
93
//calculates parity
94
assign p = ^acc;
95
 
96
assign wr_acc     = (wr_sfr==`OC8051_WRS_ACC1) | (wr & !wr_bit & (wr_addr==`OC8051_SFR_ACC));
97
assign wr2_acc    = (wr_sfr==`OC8051_WRS_ACC2);
98
assign wr_bit_acc = (wr & wr_bit & (wr_addr[7:3]==`OC8051_SFR_B_ACC));
99
//
100
//writing to acc
101
always @(wr_sfr or data2_in or wr2_acc or wr_acc or wr_bit_acc or wr_addr[2:0] or data_in or bit_in or data_out)
102
begin
103
  if (wr2_acc)
104
    acc = data2_in;
105
  else if (wr_acc)
106
    acc = data_in;
107
  else if (wr_bit_acc)
108
    case (wr_addr[2:0]) /* synopsys full_case parallel_case */
109
      3'b000: acc = {data_out[7:1], bit_in};
110
      3'b001: acc = {data_out[7:2], bit_in, data_out[0]};
111
      3'b010: acc = {data_out[7:3], bit_in, data_out[1:0]};
112
      3'b011: acc = {data_out[7:4], bit_in, data_out[2:0]};
113
      3'b100: acc = {data_out[7:5], bit_in, data_out[3:0]};
114
      3'b101: acc = {data_out[7:6], bit_in, data_out[4:0]};
115
      3'b110: acc = {data_out[7],   bit_in, data_out[5:0]};
116
      3'b111: acc = {bit_in, data_out[6:0]};
117
    endcase
118
  else
119
    acc = data_out;
120
end
121
 
122
always @(posedge clk or posedge rst)
123
begin
124
  if (rst)
125
    data_out <= #1 `OC8051_RST_ACC;
126
  else
127
    data_out <= #1 acc;
128
end
129
 
130
 
131
`ifdef OC8051_SIMULATION
132
 
133
always @(data_out)
134
  if (data_out===8'hxx) begin
135
    $display("time ",$time, "   faulire: invalid write to ACC (oc8051_acc)");
136
#22
137
    $finish;
138
 
139
  end
140
 
141
 
142
`endif
143
 
144
 
145
endmodule
146
 

powered by: WebSVN 2.1.0

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