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

Subversion Repositories oms8051mini

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

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

powered by: WebSVN 2.1.0

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