+/EE316
digital logic
git clone https://git.julia.blue/+/EE316
91885ad
master
1`timescale1 ns/ 1 ps 2 3module tb_cla ; 4reg [ 3 : 0 ] A , B ; 5reg enable ; 6reg clk ; 7reg Cin ; 8wire [ 4 : 0 ] Q ; 9 10CLA_4bits add_stuff ( 11. clk ( clk ), 12. enable ( enable ), 13. A ( A ), 14. B ( B ), 15. Cin ( Cin ), 16. Q ( Q ) 17); 18 19initial begin 20enable = 1 ; 21clk = 0 ; 22A = 0 ; B = 0 ; Cin = 0 ;# 50 ; 23$display ( "TC01" ); 24if ( Q != 0 ) $display ( "Result is wrong" ); 25 26A = 0 ; B = 5 ; Cin = 0 ; 27# 50 ; 28$display ( "TC02" ); 29if ( Q != 5 ) $display ( "Result is wrong" ); 30 31A = 5 ; B = 7 ; Cin = 0 ; 32# 50 ; 33$display ( "TC03" ); 34if ( Q != 12 ) $display ( "Result is wrong" ); 35 36A = 8 ; B = 7 ; Cin = 1 ; 37# 50 ; 38$display ( "TC04" ); 39if ( Q != 16 ) $display ( "Result is wrong" ); 40 41A = 9 ; B = 4 ; Cin = 0 ; 42# 50 ; 43$display ( "TC05" ); 44if ( Q != 13 ) $display ( "Result is wrong" ); 45 46A = 8 ; B = 8 ; Cin = 1 ; 47# 50 ; 48$display ( "TC06" ); 49if ( Q != 17 ) $display ( "Result is wrong" ); 50 51A = 13 ; B = 10 ; Cin = 1 ; 52# 50 ; 53$display ( "TC07" ); 54if ( Q != 24 ) $display ( "Result is wrong" ); 55 56A = 14 ; B = 15 ; Cin = 0 ; 57# 50 ; 58$display ( "TC08" ); 59if ( Q != 29 ) $display ( "Result is wrong" ); 60A = 0 ; B = 0 ; Cin = 0 ;# 50 ; 61end 62 63always 64# 5 clk = ~ clk ; 65 66 67endmodule