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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_multiply.v] - Diff between revs 2 and 4

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

Rev 2 Rev 4
Line 11... Line 11...
//// To Do:                                                       ////
//// To Do:                                                       ////
////  Nothing                                                     ////
////  Nothing                                                     ////
////                                                              ////
////                                                              ////
//// Author(s):                                                   ////
//// Author(s):                                                   ////
//// - Simon Teran, simont@opencores.org                          ////
//// - Simon Teran, simont@opencores.org                          ////
 
//// - Marko Mlinar, markom@opencores.org                         ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
Line 41... Line 42...
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// ver: 1
// ver: 1
//
//
 
// ver: 2 markom
 
// changed to two cycle multiplication, to save resources and
 
// increase speed
 
 
// synopsys translate_off
// synopsys translate_off
`include "oc8051_timescale.v"
`include "oc8051_timescale.v"
// synopsys translate_on
// synopsys translate_on
 
 
 
 
module oc8051_multiply (src1, src2, des1, des2, desOv);
module oc8051_multiply (clk, rst, enable, src1, src2, des1, des2, desOv);
//
//
// this module is part of alu
// this module is part of alu
 
// clk          (in)
 
// rst          (in)
 
// enable       (in)
// src1         (in)  first operand
// src1         (in)  first operand
// src2         (in)  second operand
// src2         (in)  second operand
// des1         (out) first result
// des1         (out) first result
// des2         (out) second result
// des2         (out) second result
// desOv        (out) Overflow output
// desOv        (out) Overflow output
//
//
 
 
 
input clk, rst, enable;
input [7:0] src1, src2;
input [7:0] src1, src2;
output desOv;
output desOv;
output [7:0] des1, des2;
output [7:0] des1, des2;
reg desOv; reg [7:0] des1, des2;
 
 
 
always @(src1 or src2)
// wires
 
wire [15:0] mul_result1, mul_result;
 
 
 
// real registers
 
reg cycle;
 
reg [11:0] tmp_mul;
 
 
 
assign mul_result1 = src1 * (cycle ? src2[7:4] : src2[3:0]);
 
assign mul_result = mul_result1 + tmp_mul;
 
assign des1 = mul_result[7:0];
 
assign des2 = mul_result[15:8];
 
assign desOv = des2 != 8'h0;
 
 
 
always @(posedge clk or posedge rst)
begin
begin
  {des2, des1} = src1* src2;
  if (rst) cycle <= #1 1'b0;
  if (des2!=8'b00000000)
  else begin
    desOv = 1'b1;
    if (enable && !cycle) cycle <= #1 1'b1;
  else
    else cycle <= #1 1'b0;
    desOv = 1'b0;
    tmp_mul <= #1 mul_result1[11:0];
 
  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.