OpenCores
URL https://opencores.org/ocsvn/6809_6309_compatible_core/6809_6309_compatible_core/trunk

Subversion Repositories 6809_6309_compatible_core

[/] [6809_6309_compatible_core/] [trunk/] [rtl/] [verilog/] [alu16.v] - Diff between revs 9 and 10

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

Rev 9 Rev 10
Line 92... Line 92...
        output reg carry_out,
        output reg carry_out,
        output reg overflow_out,
        output reg overflow_out,
        output reg half_c_out
        output reg half_c_out
        );
        );
 
 
 
wire carry;
 
assign carry = opcode_in[1] ? carry_in:1'b0;
 
 
always @(*)
always @(*)
        begin
        begin
                case (opcode_in)
                case (opcode_in[0])
                        2'b00: { carry_out, q_out } = { 1'b0, a_in } + { 1'b0, b_in }; // ADD
                        1'b0: { carry_out, q_out } = { 1'b0, a_in } + { 1'b0, b_in } + { 8'h0, carry }; // ADD/ADC
                        2'b01: { carry_out, q_out } = { 1'b0, a_in } - { 1'b0, b_in }; // SUB
                        1'b1: { carry_out, q_out } = { 1'b0, a_in } - { 1'b0, b_in } - { 8'h0, carry }; // SUB/SBC
                        2'b10: { carry_out, q_out } = { 1'b0, a_in } + { 1'b0, b_in } + { 8'h0, carry_in }; // ADC
 
                        2'b11: { carry_out, q_out } = { 1'b0, a_in } - { 1'b0, b_in } - { 8'h0, carry_in }; // SBC
 
                endcase
                endcase
        end
        end
 
 
always @(*)
always @(*)
        begin
        begin
                case (opcode_in)
                case (opcode_in[0])
                        2'b00, 2'b10: overflow_out = (a_in[7] & b_in[7] & (~q_out[7])) | ((~a_in[7]) & (~b_in[7]) & q_out[7]);
                        1'b0: overflow_out = (a_in[7] & b_in[7] & (~q_out[7])) | ((~a_in[7]) & (~b_in[7]) & q_out[7]);
                        2'b01, 2'b11: overflow_out = (a_in[7] & (~b_in[7]) & (~q_out[7])) | ((~a_in[7]) & b_in[7] & q_out[7]);
                        1'b1: overflow_out = (a_in[7] & (~b_in[7]) & (~q_out[7])) | ((~a_in[7]) & b_in[7] & q_out[7]);
                endcase
                endcase
        end
        end
 
 
always @(*)
always @(*)
        begin
        begin
                case (opcode_in)
                case (opcode_in[0])
                        2'b00, 2'b10: half_c_out = (a_in[3] & b_in[3] & (~q_out[3])) | ((~a_in[3]) & (~b_in[3]) & q_out[3]);
                        1'b0: half_c_out = (a_in[3] & b_in[3] & (~q_out[3])) | ((~a_in[3]) & (~b_in[3]) & q_out[3]);
                        2'b01, 2'b11: half_c_out = half_c_in;
                        1'b1: half_c_out = half_c_in;
                endcase
                endcase
        end
        end
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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