Forum Discussion
Altera_Forum
Honored Contributor
15 years agoThanks akira,
Did I still need to put BCD coding in this program? Can you help me to check the either my program is correct or not...Thanks again :) module calculator (x,y,outadd,outmul, add,mul,clk,a,b,c,d,e,f,g,dot);
input signed [4:0] x, y ;
input add , mul;
input clk;
output reg [5:0] outadd;
output reg [9:0] outmul;
output reg [4:0] a,b,c,d,e,f,g,dot;
always @ (posedge clk)
begin
if (add)
outadd <= x + y;
case ( outadd )
0:
begin
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
f = 0;
g = 1;
dot = 1;
end
1:
begin
a = 1;
b = 1;
c = 1;
d = 1;
e = 1;
f = 1;
g = 0;
dot = 0;
end
endcase
begin
if (mul)
outmul <= x * y;
case ( mul )
0:
begin
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
f = 0;
g = 1;
dot = 1;
end
1:
begin
a = 1;
b = 1;
c = 1;
d = 1;
e = 1;
f = 1;
g = 0;
end
endcase
end
end
endmodule