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

Subversion Repositories 8051

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

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 153 simont
// Revision 1.12  2003/04/09 16:24:03  simont
48
// change wr_sft to 2 bit wire.
49
//
50 118 simont
// Revision 1.11  2003/04/09 15:49:42  simont
51
// Register oc8051_sfr dato output, add signal wait_data.
52
//
53 117 simont
// Revision 1.10  2003/04/07 14:58:02  simont
54
// change sfr's interface.
55
//
56 116 simont
// Revision 1.9  2003/01/13 14:14:40  simont
57
// replace some modules
58
//
59 82 simont
// Revision 1.8  2002/11/05 17:23:54  simont
60
// add module oc8051_sfr, 256 bytes internal ram
61
//
62 76 simont
// Revision 1.7  2002/09/30 17:33:59  simont
63
// prepared header
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "oc8051_timescale.v"
69
// synopsys translate_on
70
 
71
`include "oc8051_defines.v"
72
 
73
 
74 116 simont
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 76 simont
 
80
 
81 82 simont
input clk, rst, wr, wr_bit, bit_in;
82 118 simont
input [1:0] wr_sfr;
83 82 simont
input [7:0] wr_addr, data_in, data2_in;
84 76 simont
 
85 116 simont
output p;
86 76 simont
output [7:0] data_out;
87
 
88
reg [7:0] data_out;
89 117 simont
reg [7:0] acc;
90 76 simont
 
91 117 simont
wire wr_acc, wr2_acc, wr_bit_acc;
92 76 simont
//
93
//calculates parity
94 117 simont
assign p = ^acc;
95 76 simont
 
96 117 simont
assign wr_acc     = (wr_sfr==`OC8051_WRS_ACC1) | (wr & !wr_bit & (wr_addr==`OC8051_SFR_ACC));
97 118 simont
assign wr2_acc    = (wr_sfr==`OC8051_WRS_ACC2);
98 117 simont
assign wr_bit_acc = (wr & wr_bit & (wr_addr[7:3]==`OC8051_SFR_B_ACC));
99 76 simont
//
100
//writing to acc
101 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)
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])
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
      default: acc = {bit_in, data_out[6:0]};
117
    endcase
118
  else
119
    acc = data_out;
120
end
121
 
122 76 simont
always @(posedge clk or posedge rst)
123
begin
124
  if (rst)
125
    data_out <= #1 `OC8051_RST_ACC;
126 117 simont
  else
127
    data_out <= #1 acc;
128 76 simont
end
129
 
130 153 simont
 
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 76 simont
endmodule
146
 

powered by: WebSVN 2.1.0

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