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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_sfr.v] - Diff between revs 116 and 117

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 116 Rev 117
Line 42... Line 42...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.7  2003/04/07 14:58:02  simont
 
// change sfr's interface.
 
//
// Revision 1.6  2003/04/07 13:29:16  simont
// Revision 1.6  2003/04/07 13:29:16  simont
// change uart to meet timing.
// change uart to meet timing.
//
//
// Revision 1.5  2003/04/04 10:35:07  simont
// Revision 1.5  2003/04/04 10:35:07  simont
// signal prsc_ow added.
// signal prsc_ow added.
Line 69... Line 72...
// synopsys translate_on
// synopsys translate_on
 
 
`include "oc8051_defines.v"
`include "oc8051_defines.v"
 
 
 
 
module oc8051_sfr (rst, clk, adr0, adr1, dat0, dat1, dat2, we, bit_in, bit_out, wr_bit,
module oc8051_sfr (rst, clk,
 
       adr0, adr1, dat0,
 
       dat1, dat2,
 
       we, bit_in, wr_bit,
 
       bit_out,
       wr_sfr, acc, ram_wr_sel, ram_rd_sel, sp, sp_w, bank_sel, desAc, desOv, psw_set, srcAc, cy, rmw,
       wr_sfr, acc, ram_wr_sel, ram_rd_sel, sp, sp_w, bank_sel, desAc, desOv, psw_set, srcAc, cy, rmw,
       p0_out, p1_out, p2_out, p3_out, p0_in, p1_in, p2_in, p3_in, rxd, txd, int_ack, intr, int0,
       p0_out, p1_out, p2_out, p3_out, p0_in, p1_in, p2_in, p3_in, rxd, txd, int_ack, intr, int0,
       int1, reti, int_src, t0, t1, dptr_hi, dptr_lo, t2, t2ex);
       int1, reti, int_src, t0, t1, dptr_hi, dptr_lo, t2, t2ex,
 
       wait_data);
//
//
// rst           (in)  reset - pin
// rst           (in)  reset - pin
// clk           (in)  clock - pin
// clk           (in)  clock - pin
// adr0, adr1    (in)  address input
// adr0, adr1    (in)  address input
// dat0          (out) data output
// dat0          (out) data output
Line 149... Line 157...
input int_ack, int0, int1, reti, wr_bit, t0, t1;
input int_ack, int0, int1, reti, wr_bit, t0, t1;
input [1:0] psw_set;
input [1:0] psw_set;
input [2:0] ram_rd_sel, ram_wr_sel, wr_sfr;
input [2:0] ram_rd_sel, ram_wr_sel, wr_sfr;
input [7:0] adr0, adr1, dat1, dat2, p0_in, p1_in, p2_in, p3_in;
input [7:0] adr0, adr1, dat1, dat2, p0_in, p1_in, p2_in, p3_in;
 
 
output bit_out, txd, intr, srcAc, cy;
output bit_out, txd, intr, srcAc, cy, wait_data;
output [1:0] bank_sel;
output [1:0] bank_sel;
output [7:0] dat0, p0_out, p1_out, p2_out, p3_out, int_src, dptr_hi, dptr_lo, acc;
output [7:0] dat0, p0_out, p1_out, p2_out, p3_out, int_src, dptr_hi, dptr_lo, acc;
output [7:0] sp, sp_w;
output [7:0] sp, sp_w;
 
 
 
 
reg bit_out;
reg bit_out, wait_data;
reg [7:0] dat0, adr0_r;
reg [7:0] dat0, adr0_r;
 
 
reg wr_bit_r;
reg wr_bit_r;
reg [2:0] ram_wr_sel_r;
reg [2:0] ram_wr_sel_r;
 
 
Line 183... Line 191...
// stack
// stack
          sp_out;
          sp_out;
 
 
