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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_indi_addr.v] - Diff between revs 46 and 82

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

Rev 46 Rev 82
Line 43... Line 43...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.4  2002/09/30 17:33:59  simont
 
// prepared header
 
//
//
//
 
 
// synopsys translate_off
// synopsys translate_off
`include "oc8051_timescale.v"
`include "oc8051_timescale.v"
// synopsys translate_on
// synopsys translate_on
 
 
 
 
module oc8051_indi_addr (clk, rst, addr, data_in, wr, wr_bit, data_out, sel, bank);
module oc8051_indi_addr (clk, rst, rd_addr, wr_addr, data_in, wr, wr_bit, rn_out, ri_out, sel, bank);
//
//
// clk          (in)  clock
// clk          (in)  clock
// rst          (in)  reset
// rst          (in)  reset
// addr         (in)  write address [oc8051_ram_wr_sel.out]
// addr         (in)  write address [oc8051_ram_wr_sel.out]
// data_in      (in)  data input (alu destination1) [oc8051_alu.des1]
// data_in      (in)  data input (alu destination1) [oc8051_alu.des1]
Line 64... Line 67...
// sel          (in)  select register [oc8051_op_select.op1_out[0] ]
// sel          (in)  select register [oc8051_op_select.op1_out[0] ]
// bank         (in)  select register bank: [oc8051_psw.data_out[4:3] ]
// bank         (in)  select register bank: [oc8051_psw.data_out[4:3] ]
//
//
 
 
 
 
input clk, rst, wr, sel, wr_bit;
input clk, rst, wr, wr_bit;
input [1:0] bank;
input [1:0] bank;
input [7:0] addr, data_in;
input [2:0] sel;
 
input [7:0] data_in;
 
input [7:0] rd_addr, wr_addr;
 
 
 
output [7:0] rn_out, ri_out;
 
 
output [7:0] data_out;
reg [7:0] rn_out;
 
 
reg [7:0] buff [7:0];
reg [7:0] buff [31:0];
 
reg wr_bit_r;
 
wire rd_ram, rd_ind;
 
 
 
 
 
wire tmp;
 
assign tmp = ~|wr_addr[7:5];
//
//
//write to buffer
//write to buffer
always @(posedge clk or posedge rst)
always @(posedge clk or posedge rst)
begin
begin
  if (rst) begin
  if (rst) begin
    buff[3'b000] = #1 8'h00;
    buff[0] <= #1 8'h00;
    buff[3'b001] = #1 8'h00;
    buff[1] <= #1 8'h00;
    buff[3'b010] = #1 8'h00;
    buff[2] <= #1 8'h00;
    buff[3'b011] = #1 8'h00;
    buff[3] <= #1 8'h00;
    buff[3'b100] = #1 8'h00;
    buff[4] <= #1 8'h00;
    buff[3'b101] = #1 8'h00;
    buff[5] <= #1 8'h00;
    buff[3'b110] = #1 8'h00;
    buff[6] <= #1 8'h00;
    buff[3'b111] = #1 8'h00;
    buff[7] <= #1 8'h00;
  end else begin
    buff[8] <= #1 8'h00;
    if ((wr) & !(wr_bit)) begin
    buff[9] <= #1 8'h00;
      case (addr)
    buff[10] <= #1 8'h00;
        8'h00: buff[3'b000] = #1 data_in;
    buff[11] <= #1 8'h00;
        8'h01: buff[3'b001] = #1 data_in;
    buff[12] <= #1 8'h00;
        8'h08: buff[3'b010] = #1 data_in;
    buff[13] <= #1 8'h00;
        8'h09: buff[3'b011] = #1 data_in;
    buff[14] <= #1 8'h00;
        8'h10: buff[3'b100] = #1 data_in;
    buff[15] <= #1 8'h00;
        8'h11: buff[3'b101] = #1 data_in;
    buff[16] <= #1 8'h00;
        8'h18: buff[3'b110] = #1 data_in;
    buff[17] <= #1 8'h00;
        8'h19: buff[3'b111] = #1 data_in;
    buff[18] <= #1 8'h00;
      endcase
    buff[19] <= #1 8'h00;
    end
    buff[20] <= #1 8'h00;
 
    buff[21] <= #1 8'h00;
 
    buff[22] <= #1 8'h00;
 
    buff[23] <= #1 8'h00;
 
    buff[24] <= #1 8'h00;
 
    buff[25] <= #1 8'h00;
 
    buff[26] <= #1 8'h00;
 
    buff[27] <= #1 8'h00;
 
    buff[28] <= #1 8'h00;
 
    buff[29] <= #1 8'h00;
 
    buff[30] <= #1 8'h00;
 
    buff[31] <= #1 8'h00;
 
  end else if ((wr) && !(wr_bit_r) && (tmp)) begin
 
    buff[wr_addr[4:0]] <= #1 data_in;
  end
  end
end
end
 
 
//
//
//read from buffer
//read from buffer
assign data_out = (({3'b000, bank, 2'b00, sel}==addr) & (wr)) ?
assign rd_ram = (rd_addr== wr_addr);
  data_in : buff[{bank, sel}];
assign rd_ind = ({3'h0, bank,  2'b00, sel[0]}==wr_addr);
 
assign ri_out = ( rd_ind & (wr) & !wr_bit) ? data_in : buff[{bank, 2'b00, sel[0]}];
 
 
 
always @(posedge clk or posedge rst)
 
  if (rst) begin
 
    rn_out <= #1 8'h00;
 
  end else if ( rd_ram & (wr) & !wr_bit) begin
 
    rn_out <= #1 data_in;
 
  end else begin
 
    rn_out <= #1 buff[rd_addr[4:0]];
 
  end
 
 
 
 
 
always @(posedge clk or posedge rst)
 
  if (rst) begin
 
    wr_bit_r <= #1 1'b0;
 
  end else begin
 
    wr_bit_r <= #1 wr_bit;
 
  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.