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

Subversion Repositories oms8051mini

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

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

powered by: WebSVN 2.1.0

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