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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_multiply.v] - Blame information for rev 186

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// multiply for 8051 Core                                       ////
4
////                                                              ////
5
//// This file is part of the 8051 cores project                  ////
6
//// http://www.opencores.org/cores/8051/                         ////
7
////                                                              ////
8
//// Description                                                  ////
9
//// Implementation of multipication used in alu.v                ////
10
////                                                              ////
11
//// To Do:                                                       ////
12
////  Nothing                                                     ////
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Simon Teran, simont@opencores.org                          ////
16
//// - Marko Mlinar, markom@opencores.org                         ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE. See the GNU Lesser General Public License for more  ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.8  2002/09/30 17:33:59  simont
49
// prepared header
50
//
51
//
52
// ver: 2 markom
53
// changed to two cycle multiplication, to save resources and
54
// increase speed
55
//
56
// ver: 3 markom
57
// changed to four cycle multiplication, to save resources and
58
// increase speed
59
 
60
// synopsys translate_off
61
`include "oc8051_timescale.v"
62
// synopsys translate_on
63
 
64
 
65
module oc8051_multiply (clk, rst, enable, src1, src2, des1, des2, desOv);
66
//
67
// this module is part of alu
68
// clk          (in)
69
// rst          (in)
70
// enable       (in)
71
// src1         (in)  first operand
72
// src2         (in)  second operand
73
// des1         (out) first result
74
// des2         (out) second result
75
// desOv        (out) Overflow output
76
//
77
 
78
input clk, rst, enable;
79
input [7:0] src1, src2;
80
output desOv;
81
output [7:0] des1, des2;
82
 
83
// wires
84
wire [15:0] mul_result1, mul_result, shifted;
85
 
86
// real registers
87
reg [1:0] cycle;
88
reg [15:0] tmp_mul;
89
 
90
assign mul_result1 = src1 * (cycle == 2'h0 ? src2[7:6]
91
                           : cycle == 2'h1 ? src2[5:4]
92
                           : cycle == 2'h2 ? src2[3:2]
93
                           : src2[1:0]);
94
 
95
assign shifted = (cycle == 2'h0 ? 16'h0 : {tmp_mul[13:0], 2'b00});
96
assign mul_result = mul_result1 + shifted;
97
assign des1 = mul_result[15:8];
98
assign des2 = mul_result[7:0];
99
assign desOv = | des1;
100
 
101
always @(posedge clk or posedge rst)
102
begin
103
  if (rst) begin
104
    cycle <= #1 2'b0;
105
    tmp_mul <= #1 16'b0;
106
  end else begin
107
    if (enable) cycle <= #1 cycle + 2'b1;
108
    tmp_mul <= #1 mul_result;
109
  end
110
end
111
 
112
endmodule

powered by: WebSVN 2.1.0

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