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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_multiply.v] - Diff between revs 21 and 25

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

Rev 21 Rev 25
Line 74... Line 74...
input [7:0] src1, src2;
input [7:0] src1, src2;
output desOv;
output desOv;
output [7:0] des1, des2;
output [7:0] des1, des2;
 
 
// wires
// wires
wire [15:0] mul_result1, mul_result;
wire [15:0] mul_result1, mul_result, shifted;
 
 
// real registers
// real registers
reg [1:0] cycle;
reg [1:0] cycle;
reg [13:0] tmp_mul;
reg [15:0] tmp_mul;
 
 
assign mul_result1 = src1 * (cycle == 0 ? src2[7:6]
assign mul_result1 = src1 * (cycle == 2'h0 ? src2[7:6]
                           : cycle == 1 ? src2[5:4]
                           : cycle == 2'h1 ? src2[5:4]
                           : cycle == 2 ? src2[3:2]
                           : cycle == 2'h2 ? src2[3:2]
                           : src2[1:0]);
                           : src2[1:0]);
 
assign shifted = (cycle == 2'h0 ? 16'h0 : {tmp_mul[13:0], 2'b00});
assign mul_result = mul_result1 + ({2'b0, tmp_mul} << {cycle, 1'b0});
assign mul_result = mul_result1 + shifted;
assign des1 = mul_result[7:0];
assign des1 = mul_result[15:8];
assign des2 = mul_result[15:8];
assign des2 = mul_result[7:0];
assign desOv = des2 != 8'h0;
assign desOv = src2 != 8'h0;
 
 
always @(posedge clk or posedge rst)
always @(posedge clk or posedge rst)
begin
begin
  if (rst) begin
  if (rst) begin
    cycle <= #1 1'b0;
    cycle <= #1 2'b0;
    tmp_mul <= #1 14'b0;
    tmp_mul <= #1 16'b0;
  end else begin
  end else begin
    if (enable || cycle != 0) cycle <= #1 cycle + 2'b1;
    if (enable) cycle <= #1 cycle + 2'b1;
    tmp_mul <= #1 mul_result[13:0];
    tmp_mul <= #1 mul_result;
  end
  end
end
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.