Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

multi3

  • Loading branch information...
commit 9ef99c48e80282f9accce2da5531e7a985dcaa59 1 parent d5554b4
godspeed1989 authored October 04, 2012

Showing 1 changed file with 26 additions and 3 deletions. Show diff stats Hide diff stats

  1. 29  multi3.v
29  multi3.v
... ...
@@ -1,10 +1,33 @@
1 1
 
2  
-module multi3();
3  
-
  2
+module multi3_tb();
  3
+	reg [2:0] p1;
  4
+	reg [2:0] p2;
  5
+	wire [4:0] result;
  6
+initial begin
  7
+	$dumpfile("multi3.vcd");
  8
+	$dumpvars();
  9
+	p1 <= 0;
  10
+	p2 <= 0;
  11
+end
  12
+	multi3 mult(p1, p2, result);
  13
+initial begin
  14
+	#2 p1= 3'b11;	p2= 3'b10;
  15
+	#2 p1=-3'b01;	p2= 3'b10;
  16
+	#2 p1= 3'b10;	p2=-3'b10;
  17
+	#2 p1=-3'b11;	p2= 3'b11;
  18
+	#2 p1=-3'b11;	p2= 3'b00;
  19
+	#5 $finish();
  20
+end
4 21
 endmodule
5 22
 
6 23
 module multi3(p1, p2, result);
7  
-	input [2:0] p1;
  24
+	input [2:0] p1; //最高位是符号位
8 25
 	input [2:0] p2;
  26
+	output reg [4:0] result;
9 27
 
  28
+always @ (*)
  29
+begin
  30
+	result = p1[1:0] * p2[1:0];
  31
+	result[4] = p1[2] ^ p2[2];
  32
+end
10 33
 endmodule

0 notes on commit 9ef99c4

Please sign in to comment.
Something went wrong with that request. Please try again.