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

Subversion Repositories 8051

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

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

Line No. Rev Author Line
1 2 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 4 markom
//// - Marko Mlinar, markom@opencores.org                         ////
17 2 simont
////                                                              ////
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
// ver: 1
46
//
47 4 markom
// ver: 2 markom
48
// changed to two cycle multiplication, to save resources and
49
// increase speed
50 2 simont
 
51
// synopsys translate_off
52
`include "oc8051_timescale.v"
53
// synopsys translate_on
54
 
55
 
56 4 markom
module oc8051_multiply (clk, rst, enable, src1, src2, des1, des2, desOv);
57 2 simont
//
58
// this module is part of alu
59 4 markom
// clk          (in)
60
// rst          (in)
61
// enable       (in)
62 2 simont
// src1         (in)  first operand
63
// src2         (in)  second operand
64
// des1         (out) first result
65
// des2         (out) second result
66
// desOv        (out) Overflow output
67
//
68
 
69 4 markom
input clk, rst, enable;
70 2 simont
input [7:0] src1, src2;
71
output desOv;
72
output [7:0] des1, des2;
73
 
74 4 markom
// wires
75
wire [15:0] mul_result1, mul_result;
76
 
77
// real registers
78
reg cycle;
79
reg [11:0] tmp_mul;
80
 
81
assign mul_result1 = src1 * (cycle ? src2[7:4] : src2[3:0]);
82
assign mul_result = mul_result1 + tmp_mul;
83
assign des1 = mul_result[7:0];
84
assign des2 = mul_result[15:8];
85
assign desOv = des2 != 8'h0;
86
 
87
always @(posedge clk or posedge rst)
88 2 simont
begin
89 4 markom
  if (rst) cycle <= #1 1'b0;
90
  else begin
91
    if (enable && !cycle) cycle <= #1 1'b1;
92
    else cycle <= #1 1'b0;
93
    tmp_mul <= #1 mul_result1[11:0];
94
  end
95 2 simont
end
96
 
97
endmodule

powered by: WebSVN 2.1.0

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