particleynamics
Newbie level 5
I am trying to add a signed and an unsigned number in verilog. Can someone tell me how to??
Am not able to do..
Am not able to do..
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
reg signed [31:0] result;
reg signed [31:0] operand1;
reg [15:0] operand2;
always [...] begin
...
result = operand1 + operand2;
...
end
C = $signed(A)
module top;
reg signed [31:0] operand1;
reg [15:0] operand2;
reg signed [31:0] result;
initial begin
operand1 = -1;
operand2 = 10;
result = operand1 + operand2;
$display(result,,operand1,, operand2);
end
endmodule
# 9 -1 10
module adder(
input wire signed [31:0] operand1,
input wire [15:0] operand2,
output reg signed [31:0] result
);
always @(operand1 or operand2)
result = operand1 + operand2;
endmodule
module top;
reg signed [31:0] op1;
reg [15:0] op2;
wire signed [31:0] result;
adder a1(op1,op2,result);
initial begin
op1 = -1;
op2 = 10;
#10
$display(result,,op1,,op2);
end
endmodule