My goal is coding a BCD adder in Verilog with gates. I have some issues:
1- How can I select bits from first "four bit adders" outputs. My sum is S
. After I used S
in first adder, can I select bits like S[0]
or is there another way?
2- How can I specify inputs, especially if I have a module for four_bit_adder
and it takes one element like A
(4 bits)? I tried to specify some bits, but I couldn't handle it.
For example, A[3]
and A[1]
needed to be 0 or 1 regarding the some situations, but my module takes one element.
My trial is below:
`include "four_bit_adder.v"
module bcd_adder(S,A,B,Cin);
input [3:0]A,B;
input Cin;
output [3:0]S;
wire [2:0]connectors;
//four_bit_adder(S,Cout,A,B,Cin);
four_bit_adder F_A1(S,Cout,A,B,Cin);
and(connectors[0],S[3],S[2]);
and(connectors[1],S[3],S[1]);
or(connectors[2],connectors[1],connectors[0],Cout);
//four_bit_adder F_A2();
endmodule