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

Subversion Repositories turbo8051

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

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

powered by: WebSVN 2.1.0

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