For class, we are learning a little bit of Verilog and using ModelSim to code it in. I needed some assistance/guidance on how to code buses. I just can't seem to understand it fully. Basically, I have a 1-bit adder already coded:
Now, using this I want to create a 16-bit cascading adder. So for that, I have this so far:
***I have it set up so all the inputs on the adders are the same (a, b) and then the Carry-Out (cout) of each Adder feeds into the Carry-In of the next Adder.
My question is that how do I use/set up buses to finish the rest of this correctly?
**Would it be something like this:
This seems to me to be somewhat correct, but I feel I have something missing or something just not right about this.
Please guide me in the right direction and my apologizes for the long post.
Rich (BB code):
module Bit1Adder (x1, x2, cin, cout, sum);
input x1, x2, cin;
output cout, sum;
assign cout = ((x1 & x2) | (cin & (x1 ^ x2)));
assign sum = (x1 ^ x2) ^ cin;
endmodule
Rich (BB code):
`include 1BitAdder.v
module Adder16Bit
Bit1Adder Adder0 (a, b, cin, sum0, cout0);
Bit1Adder Adder1 (a, b, cout0, sum1, cout1);
Bit1Adder Adder2 (a, b, cout1, sum2, cout2);
Bit1Adder Adder3 (a, b, cout2, sum3, cout3);
Bit1Adder Adder4 (a, b, cout3, sum4, cout4);
Bit1Adder Adder5 (a, b, cout4, sum5, cout5);
Bit1Adder Adder6 (a, b, cout5, sum6, cout6);
Bit1Adder Adder7 (a, b, cout6, sum7, cout7);
Bit1Adder Adder8 (a, b, cout7, sum8, cout8);
Bit1Adder Adder9 (a, b, cout8, sum9, cout9);
Bit1Adder Adder10 (a, b, cout9, sum10, cout10);
Bit1Adder Adder11 (a, b, cout10, sum11, cout11);
Bit1Adder Adder12 (a, b, cout11, sum12, cout12);
Bit1Adder Adder13 (a, b, cout12, sum13, cout13);
Bit1Adder Adder14 (a, b, cout13, sum14, cout14);
Bit1Adder Adder15 (a, b, cout14, sum15, cout15);
My question is that how do I use/set up buses to finish the rest of this correctly?
**Would it be something like this:
Rich (BB code):
module Bit16Adder (a, b, cin, cout, sum);
input [15:0] a;
input [15:0] b;
input cin;
output [15:0] sum;
output cout;
Please guide me in the right direction and my apologizes for the long post.