wire pres_ow;
wire pres_ow;
 
 
 
 
assign cy = psw[7];
assign cy = psw[7];
assign srcAc = psw [6];
assign srcAc = psw [6];
 
 
 
 
 
 
Line 280... Line 289...
always @(posedge clk or posedge rst)
always @(posedge clk or posedge rst)
  if (rst) begin
  if (rst) begin
    adr0_r <= #1 8'h00;
    adr0_r <= #1 8'h00;
    ram_wr_sel_r <= #1 3'b000;
    ram_wr_sel_r <= #1 3'b000;
    wr_bit_r <= #1 1'b0;
    wr_bit_r <= #1 1'b0;
 
//    wait_data <= #1 1'b0;
  end else begin
  end else begin
    adr0_r <= #1 adr0;
    adr0_r <= #1 adr0;
    ram_wr_sel_r <= #1 ram_wr_sel;
    ram_wr_sel_r <= #1 ram_wr_sel;
    wr_bit_r <= #1 wr_bit;
    wr_bit_r <= #1 wr_bit;
  end
  end
 
 
 
/*
 
//
 
//set output in case of address (byte)
 
always @(adr0_r or psw or acc or dptr_hi or dptr_lo or b_reg or
 
//ports
 
          p0_data or p1_data or p2_data or p3_data or
 
//interrupt control
 
          ie or tcon or ip or
 
// t/c 2
 
          t2con or tl2 or th2 or rcap2l or rcap2h or
 
// t/c 0,1
 
          tmod or tl0 or th0 or tl1 or th1 or
 
// serial interface
 
          scon or pcon or sbuf or
 
// stack
 
          sp_out)
 
begin
 
    case (adr0_r)
 
      `OC8051_SFR_ACC:          dat0 = acc;
 
      `OC8051_SFR_PSW:          dat0 = psw;
 
      `OC8051_SFR_P0:           dat0 = p0_data;
 
      `OC8051_SFR_P1:           dat0 = p1_data;
 
      `OC8051_SFR_P2:           dat0 = p2_data;
 
      `OC8051_SFR_P3:           dat0 = p3_data;
 
      `OC8051_SFR_SP:           dat0 = sp_out;
 
      `OC8051_SFR_B:            dat0 = b_reg;
 
      `OC8051_SFR_DPTR_HI:      dat0 = dptr_hi;
 
      `OC8051_SFR_DPTR_LO:      dat0 = dptr_lo;
 
      `OC8051_SFR_SCON:         dat0 = scon;
 
      `OC8051_SFR_SBUF:         dat0 = sbuf;
 
      `OC8051_SFR_PCON:         dat0 = pcon;
 
      `OC8051_SFR_TH0:          dat0 = th0;
 
      `OC8051_SFR_TH1:          dat0 = th1;
 
      `OC8051_SFR_TL0:          dat0 = tl0;
 
      `OC8051_SFR_TL1:          dat0 = tl1;
 
      `OC8051_SFR_TMOD:         dat0 = tmod;
 
      `OC8051_SFR_IP:           dat0 = ip;
 
      `OC8051_SFR_IE:           dat0 = ie;
 
      `OC8051_SFR_TCON:         dat0 = tcon;
 
      `OC8051_SFR_RCAP2H:       dat0 = rcap2h;
 
      `OC8051_SFR_RCAP2L:       dat0 = rcap2l;
 
      `OC8051_SFR_TH2:          dat0 = th2;
 
      `OC8051_SFR_TL2:          dat0 = tl2;
 
      `OC8051_SFR_T2CON:        dat0 = t2con;
 
      default:                  dat0 = 8'h00;
 
    endcase
 
end
 
 
 
 
 
//
 
//set output in case of address (bit)
 
always @(adr0_r or psw or acc or b_reg or
 
//ports
 
          p0_data or p1_data or p2_data or p3_data or
 
//interrupt control
 
          ie or tcon or ip or
 
// t/c 2
 
          t2con or
 
// serial interface
 
          scon)
 
begin
 
    case (adr0_r[7:3])
 
      `OC8051_SFR_B_ACC:   bit_out = acc[adr0_r[2:0]];
 
      `OC8051_SFR_B_PSW:   bit_out = psw[adr0_r[2:0]];
 
      `OC8051_SFR_B_P0:    bit_out = p0_data[adr0_r[2:0]];
 
      `OC8051_SFR_B_P1:    bit_out = p1_data[adr0_r[2:0]];
 
      `OC8051_SFR_B_P2:    bit_out = p2_data[adr0_r[2:0]];
 
      `OC8051_SFR_B_P3:    bit_out = p3_data[adr0_r[2:0]];
 
      `OC8051_SFR_B_B:     bit_out = b_reg[adr0_r[2:0]];
 
      `OC8051_SFR_B_IP:    bit_out = ip[adr0_r[2:0]];
 
      `OC8051_SFR_B_IE:    bit_out = ie[adr0_r[2:0]];
 
      `OC8051_SFR_B_TCON:  bit_out = tcon[adr0_r[2:0]];
 
      `OC8051_SFR_B_SCON:  bit_out = scon[adr0_r[2:0]];
 
      `OC8051_SFR_B_T2CON: bit_out = t2con[adr0_r[2:0]];
 
      default:             bit_out = 1'b0;
 
    endcase
 
end
 
*/
 
 
 
 
 
 
//
//
//set output in case of address (byte)
//set output in case of address (byte)
always @(adr0_r or psw or acc or dptr_hi or dptr_lo or b_reg or
always @(posedge clk or posedge rst)
//ports
 
          p0_data or p1_data or p2_data or p3_data or
 
//interrupt control
 
          ie or tcon or ip or
 
// t/c 2
 
          t2con or tl2 or th2 or rcap2l or rcap2h or
 
// t/c 0,1
 
          tmod or tl0 or th0 or tl1 or th1 or
 
// serial interface
 
          scon or pcon or sbuf or
 
// stack
 
          sp_out)
 
