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

Subversion Repositories 8051

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

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 179 simont
// Revision 1.13  2003/06/03 17:16:16  simont
48
// `ifdef added.
49
//
50 153 simont
// Revision 1.12  2003/04/09 16:24:03  simont
51
// change wr_sft to 2 bit wire.
52
//
53 118 simont
// Revision 1.11  2003/04/09 15:49:42  simont
54
// Register oc8051_sfr dato output, add signal wait_data.
55
//
56 117 simont
// Revision 1.10  2003/04/07 14:58:02  simont
57
// change sfr's interface.
58
//
59 116 simont
// Revision 1.9  2003/01/13 14:14:40  simont
60
// replace some modules
61
//
62 82 simont
// Revision 1.8  2002/11/05 17:23:54  simont
63
// add module oc8051_sfr, 256 bytes internal ram
64
//
65 76 simont
// 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 116 simont
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 76 simont
 
83
 
84 82 simont
input clk, rst, wr, wr_bit, bit_in;
85 118 simont
input [1:0] wr_sfr;
86 82 simont
input [7:0] wr_addr, data_in, data2_in;
87 76 simont
 
88 116 simont
output p;
89 76 simont
output [7:0] data_out;
90
 
91
reg [7:0] data_out;
92 117 simont
reg [7:0] acc;
93 76 simont
 
94 117 simont
wire wr_acc, wr2_acc, wr_bit_acc;
95 76 simont
//
96
//calculates parity
97 117 simont
assign p = ^acc;
98 76 simont
 
99 117 simont
assign wr_acc     = (wr_sfr==`OC8051_WRS_ACC1) | (wr & !wr_bit & (wr_addr==`OC8051_SFR_ACC));
100 118 simont
assign wr2_acc    = (wr_sfr==`OC8051_WRS_ACC2);
101 117 simont
assign wr_bit_acc = (wr & wr_bit & (wr_addr[7:3]==`OC8051_SFR_B_ACC));
102 76 simont
//
103
//writing to acc
104 117 simont
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 179 simont
    case (wr_addr[2:0]) /* synopsys full_case parallel_case */
112 117 simont
      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 179 simont
      3'b111: acc = {bit_in, data_out[6:0]};
120 117 simont
    endcase
121
  else
122
    acc = data_out;
123
end
124
 
125 76 simont
always @(posedge clk or posedge rst)
126
begin
127
  if (rst)
128
    data_out <= #1 `OC8051_RST_ACC;
129 117 simont
  else
130
    data_out <= #1 acc;
131 76 simont
end
132
 
133 153 simont
 
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 76 simont
endmodule
149
 

powered by: WebSVN 2.1.0

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