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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_multiply.v] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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