3
3ashmawy
Guest
Hello,
I am trying to write a BCD-Excess3 converter in Behavioral Model. By
Adding 3 to Each Input And Printing the Output.Anyways Here is my
Code.
module Exess3 (In,Out);
input [0:3]In;
output [0:3]Out;
reg [0:3]Out;
always @ (In)
Out = In + 1'd3;
endmodule
module Sim;
reg [0:3]D;
wire [0:3]S;
Exess3 Exess3Sim(D,S);
initial
begin
D = 4'b0000;
repeat(9)
#20 D = D + 1'b1;
end
initial
$monitor ("ABCD = %b w = %b x = %b y = %b z =
%b",D,S[0],S[1],S[2],S[3]);
endmodule
The Output is :
ABCD = 0000 w = 0 x = 0 y = 0 z = 1
ABCD = 0001 w = 0 x = 0 y = 1 z = 0
ABCD = 0010 w = 0 x = 0 y = 1 z = 1
ABCD = 0011 w = 0 x = 1 y = 0 z = 0
ABCD = 0100 w = 0 x = 1 y = 0 z = 1
ABCD = 0101 w = 0 x = 1 y = 1 z = 0
ABCD = 0110 w = 0 x = 1 y = 1 z = 1
ABCD = 0111 w = 1 x = 0 y = 0 z = 0
ABCD = 1000 w = 1 x = 0 y = 0 z = 1
ABCD = 1001 w = 1 x = 0 y = 1 z = 0
The Output should be:
ABCD = 0000 w = 0 x = 0 y = 1 z = 1
ABCD = 0001 w = 0 x = 1 y = 0 z = 0
ABCD = 0010 w = 0 x = 1 y = 0 z = 1
ABCD = 0011 w = 0 x = 1 y = 1 z = 0
ABCD = 0100 w = 0 x = 1 y = 1 z = 1
ABCD = 0101 w = 1 x = 0 y = 0 z = 0
ABCD = 0110 w = 1 x = 0 y = 0 z = 1
ABCD = 0111 w = 1 x = 0 y = 1 z = 0
ABCD = 1000 w = 1 x = 0 y = 1 z = 1
ABCD = 1001 w = 1 x = 1 y = 0 z = 0
Thanx In Advance for any help,
3ashmawy
I am trying to write a BCD-Excess3 converter in Behavioral Model. By
Adding 3 to Each Input And Printing the Output.Anyways Here is my
Code.
module Exess3 (In,Out);
input [0:3]In;
output [0:3]Out;
reg [0:3]Out;
always @ (In)
Out = In + 1'd3;
endmodule
module Sim;
reg [0:3]D;
wire [0:3]S;
Exess3 Exess3Sim(D,S);
initial
begin
D = 4'b0000;
repeat(9)
#20 D = D + 1'b1;
end
initial
$monitor ("ABCD = %b w = %b x = %b y = %b z =
%b",D,S[0],S[1],S[2],S[3]);
endmodule
The Output is :
ABCD = 0000 w = 0 x = 0 y = 0 z = 1
ABCD = 0001 w = 0 x = 0 y = 1 z = 0
ABCD = 0010 w = 0 x = 0 y = 1 z = 1
ABCD = 0011 w = 0 x = 1 y = 0 z = 0
ABCD = 0100 w = 0 x = 1 y = 0 z = 1
ABCD = 0101 w = 0 x = 1 y = 1 z = 0
ABCD = 0110 w = 0 x = 1 y = 1 z = 1
ABCD = 0111 w = 1 x = 0 y = 0 z = 0
ABCD = 1000 w = 1 x = 0 y = 0 z = 1
ABCD = 1001 w = 1 x = 0 y = 1 z = 0
The Output should be:
ABCD = 0000 w = 0 x = 0 y = 1 z = 1
ABCD = 0001 w = 0 x = 1 y = 0 z = 0
ABCD = 0010 w = 0 x = 1 y = 0 z = 1
ABCD = 0011 w = 0 x = 1 y = 1 z = 0
ABCD = 0100 w = 0 x = 1 y = 1 z = 1
ABCD = 0101 w = 1 x = 0 y = 0 z = 0
ABCD = 0110 w = 1 x = 0 y = 0 z = 1
ABCD = 0111 w = 1 x = 0 y = 1 z = 0
ABCD = 1000 w = 1 x = 0 y = 1 z = 1
ABCD = 1001 w = 1 x = 1 y = 0 z = 0
Thanx In Advance for any help,
3ashmawy