File: x_multv2.v

package info (click to toggle)
vbs 1.4.0-9
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,200 kB
  • ctags: 4,401
  • sloc: cpp: 17,648; yacc: 1,880; ansic: 884; makefile: 419; sh: 375; lex: 345
file content (54 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Multiply module
 *  dependencies:
 *	register declaration
 *	io declaration
 *	always procedural block
 *	system tasks
 *	ifelse statement
 */
/*
 * Multiplier from Hennessy [94].  First iteration.
 */

module multiply (clk, prod, fin, mcand, mplier, reset);
	input clk, reset;
	output [63:0] prod;
	output fin;
	input [31:0] mcand, mplier;

	reg [63:0] prod;
	reg [7:0] working;
	reg fin;

	always @(posedge clk)
		begin
		if (reset == 1)
			begin
			fin = 0;
			prod = 0;
			working = 1;	// Start work on next clk!
			end
		else
			begin
			if (working == 1)
				begin
				// Make copies of the data.
				prod[31:0] = mplier;
				working = working + 1;
				end
			else if (working > 1)
				begin
				if (prod[0:0] == 1)
					prod[63:32] = prod[63:32] + mcand;
				prod = prod >> 1;

				// When are we finished?
				if (working > 32)
					fin = 1;
				working = working + 1;
				end
			end
		end

endmodule