Line 44... |
Line 44... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.11 2003/04/14 14:29:42 simont
|
|
// fiz bug iv pcs operation.
|
|
//
|
// Revision 1.10 2003/01/13 14:14:40 simont
|
// Revision 1.10 2003/01/13 14:14:40 simont
|
// replace some modules
|
// replace some modules
|
//
|
//
|
// Revision 1.9 2002/09/30 17:33:59 simont
|
// Revision 1.9 2002/09/30 17:33:59 simont
|
// prepared header
|
// prepared header
|
Line 60... |
Line 63... |
|
|
`include "oc8051_defines.v"
|
`include "oc8051_defines.v"
|
|
|
|
|
|
|
module oc8051_alu (clk, rst, op_code, rd, src1, src2, src3, srcCy, srcAc, bit_in, des1, des2, des1_r, desCy,
|
module oc8051_alu (clk, rst, op_code, src1, src2, src3, srcCy, srcAc, bit_in, des1, des2, desCy,
|
desAc, desOv);
|
desAc, desOv);
|
//
|
//
|
// op_code (in) operation code [oc8051_decoder.alu_op -r]
|
// op_code (in) operation code [oc8051_decoder.alu_op -r]
|
// src1 (in) first operand [oc8051_alu_src1_sel.des]
|
// src1 (in) first operand [oc8051_alu_src1_sel.des]
|
// src2 (in) second operand [oc8051_alu_src2_sel.des]
|
// src2 (in) second operand [oc8051_alu_src2_sel.des]
|
// src3 (in) third operand [oc8051_alu_src3_sel.des]
|
// src3 (in) third operand [oc8051_alu_src3_sel.des]
|
// srcCy (in) carry input [oc8051_cy_select.data_out]
|
// srcCy (in) carry input [oc8051_cy_select.data_out]
|
// srcAc (in) auxiliary carry input [oc8051_psw.data_out[6] ]
|
// srcAc (in) auxiliary carry input [oc8051_psw.data_out[6] ]
|
// bit_in (in) bit input, used for logic operatins on bits [oc8051_ram_sel.bit_out]
|
// bit_in (in) bit input, used for logic operatins on bits [oc8051_ram_sel.bit_out]
|
// des1 (out)
|
// des1 (out)
|
// des1_r (out)
|
|
// des2 (out)
|
// des2 (out)
|
// desCy (out) carry output [oc8051_ram_top.bit_data_in, oc8051_acc.bit_in, oc8051_b_register.bit_in, oc8051_psw.cy_in, oc8051_ports.bit_in]
|
// desCy (out) carry output [oc8051_ram_top.bit_data_in, oc8051_acc.bit_in, oc8051_b_register.bit_in, oc8051_psw.cy_in, oc8051_ports.bit_in]
|
// desAc (out) auxiliary carry output [oc8051_psw.ac_in]
|
// desAc (out) auxiliary carry output [oc8051_psw.ac_in]
|
// desOv (out) Overflow output [oc8051_psw.ov_in]
|
// desOv (out) Overflow output [oc8051_psw.ov_in]
|
//
|
//
|
|
|
input srcCy, srcAc, bit_in, clk, rst, rd;
|
input srcCy, srcAc, bit_in, clk, rst;
|
input [3:0] op_code;
|
input [3:0] op_code;
|
input [7:0] src1, src2, src3;
|
input [7:0] src1, src2, src3;
|
output desCy, desAc, desOv;
|
output desCy, desAc, desOv;
|
output [7:0] des1, des2;
|
output [7:0] des1, des2;
|
output [7:0] des1_r;
|
|
|
|
reg desCy, desAc, desOv;
|
reg desCy, desAc, desOv;
|
reg [7:0] des1, des2;
|
reg [7:0] des1, des2;
|
|
|
reg [7:0] des1_r;
|
|
|
|
|
|
reg rd_r;
|
|
//
|
//
|
//add
|
//add
|
//
|
//
|
wire [4:0] add1, add2, add3, add4;
|
wire [4:0] add1, add2, add3, add4;
|
wire [3:0] add5, add6, add7, add8;
|
wire [3:0] add5, add6, add7, add8;
|
Line 310... |
Line 308... |
desOv = 1'b0;
|
desOv = 1'b0;
|
enable_mul = 1'b0;
|
enable_mul = 1'b0;
|
enable_div = 1'b0;
|
enable_div = 1'b0;
|
end
|
end
|
//operation pcs Add
|
//operation pcs Add
|
`OC8051_ALU_PCS: begin
|
/* `OC8051_ALU_PCS: begin
|
if (src1[7]) begin
|
if (src1[7]) begin
|
{desCy, des1} = {1'b0, src2} + {1'b0, src1};
|
{desCy, des1} = {1'b0, src2} + {1'b0, src1};
|
des2 = {1'b0, src3} - {8'h0, !desCy};
|
des2 = {1'b0, src3} - {8'h0, !desCy};
|
end else {des2, des1} = {src3,src2} + {8'h00, src1};
|
end else {des2, des1} = {src3,src2} + {8'h00, src1};
|
desCy = 1'b0;
|
desCy = 1'b0;
|
desAc = 1'b0;
|
desAc = 1'b0;
|
desOv = 1'b0;
|
desOv = 1'b0;
|
enable_mul = 1'b0;
|
enable_mul = 1'b0;
|
enable_div = 1'b0;
|
enable_div = 1'b0;
|
end
|
end*/
|
//operation exchange
|
//operation exchange
|
//if carry = 0 exchange low order digit
|
//if carry = 0 exchange low order digit
|
`OC8051_ALU_XCH: begin
|
`OC8051_ALU_XCH: begin
|
if (srcCy)
|
if (srcCy)
|
begin
|
begin
|
Line 350... |
Line 348... |
enable_div = 1'b0;
|
enable_div = 1'b0;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
|
|
always @(posedge clk or posedge rst)
|
|
if (rst) begin
|
|
des1_r <= #1 8'h0;
|
|
end else if (rd_r) begin
|
|
des1_r <= #1 des1;
|
|
end
|
|
|
|
always @(posedge clk or posedge rst)
|
|
if (rst) begin
|
|
rd_r <= #1 8'h0;
|
|
end else begin
|
|
rd_r <= #1 rd;
|
|
end
|
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|