Line 28... |
Line 28... |
wire [3:0] ccr16_out;
|
wire [3:0] ccr16_out;
|
wire [15:0] q16_mul;
|
wire [15:0] q16_mul;
|
reg [15:0] ra_in, rb_in;
|
reg [15:0] ra_in, rb_in;
|
reg [4:0] rop_in;
|
reg [4:0] rop_in;
|
|
|
|
|
mul8x8 mulu(clk_in, a_in[7:0], b_in[7:0], q16_mul);
|
mul8x8 mulu(clk_in, a_in[7:0], b_in[7:0], q16_mul);
|
alu8 alu8(clk_in, ra_in[7:0], rb_in[7:0], CCR, rop_in, q8_out, ccr8_out);
|
alu8 alu8(clk_in, ra_in[7:0], rb_in[7:0], CCR, rop_in, q8_out, ccr8_out);
|
alu16 alu16(clk_in, ra_in, rb_in, CCR, rop_in, q16_mul, q16_out, ccr16_out);
|
alu16 alu16(clk_in, ra_in, rb_in, CCR, rop_in, q16_mul, q16_out, ccr16_out);
|
|
|
|
|
always @(posedge clk_in)
|
always @(posedge clk_in)
|
begin
|
begin
|
ra_in <= a_in;
|
ra_in <= a_in;
|
rb_in <= b_in;
|
rb_in <= b_in;
|
rop_in <= opcode_in;
|
rop_in <= opcode_in;
|
Line 242... |
Line 240... |
|
|
wire [7:0] logic_q, arith_q, shift_q;
|
wire [7:0] logic_q, arith_q, shift_q;
|
wire arith_c, arith_v, arith_h;
|
wire arith_c, arith_v, arith_h;
|
wire shift_c, shift_v;
|
wire shift_c, shift_v;
|
|
|
|
reg [7:0] alu8_b_in;
|
|
|
|
always @(*)
|
|
begin
|
|
alu8_b_in = b_in[7:0];
|
|
case (opcode_in)
|
|
`INC, `DEC: alu8_b_in = 8'h01;
|
|
`CLR: alu8_b_in = 8'h0;
|
|
endcase
|
|
end
|
|
|
logic8 l8(a_in, b_in, opcode_in[1:0], logic_q);
|
logic8 l8(a_in, b_in, opcode_in[1:0], logic_q);
|
arith8 a8(a_in, b_in, c_in, h_in, opcode_in[1:0], arith_q, arith_c, arith_v, arith_h);
|
arith8 a8(a_in, alu8_b_in, c_in, h_in, opcode_in[1:0], arith_q, arith_c, arith_v, arith_h);
|
shift8 s8(a_in, b_in, c_in, v_in, opcode_in[2:0], shift_q, shift_c, shift_v);
|
shift8 s8(a_in, b_in, c_in, v_in, opcode_in[2:0], shift_q, shift_c, shift_v);
|
// DAA
|
// DAA
|
assign daa_p0_r = ((a_in[3:0] > 4'h9) | h_in ) ? a_in[7:0] + 8'h6:a_in[7:0];
|
assign daa_p0_r = ((a_in[3:0] > 4'h9) | h_in ) ? a_in[7:0] + 8'h6:a_in[7:0];
|
assign { cdaa8_r, daa8h_r } = ((daa_p0_r[7:4] > 9) || (c_in == 1'b1)) ? { 1'b0, daa_p0_r[7:4] } + 5'h6:{ 1'b0, daa_p0_r[7:4] };
|
assign { cdaa8_r, daa8h_r } = ((daa_p0_r[7:4] > 9) || (c_in == 1'b1)) ? { 1'b0, daa_p0_r[7:4] } + 5'h6:{ 1'b0, daa_p0_r[7:4] };
|
|
|
Line 295... |
Line 304... |
`AND, `OR, `EOR, `LD:
|
`AND, `OR, `EOR, `LD:
|
begin
|
begin
|
q8 = logic_q;
|
q8 = logic_q;
|
v8 = 1'b0;
|
v8 = 1'b0;
|
end
|
end
|
|
`TST:
|
|
begin
|
|
q8 = a_in;
|
|
v8 = 1'b0;
|
|
end
|
`DAA:
|
`DAA:
|
begin // V is undefined, so we don't touch it
|
begin // V is undefined, so we don't touch it
|
q8 = { daa8h_r, daa_p0_r[3:0] };
|
q8 = { daa8h_r, daa_p0_r[3:0] };
|
c8 = cdaa8_r;
|
c8 = cdaa8_r;
|
end
|
end
|