Salil Vaidya
Newbie level 6
- Joined
- Feb 27, 2014
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 109
y
mrflibble ...i understand what you are saying...i also knw how to write case statement.bt my prob is inside case,i will hve to instantiate my individual modules ryt???how to do that???
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 module adder8bit( input [7:0] a, input [7:0] b, input cin, output [7:0] sum, output cout ); wire w1,w2,w3,w4,w5,w6,w7; adder1bit fa1(a[0],b[0],cin,sum[0],w1); adder1bit fa2(a[1],b[1],w1,sum[1],w2); adder1bit fa3(a[2],b[2],w2,sum[2],w3); adder1bit fa4(a[3],b[3],w3,sum[3],w4); adder1bit fa5(a[4],b[4],w4,sum[4],w5); adder1bit fa6(a[5],b[5],w5,sum[5],w6); adder1bit fa7(a[6],b[6],w6,sum[6],w7); adder1bit fa8(a[7],b[7],w7,sum[7],cout); endmodule
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 module adder8bit_tb; // Inputs reg [7:0] a; reg [7:0] b; reg cin; // Outputs wire [7:0] sum; wire cout; // Instantiate the Unit Under Test (UUT) adder8bit uut ( .a(a), .b(b), .cin(cin), .sum(sum), .cout(cout) ); initial begin // Initialize Inputs a = 0; b = 0; cin = 0; // Wait 100 ns for global reset to finish #100; a=8'b00110111; b=8'b10101100; cin=1'b1; // Add stimulus here end endmodule
can you please tell me syntax or post an example???
module half_adder (output s,c, input x,y); //1-bit half adder
xor(s,x,y);
and(c,x,y);
endmodule
module full_adder (output s,c, input x,y,cin); //1-bit full adder
wire s1,c1,c2;
half_adder ha1(s1,c1,x,y);
half_adder ha2(s,c2,s1,cin);
or d1 (c,c2,c1);
endmodule
module adder(output [3:0]s,output cout,input [3:0]a,input [3:0]b,input cin); //4-bit full adder
wire w1,w2,w3;
full_adder f1(s[0],w1,a[0],b[0],cin);
full_adder f2(s[1],w2,a[1],b[1],w1);
full_adder f3(s[2],w3,a[2],b[2],w2);
full_adder f4(s[3],cout,a[3],b[3],w3);
endmodule
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?