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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_acc.v] - Blame information for rev 25

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/oms8051mini/                 ////
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
////      - Dinesh Annayya, dinesha@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19 25 dinesha
////   v0.0 - Dinesh A, 5th Jan 2017
20
////        1. Active edge of reset changed from High to Low
21
//////////////////////////////////////////////////////////////////////
22 2 dinesha
////                                                              ////
23
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
24
////                                                              ////
25
//// This source file may be used and distributed without         ////
26
//// restriction provided that this copyright statement is not    ////
27
//// removed from the file and that any derivative work contains  ////
28
//// the original copyright notice and the associated disclaimer. ////
29
////                                                              ////
30
//// This source file is free software; you can redistribute it   ////
31
//// and/or modify it under the terms of the GNU Lesser General   ////
32
//// Public License as published by the Free Software Foundation; ////
33
//// either version 2.1 of the License, or (at your option) any   ////
34
//// later version.                                               ////
35
////                                                              ////
36
//// This source is distributed in the hope that it will be       ////
37
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
38
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
39
//// PURPOSE.  See the GNU Lesser General Public License for more ////
40
//// details.                                                     ////
41
////                                                              ////
42
//// You should have received a copy of the GNU Lesser General    ////
43
//// Public License along with this source; if not, download it   ////
44
//// from http://www.opencores.org/lgpl.shtml                     ////
45
////                                                              ////
46
//////////////////////////////////////////////////////////////////////
47
//
48
// CVS Revision History
49
//
50
// $Log: not supported by cvs2svn $
51
// Revision 1.13  2003/06/03 17:16:16  simont
52
// `ifdef added.
53
//
54
// Revision 1.12  2003/04/09 16:24:03  simont
55
// change wr_sft to 2 bit wire.
56
//
57
// Revision 1.11  2003/04/09 15:49:42  simont
58
// Register oc8051_sfr dato output, add signal wait_data.
59
//
60
// Revision 1.10  2003/04/07 14:58:02  simont
61
// change sfr's interface.
62
//
63
// Revision 1.9  2003/01/13 14:14:40  simont
64
// replace some modules
65
//
66
// Revision 1.8  2002/11/05 17:23:54  simont
67
// add module oc8051_sfr, 256 bytes internal ram
68
//
69
// Revision 1.7  2002/09/30 17:33:59  simont
70
// prepared header
71
//
72
//
73
 
74
`include "top_defines.v"
75
 
76
 
77 25 dinesha
module oc8051_acc (clk, resetn,
78 2 dinesha
                 bit_in, data_in, data2_in,
79
                 data_out,
80
                 wr, wr_bit, wr_addr,
81
                 p, wr_sfr);
82
 
83
 
84 25 dinesha
input clk, resetn, wr, wr_bit, bit_in;
85 2 dinesha
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 25 dinesha
always @(posedge clk or negedge resetn)
126 2 dinesha
begin
127 25 dinesha
  if (resetn == 1'b0)
128 2 dinesha
    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.