begin
begin
    case (adr0_r)
  if (rst) begin
      `OC8051_SFR_ACC:          dat0 = acc;
    dat0 <= #1 8'h00;
      `OC8051_SFR_PSW:          dat0 = psw;
    wait_data <= #1 1'b0;
      `OC8051_SFR_P0:           dat0 = p0_data;
/*  end else if (((adr0==`OC8051_SFR_PSW) & (((adr1==`OC8051_SFR_ACC) & we & !wr_bit_r)) |
      `OC8051_SFR_P1:           dat0 = p1_data;
                (({adr1[7:3], 3'b000}==adr0) & we & wr_bit_r)) & !wait_data) begin
      `OC8051_SFR_P2:           dat0 = p2_data;
//    dat0 <= #1 {dat1[7:1], p};
      `OC8051_SFR_P3:           dat0 = p3_data;
    wait_data <= #1 1'b1;
      `OC8051_SFR_SP:           dat0 = sp_out;
  end else if ((adr0==`OC8051_SFR_PSW) & (adr1==adr0) & we & !wr_bit_r & !wait_data) begin
      `OC8051_SFR_B:            dat0 = b_reg;
//    dat0 <= #1 {dat1[7:1], p};
      `OC8051_SFR_DPTR_HI:      dat0 = dptr_hi;
    wait_data <= #1 1'b1;*/
      `OC8051_SFR_DPTR_LO:      dat0 = dptr_lo;
  end else if ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_LO)) begin                          //write and read same address
      `OC8051_SFR_SCON:         dat0 = scon;
    dat0 <= #1 dat1;
      `OC8051_SFR_SBUF:         dat0 = sbuf;
    wait_data <= #1 1'b0;
      `OC8051_SFR_PCON:         dat0 = pcon;
  end else if (
      `OC8051_SFR_TH0:          dat0 = th0;
      (((wr_sfr==`OC8051_WRS_ACC1) & (adr0==`OC8051_SFR_ACC)) |                 //write to acc
      `OC8051_SFR_TH1:          dat0 = th1;
      ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_LO)) |      //write to dpl
      `OC8051_SFR_TL0:          dat0 = tl0;
      ((wr_sfr==`OC8051_WRS_BA)   & (adr0==`OC8051_SFR_B)) |            //write to b
      `OC8051_SFR_TL1:          dat0 = tl1;
      (adr1[7] & (adr1==adr0) & we & !wr_bit_r)) & !wait_data) begin                            //write and read same address
      `OC8051_SFR_TMOD:         dat0 = tmod;
//    dat0 <= #1 dat1;
      `OC8051_SFR_IP:           dat0 = ip;
    wait_data <= #1 1'b1;
      `OC8051_SFR_IE:           dat0 = ie;
 
      `OC8051_SFR_TCON:         dat0 = tcon;
  end else if (
      `OC8051_SFR_RCAP2H:       dat0 = rcap2h;
      (((wr_sfr==`OC8051_WRS_ACC2) & (adr0==`OC8051_SFR_ACC)) |         //write to acc
      `OC8051_SFR_RCAP2L:       dat0 = rcap2l;
      ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_HI)) |      //write to dph
      `OC8051_SFR_TH2:          dat0 = th2;
      ((wr_sfr==`OC8051_WRS_BA)   & (adr0==`OC8051_SFR_ACC))) & !wait_data) begin       //write to b
      `OC8051_SFR_TL2:          dat0 = tl2;
//    dat0 <= #1 dat2;
      `OC8051_SFR_T2CON:        dat0 = t2con;
    wait_data <= #1 1'b1;
      default:                  dat0 = 8'h00;
 
 
//  else if (({adr1[7:3], 3'b000}==adr0_r) & we & wr_bit_r)
 
//    dat0 <= #1 dat1;
 
  end else begin
 
    case (adr0)
 
      `OC8051_SFR_ACC:          dat0 <= #1 acc;
 
      `OC8051_SFR_PSW:          dat0 <= #1 psw;
 
      `OC8051_SFR_P0:           dat0 <= #1 p0_data;
 
      `OC8051_SFR_P1:           dat0 <= #1 p1_data;
 
      `OC8051_SFR_P2:           dat0 <= #1 p2_data;
 
      `OC8051_SFR_P3:           dat0 <= #1 p3_data;
 
//      `OC8051_SFR_SP:                 dat0 <= #1 sp_out;
 
      `OC8051_SFR_SP:           dat0 <= #1 sp;
 
      `OC8051_SFR_B:            dat0 <= #1 b_reg;
 
      `OC8051_SFR_DPTR_HI:      dat0 <= #1 dptr_hi;
 
      `OC8051_SFR_DPTR_LO:      dat0 <= #1 dptr_lo;
 
      `OC8051_SFR_SCON:         dat0 <= #1 scon;
 
      `OC8051_SFR_SBUF:         dat0 <= #1 sbuf;
 
      `OC8051_SFR_PCON:         dat0 <= #1 pcon;
 
      `OC8051_SFR_TH0:          dat0 <= #1 th0;
 
      `OC8051_SFR_TH1:          dat0 <= #1 th1;
 
      `OC8051_SFR_TL0:          dat0 <= #1 tl0;
 
      `OC8051_SFR_TL1:          dat0 <= #1 tl1;
 
      `OC8051_SFR_TMOD:         dat0 <= #1 tmod;
 
      `OC8051_SFR_IP:           dat0 <= #1 ip;
 
      `OC8051_SFR_IE:           dat0 <= #1 ie;
 
      `OC8051_SFR_TCON:         dat0 <= #1 tcon;
 
      `OC8051_SFR_RCAP2H:       dat0 <= #1 rcap2h;
 
      `OC8051_SFR_RCAP2L:       dat0 <= #1 rcap2l;
 
      `OC8051_SFR_TH2:          dat0 <= #1 th2;
 
      `OC8051_SFR_TL2:          dat0 <= #1 tl2;
 
      `OC8051_SFR_T2CON:        dat0 <= #1 t2con;
 
      default:                  dat0 <= #1 8'h00;
    endcase
    endcase
 
    wait_data <= #1 1'b0;
 
  end
end
end
 
 
 
 
//
//
//set output in case of address (bit)
//set output in case of address (bit)
always @(adr0_r or psw or acc or b_reg or
always @(posedge clk or posedge rst)
//ports
 
          p0_data or p1_data or p2_data or p3_data or
 
//interrupt control
 
          ie or tcon or ip or
 
// t/c 2
 
          t2con or
 
// serial interface
 
          scon)
 
begin
begin
    case (adr0_r[7:3])
  if (rst)
      `OC8051_SFR_B_ACC:   bit_out = acc[adr0_r[2:0]];
    bit_out <= #1 1'h0;
      `OC8051_SFR_B_PSW:   bit_out = psw[adr0_r[2:0]];
  else if (
      `OC8051_SFR_B_P0:    bit_out = p0_data[adr0_r[2:0]];
          ((adr1[7:3]==adr0[7:3]) & (~&adr1[2:0]) &  we & !wr_bit_r) |
      `OC8051_SFR_B_P1:    bit_out = p1_data[adr0_r[2:0]];
          ((wr_sfr==`OC8051_WRS_ACC1) & (adr0[7:3]==`OC8051_SFR_B_ACC)) |       //write to acc
      `OC8051_SFR_B_P2:    bit_out = p2_data[adr0_r[2:0]];
          ((wr_sfr==`OC8051_WRS_BA)   & (adr0[7:3]==`OC8051_SFR_B_B)))          //write to b
      `OC8051_SFR_B_P3:    bit_out = p3_data[adr0_r[2:0]];
 
      `OC8051_SFR_B_B:     bit_out = b_reg[adr0_r[2:0]];
    bit_out <= #1 dat1[adr0[2:0]];
      `OC8051_SFR_B_IP:    bit_out = ip[adr0_r[2:0]];
  else if ((adr1==adr0) & we & wr_bit_r)
      `OC8051_SFR_B_IE:    bit_out = ie[adr0_r[2:0]];
    bit_out <= #1 bit_in;
      `OC8051_SFR_B_TCON:  bit_out = tcon[adr0_r[2:0]];
  else
      `OC8051_SFR_B_SCON:  bit_out = scon[adr0_r[2:0]];
    case (adr0[7:3])
      `OC8051_SFR_B_T2CON: bit_out = t2con[adr0_r[2:0]];
      `OC8051_SFR_B_ACC:   bit_out <= #1 acc[adr0[2:0]];
      default:             bit_out = 1'b0;
      `OC8051_SFR_B_PSW:   bit_out <= #1 psw[adr0[2:0]];
 
      `OC8051_SFR_B_P0:    bit_out <= #1 p0_data[adr0[2:0]];
 
      `OC8051_SFR_B_P1:    bit_out <= #1 p1_data[adr0[2:0]];
 
      `OC8051_SFR_B_P2:    bit_out <= #1 p2_data[adr0[2:0]];
 
      `OC8051_SFR_B_P3:    bit_out <= #1 p3_data[adr0[2:0]];
 
      `OC8051_SFR_B_B:     bit_out <= #1 b_reg[adr0[2:0]];
 
      `OC8051_SFR_B_IP:    bit_out <= #1 ip[adr0[2:0]];
 
      `OC8051_SFR_B_IE:    bit_out <= #1 ie[adr0[2:0]];
 
      `OC8051_SFR_B_TCON:  bit_out <= #1 tcon[adr0[2:0]];
 
      `OC8051_SFR_B_SCON:  bit_out <= #1 scon[adr0[2:0]];
 
      `OC8051_SFR_B_T2CON: bit_out <= #1 t2con[adr0[2:0]];
 
      default:             bit_out <= #1 1'b0;
    endcase
    endcase
end
end
 
 
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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