Hi,
I'm trying to code a signed multiplier, and I used 'signed' for the ports and wire, but when I run (ModelSim) simulation to check it, it doesn't work for me.
Below is the code and the simple testbench. The numbers are the most positive (0xFF) * most negative (0x2000). In simulation, I get 0x1FE000, which is not the correct answer. Any idea?
The code:
========
Code Verilog - [expand] |
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
| module mult (one_a, dccfltro, multout);
input [7:0] one_a;
input signed [13:0] dccfltro;
output signed [22:0] multout;
wire signed [22:0] multout;
// one_a is unsigned, so treat is as positive
assign multout = dccfltro * {1'b0, one_a};
endmodule
Testbench:
=======
module mult_tb1 ();
wire signed [22:0] multout;
mult mult (
.dccfltro (14'h2000),
.one_a (8'hff),
.multout (multout)
);
endmodule |