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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_psw.v] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 program status word                                    ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   program status word                                        ////
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
////                                                              ////
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.11  2003/04/09 15:49:42  simont
49
// Register oc8051_sfr dato output, add signal wait_data.
50
//
51
// Revision 1.10  2003/04/07 14:58:02  simont
52
// change sfr's interface.
53
//
54
// Revision 1.9  2003/01/13 14:14:41  simont
55
// replace some modules
56
//
57
// Revision 1.8  2002/11/05 17:23:54  simont
58
// add module oc8051_sfr, 256 bytes internal ram
59
//
60
// Revision 1.7  2002/09/30 17:33:59  simont
61
// prepared header
62
//
63
//
64
 
65
 
66
`include "top_defines.v"
67
 
68
 
69
module oc8051_psw (clk, rst, wr_addr, data_in, wr, wr_bit, data_out, p,
70
                cy_in, ac_in, ov_in, set, bank_sel);
71
//
72
// clk          (in)  clock
73
// rst          (in)  reset
74
// addr         (in)  write address [oc8051_ram_wr_sel.out]
75
// data_in      (in)  data input [oc8051_alu.des1]
76
// wr           (in)  write [oc8051_decoder.wr -r]
77
// wr_bit       (in)  write bit addresable [oc8051_decoder.bit_addr -r]
78
// p            (in)  parity [oc8051_acc.p]
79
// cy_in        (in)  input bit data [oc8051_alu.desCy]
80
// ac_in        (in)  auxiliary carry input [oc8051_alu.desAc]
81
// ov_in        (in)  overflov input [oc8051_alu.desOv]
82
// set          (in)  set psw (write to caryy, carry and overflov or carry, owerflov and ac) [oc8051_decoder.psw_set -r]
83
//
84
 
85
 
86
input clk, rst, wr, p, cy_in, ac_in, ov_in, wr_bit;
87
input [1:0] set;
88
input [7:0] wr_addr, data_in;
89
 
90
output [1:0] bank_sel;
91
output [7:0] data_out;
92
 
93
reg [7:1] data;
94
wire wr_psw;
95
 
96
assign wr_psw = (wr & (wr_addr==`OC8051_SFR_PSW) && !wr_bit);
97
 
98
assign bank_sel = wr_psw ? data_in[4:3]:data[4:3];
99
assign data_out = {data[7:1], p};
100
 
101
//
102
//case writing to psw
103
always @(posedge clk or posedge rst)
104
begin
105
  if (rst)
106
    data <= #1 `OC8051_RST_PSW;
107
 
108
//
109
// write to psw (byte addressable)
110
  else begin
111
    if (wr & (wr_bit==1'b0) & (wr_addr==`OC8051_SFR_PSW))
112
      data[7:1] <= #1 data_in[7:1];
113
//
114
// write to psw (bit addressable)
115
    else if (wr & wr_bit & (wr_addr[7:3]==`OC8051_SFR_B_PSW))
116
      data[wr_addr[2:0]] <= #1 cy_in;
117
    else begin
118
      case (set) /* synopsys full_case parallel_case */
119
        `OC8051_PS_CY: begin
120
//
121
//write carry
122
          data[7] <= #1 cy_in;
123
        end
124
        `OC8051_PS_OV: begin
125
//
126
//write carry and overflov
127
          data[7] <= #1 cy_in;
128
          data[2] <= #1 ov_in;
129
        end
130
        `OC8051_PS_AC:begin
131
//
132
//write carry, overflov and ac
133
          data[7] <= #1 cy_in;
134
          data[6] <= #1 ac_in;
135
          data[2] <= #1 ov_in;
136
 
137
        end
138
      endcase
139
    end
140
  end
141
end
142
 
143
endmodule

powered by: WebSVN 2.1.0

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