Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.8 2002/11/05 17:23:54 simont
|
|
// add module oc8051_sfr, 256 bytes internal ram
|
|
//
|
// Revision 1.7 2002/09/30 17:33:59 simont
|
// Revision 1.7 2002/09/30 17:33:59 simont
|
// prepared header
|
// prepared header
|
//
|
//
|
//
|
//
|
|
|
Line 54... |
Line 57... |
// synopsys translate_on
|
// synopsys translate_on
|
|
|
`include "oc8051_defines.v"
|
`include "oc8051_defines.v"
|
|
|
|
|
module oc8051_acc (clk, rst, bit_in, data_in, data2_in, wr, wr_bit, wad2, wr_addr, rd_addr,
|
module oc8051_acc (clk, rst, bit_in, data_in, data2_in, wr, wr_bit, wr_addr, rd_addr,
|
data_out, bit_out, p, rd_x, xdata);
|
data_out, bit_out, p, wr_sfr);
|
// clk (in) clock
|
// clk (in) clock
|
// rst (in) reset
|
// rst (in) reset
|
// bit_in (in) bit input - used in case of writing bits to acc (bit adddressable memory space - alu carry) [oc8051_alu.desCy]
|
// bit_in (in) bit input - used in case of writing bits to acc (bit adddressable memory space - alu carry) [oc8051_alu.desCy]
|
// data_in (in) data input - used to write to acc (from alu destiantion 1) [oc8051_alu.des1]
|
// data_in (in) data input - used to write to acc (from alu destiantion 1) [oc8051_alu.des1]
|
// data2_in (in) data 2 input - write to acc, from alu detination 2 - instuctions mul and div [oc8051_alu.des2]
|
// data2_in (in) data 2 input - write to acc, from alu detination 2 - instuctions mul and div [oc8051_alu.des2]
|
// wr (in) write - actine high [oc8051_decoder.wr -r]
|
// wr (in) write - actine high [oc8051_decoder.wr -r]
|
// wr_bit (in) write bit addresable - actine high [oc8051_decoder.bit_addr -r]
|
// wr_bit (in) write bit addresable - actine high [oc8051_decoder.bit_addr -r]
|
// wad2 (in) write data 2 [oc8051_decoder.wad2 -r]
|
|
// wr_addr (in) write address (if is addres of acc and white high must be written to acc) [oc8051_ram_wr_sel.out]
|
// wr_addr (in) write address (if is addres of acc and white high must be written to acc) [oc8051_ram_wr_sel.out]
|
// data_out (out) data output [oc8051_alu_src1_sel.acc oc8051_alu_src2_sel.acc oc8051_comp.acc oc8051_ram_sel.acc]
|
// data_out (out) data output [oc8051_alu_src1_sel.acc oc8051_alu_src2_sel.acc oc8051_comp.acc oc8051_ram_sel.acc]
|
// p (out) parity [oc8051_psw.p]
|
// p (out) parity [oc8051_psw.p]
|
// rd_x (in) read external
|
// mx_ext (in) mx extension
|
// xdata (in) external data input
|
// wr_sfr
|
//
|
//
|
|
|
|
|
input clk, rst, wr, wr_bit, wad2, bit_in, rd_x;
|
input clk, rst, wr, wr_bit, bit_in;
|
input [2:0] rd_addr;
|
input [2:0] rd_addr, wr_sfr;
|
input [7:0] wr_addr, data_in, data2_in, xdata;
|
input [7:0] wr_addr, data_in, data2_in;
|
|
|
output p, bit_out;
|
output p, bit_out;
|
output [7:0] data_out;
|
output [7:0] data_out;
|
|
|
reg [7:0] data_out;
|
reg [7:0] data_out;
|
Line 93... |
Line 95... |
//must check if write high and correct address
|
//must check if write high and correct address
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
data_out <= #1 `OC8051_RST_ACC;
|
data_out <= #1 `OC8051_RST_ACC;
|
else if (rd_x)
|
else if ((wr_sfr==`OC8051_WRS_ACC2) || (wr_sfr==`OC8051_WRS_BA))
|
data_out <= #1 xdata;
|
|
else if (wad2)
|
|
data_out <= #1 data2_in;
|
data_out <= #1 data2_in;
|
|
else if ((wr_sfr==`OC8051_WRS_ACC1))
|
|
data_out <= #1 data_in;
|
else if (wr) begin
|
else if (wr) begin
|
if (!wr_bit) begin
|
if (!wr_bit) begin
|
if (wr_addr==`OC8051_SFR_ACC)
|
if (wr_addr==`OC8051_SFR_ACC)
|
data_out <= #1 data_in;
|
data_out <= #1 data_in;
|
end else begin
|
end else begin
|
Line 113... |
Line 115... |
always @(posedge clk or posedge rst)
|
always @(posedge clk or posedge rst)
|
begin
|
begin
|
if (rst) bit_out <= #1 1'b0;
|
if (rst) bit_out <= #1 1'b0;
|
else if ((rd_addr==wr_addr[2:0]) & wr & wr_bit) begin
|
else if ((rd_addr==wr_addr[2:0]) & wr & wr_bit) begin
|
bit_out <= #1 bit_in;
|
bit_out <= #1 bit_in;
|
end else if ((wr_addr==`OC8051_SFR_ACC) & wr & !wr_bit) begin
|
end else if (((wr_addr==`OC8051_SFR_ACC) & wr & !wr_bit) || (wr_sfr==`OC8051_WRS_ACC1)) begin
|
bit_out <= #1 data_in[rd_addr];
|
bit_out <= #1 data_in[rd_addr];
|
|
end else if ((wr_sfr==`OC8051_WRS_ACC2) || (wr_sfr==`OC8051_WRS_BA)) begin
|
|
bit_out <= #1 data2_in[rd_addr];
|
end else bit_out <= #1 data_out[rd_addr];
|
end else bit_out <= #1 data_out[rd_addr];
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|