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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_memory_interface.v] - Diff between revs 20 and 25

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

Rev 20 Rev 25
Line 12... Line 12...
////   nothing                                                    ////
////   nothing                                                    ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Simon Teran, simont@opencores.org                     ////
////      - Simon Teran, simont@opencores.org                     ////
////      - Dinesh Annayya, dinesha@opencores.org                 ////
////      - Dinesh Annayya, dinesha@opencores.org                 ////
////      - Dinesh Annayya, dinesha@opencores.org                 ////
 
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
 
////   v0.0 - Dinesh A, 5th Jan 2017
 
////        1. Active edge of reset changed from High to Low
 
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
Line 86... Line 88...
 
 
 
 
`include "top_defines.v"
`include "top_defines.v"
 
 
 
 
module oc8051_memory_interface (clk, rst,
module oc8051_memory_interface (clk, resetn,
 
 
//decoder
//decoder
     wr_i,
     wr_i,
     wr_bit_i,
     wr_bit_i,
     rd_sel,
     rd_sel,
Line 163... Line 165...
     reti
     reti
   );
   );
 
 
 
 
input         clk,
input         clk,
              rst,
              resetn,
              wr_i,
              wr_i,
              wr_bit_i;
              wr_bit_i;
 
 
input         bit_in,
input         bit_in,
              sfr_bit,
              sfr_bit,
Line 365... Line 367...
 
 
assign wr_dat     = des1;
assign wr_dat     = des1;
 
 
 
 
`ifdef OC8051_SIMULATION
`ifdef OC8051_SIMULATION
  always @(negedge rst) begin
  always @(negedge resetn) begin
    #5
    #5
    if (ea_rom_sel)
    if (ea_rom_sel)
      $display("   progran execution from external rom");
      $display("   progran execution from external rom");
    else
    else
      $display("   progran execution from internal rom");
      $display("   progran execution from internal rom");
Line 431... Line 433...
    `OC8051_RWS_B  : wr_addr = `OC8051_SFR_B;
    `OC8051_RWS_B  : wr_addr = `OC8051_SFR_B;
//    default        : wr_addr = 2'bxx;
//    default        : wr_addr = 2'bxx;
  endcase
  endcase
