Posts

Showing posts with the label vending

verilog code for candy vending machine

Image
verilog code for candy vending machine hello friends.... I a m providing u verilog code for candy vending machine with test bench. CANDY MACHINE module candy ( d , n , q , reset , clk , y ) ; output reg y ; input d , n , q ; //n=5,d=10,q=25; input clk ; input reset ; reg [ 2 : 0 ] cst , nst ; parameter S0 = 3b000 , S1 = 3b001 , S2 = 3b010 , S3 = 3b100 , S4 = 3b101 , S5 = 3b110 , S6 = 3b111 ; always @( cst or d or n or q ) begin case ( cst ) S0 : if ( n== 1b1 && d== 1b0 && q== 1b0 ) begin nst = S1 ; y= 1b0 ; end else if ( n== 1b0 && d== 1b1 && q== 1b0 ) begin nst=S2 ; y= 1b0 ; end else if ( n== 1b0 && d== 1b0 && q== 1b1 ) begin nst=S5 ; y= 1b0 ; end else begin nst = cst ; y= 1b0 ; end S1 : if ( n== 1b1 && d== 1b0 && q== 1b0 ) begin nst = S2 ; y= 1b0 ; end else if ( n== 1b0 && d== 1b1 && q== 1b0 ) begin nst=S3 ; y= 1b0 ; end else if ( n=...