end
end
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst)
  if (resetn == 1'b0)
    rd_ind <= #1 1'b0;
    rd_ind <= #1 1'b0;
  else if ((rd_sel==`OC8051_RRS_I) || (rd_sel==`OC8051_RRS_SP))
  else if ((rd_sel==`OC8051_RRS_I) || (rd_sel==`OC8051_RRS_SP))
    rd_ind <= #1 1'b1;
    rd_ind <= #1 1'b1;
  else
  else
    rd_ind <= #1 1'b0;
    rd_ind <= #1 1'b0;
Line 459... Line 461...
 
 
//assign iadr_o = (istb_t & !iack_i) ? iadr_t : pc_out;
//assign iadr_o = (istb_t & !iack_i) ? iadr_t : pc_out;
assign iadr_o = (istb_t) ? iadr_t : pc_out;
assign iadr_o = (istb_t) ? iadr_t : pc_out;
 
 
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    iadr_t <= #1 23'h0;
    iadr_t <= #1 23'h0;
    istb_t <= #1 1'b0;
    istb_t <= #1 1'b0;
    imem_wait <= #1 1'b0;
    imem_wait <= #1 1'b0;
    idat_ir <= #1 24'h0;
    idat_ir <= #1 24'h0;
  end else if (mem_act==`OC8051_MAS_CODE) begin
  end else if (mem_act==`OC8051_MAS_CODE) begin
Line 488... Line 490...
//
//
/////////////////////////////
/////////////////////////////
 
 
assign dadr_o = dadr_ot;
assign dadr_o = dadr_ot;
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    dwe_o <= #1 1'b0;
    dwe_o <= #1 1'b0;
    dmem_wait <= #1 1'b0;
    dmem_wait <= #1 1'b0;
    dstb_o <= #1 1'b0;
    dstb_o <= #1 1'b0;
    ddat_o <= #1 8'h00;
    ddat_o <= #1 8'h00;
    dadr_ot <= #1 23'h0;
    dadr_ot <= #1 23'h0;
Line 542... Line 544...
//
//
/////////////////////////////
/////////////////////////////
 
 
 
 
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    idat_cur <= #1 32'h0;
    idat_cur <= #1 32'h0;
    idat_old <= #1 32'h0;
    idat_old <= #1 32'h0;
  end else if ((iack_i | ea_rom_sel) & (inc_pc | pc_wr_r2)) begin
  end else if ((iack_i | ea_rom_sel) & (inc_pc | pc_wr_r2)) begin
    idat_cur <= #1 ea_rom_sel ? idat_onchip : idat_i;
    idat_cur <= #1 ea_rom_sel ? idat_onchip : idat_i;
    idat_old <= #1 idat_cur;
    idat_old <= #1 idat_cur;
  end
  end
 
 
end
end
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    cdata <= #1 8'h00;
    cdata <= #1 8'h00;
    cdone <= #1 1'b0;
    cdone <= #1 1'b0;
  end else if (istb_t) begin
  end else if (istb_t) begin
    cdata <= #1 ea_rom_sel ? idat_onchip[7:0] : idat_i[7:0];
    cdata <= #1 ea_rom_sel ? idat_onchip[7:0] : idat_i[7:0];
    cdone <= #1 1'b1;
    cdone <= #1 1'b1;
Line 650... Line 652...
  end
  end
end
end
 
 
//
//
//in case of reti
//in case of reti
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) reti <= #1 1'b0;
  if (resetn == 1'b0) reti <= #1 1'b0;
  else if ((op1_o==`OC8051_RETI) & rd & !mem_wait) reti <= #1 1'b1;
  else if ((op1_o==`OC8051_RETI) & rd & !mem_wait) reti <= #1 1'b1;
  else reti <= #1 1'b0;
  else reti <= #1 1'b0;
 
 
//
//
// remember inputs
// remember inputs
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    op2_buff <= #1 8'h0;
    op2_buff <= #1 8'h0;
    op3_buff <= #1 8'h0;
    op3_buff <= #1 8'h0;
  end else if (rd) begin
  end else if (rd) begin
    op2_buff <= #1 op2_o;
    op2_buff <= #1 op2_o;
    op3_buff <= #1 op3_o;
    op3_buff <= #1 op3_o;
Line 752... Line 754...
end
end
 
 
 
 
assign inc_pc = ((op_pos[2] | (&op_pos[1:0])) & rd) | pc_wr_r2;
assign inc_pc = ((op_pos[2] | (&op_pos[1:0])) & rd) | pc_wr_r2;
 
 
always @(posedge rst or posedge clk)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    op_pos <= #1 3'h0;
    op_pos <= #1 3'h0;
  end else if (pc_wr_r2) begin
  end else if (pc_wr_r2) begin
    op_pos <= #1 3'h4;// - op_length;////****??????????
    op_pos <= #1 3'h4;// - op_length;////****??????????
  end else if (inc_pc & rd) begin
  end else if (inc_pc & rd) begin
    op_pos[2]   <= #1 op_pos[2] & !op_pos[1] & op_pos[0] & (&op_length);
    op_pos[2]   <= #1 op_pos[2] & !op_pos[1] & op_pos[0] & (&op_length);
Line 769... Line 771...
end
end
 
 
//
//
// remember interrupt
// remember interrupt
// we don't want to interrupt instruction in the middle of execution
// we don't want to interrupt instruction in the middle of execution
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
 if (rst) begin
 if (resetn == 1'b0) begin
   int_ack_t <= #1 1'b0;
   int_ack_t <= #1 1'b0;
   int_vec_buff <= #1 8'h00;
   int_vec_buff <= #1 8'h00;
 end else if (intr) begin
 end else if (intr) begin
   int_ack_t <= #1 1'b1;
   int_ack_t <= #1 1'b1;
   int_vec_buff <= #1 int_v;
   int_vec_buff <= #1 int_v;
 end else if (rd && (ea_rom_sel || iack_i) && !pc_wr_r2) int_ack_t <= #1 1'b0;
 end else if (rd && (ea_rom_sel || iack_i) && !pc_wr_r2) int_ack_t <= #1 1'b0;
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) int_ack_buff <= #1 1'b0;
  if (resetn == 1'b0) int_ack_buff <= #1 1'b0;
  else int_ack_buff <= #1 int_ack_t;
  else int_ack_buff <= #1 int_ack_t;
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) int_ack <= #1 1'b0;
  if (resetn == 1'b0) int_ack <= #1 1'b0;
  else begin
  else begin
    if ((int_ack_buff) & !(int_ack_t))
    if ((int_ack_buff) & !(int_ack_t))
      int_ack <= #1 1'b1;
      int_ack <= #1 1'b1;
    else int_ack <= #1 1'b0;
    else int_ack <= #1 1'b0;
  end
  end
 
 
 
 
//
//
//interrupt buffer
//interrupt buffer
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) begin
  if (resetn == 1'b0) begin
    int_buff1 <= #1 1'b0;
    int_buff1 <= #1 1'b0;
  end else begin
  end else begin
    int_buff1 <= #1 int_buff;
    int_buff1 <= #1 int_buff;
  end
  end
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) begin
  if (resetn == 1'b0) begin
    int_buff <= #1 1'b0;
    int_buff <= #1 1'b0;
  end else if (intr) begin
  end else if (intr) begin
    int_buff <= #1 1'b1;
    int_buff <= #1 1'b1;
  end else if (pc_wait)
  end else if (pc_wait)
    int_buff <= #1 1'b0;
    int_buff <= #1 1'b0;
Line 823... Line 825...
    pcs_result[15:8] = pc[15:8] - {7'h0, !pcs_cy};
    pcs_result[15:8] = pc[15:8] - {7'h0, !pcs_cy};
  end else pcs_result = pc + {8'h00, pcs_source};
  end else pcs_result = pc + {8'h00, pcs_source};
end
end
 
 
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst)
  if (resetn == 1'b0)
    pc <= #1 16'h0;
    pc <= #1 16'h0;
  else if (pc_wr_r2)
  else if (pc_wr_r2)
    pc <= #1 pc_buf;
    pc <= #1 pc_buf;
  else if (rd & !int_ack_t)
  else if (rd & !int_ack_t)
    pc <= #1 pc_buf - 16'h8 + {13'h0, op_pos} + {14'h0, op_length};
    pc <= #1 pc_buf - 16'h8 + {13'h0, op_pos} + {14'h0, op_length};
end
end
 
 
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
begin
begin
  if (rst) begin
  if (resetn == 1'b0) begin
    pc_buf <= #1 `OC8051_RST_PC;
    pc_buf <= #1 `OC8051_RST_PC;
  end else if (pc_wr) begin
  end else if (pc_wr) begin
//
//
//case of writing new value to pc (jupms)
//case of writing new value to pc (jupms)
      case (pc_wr_sel) /* synopsys full_case parallel_case */
      case (pc_wr_sel) /* synopsys full_case parallel_case */
Line 866... Line 868...
 
 
 
 
 
 
 
 
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst)
  if (resetn == 1'b0)
    ddat_ir <= #1 8'h00;
    ddat_ir <= #1 8'h00;
  else if (dack_i)
  else if (dack_i)
    ddat_ir <= #1 ddat_i;
    ddat_ir <= #1 ddat_i;
 
 
 
 
////////////////////////
////////////////////////
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) begin
  if (resetn == 1'b0) begin
    rn_r      <= #1 5'd0;
    rn_r      <= #1 5'd0;
    ri_r      <= #1 8'h00;
    ri_r      <= #1 8'h00;
    imm_r     <= #1 8'h00;
    imm_r     <= #1 8'h00;
    imm2_r    <= #1 8'h00;
    imm2_r    <= #1 8'h00;
    rd_addr_r <= #1 1'b0;
    rd_addr_r <= #1 1'b0;
Line 899... Line 901...
    sp_r      <= #1 sp;
    sp_r      <= #1 sp;
    pc_wr_r   <= #1 pc_wr && (pc_wr_sel != `OC8051_PIS_AH);
    pc_wr_r   <= #1 pc_wr && (pc_wr_sel != `OC8051_PIS_AH);
    pc_wr_r2  <= #1 pc_wr_r;
    pc_wr_r2  <= #1 pc_wr_r;
  end
  end
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or negedge resetn)
  if (rst) begin
  if (resetn == 1'b0) begin
    inc_pc_r  <= #1 1'b1;
    inc_pc_r  <= #1 1'b1;
  end else if (istb) begin
  end else if (istb) begin
    inc_pc_r  <= #1 inc_pc;
    inc_pc_r  <= #1 inc_pc;
  end
  end
 
 
`ifdef OC8051_SIMULATION
`ifdef OC8051_SIMULATION
 
 
initial
initial
begin
begin
  wait (!rst)
  wait (!resetn)
  if (ea_rom_sel) begin
  if (ea_rom_sel) begin
    $display(" ");
    $display(" ");
    $display("\t Program running from internal rom !");
    $display("\t Program running from internal rom !");
    $display(" ");
    $display(" ");
  end else begin
  end else begin

powered by: WebSVN 2.1.0

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