Sunteți pe pagina 1din 3

In a car security System we usually wants to connect the Siren in such a way that a siren will come on when

it is triggered by one or more sensor or inputs.In addition there will be a master switch to turn on or off the system. Let us suppose that there is 1>Car door switch D. 2>Vibration Detector switch V and 3> Master Switch M We will use the convention that when the door is opened D=1,otherwise D=0.Similarly,when the car is being shaken,V=1,but this only the system is turned on, that is M=1.When M=0 as in when we are entering the car or when we are driving ,we dont want the siren to come on

Design Code
module Security( input M_Master,//When the System is ON input D_Door, input V_Vibration, output S_Siren );

assign S_Siren= M_Master & ( D_Door | V_Vibration); endmodule

Testbench Code
module Security_TB; // Inputs reg M_Master; reg D_Door; reg V_Vibration; // Outputs wire S_Siren; // Instantiate the Unit Under Test (UUT) Security uut ( .M_Master(M_Master), .D_Door(D_Door), .V_Vibration(V_Vibration), .S_Siren(S_Siren) );

// Add stimulus here initial begin

// Add stimulus here

M_Master = 1; D_Door = 0; V_Vibration = 1; #100; M_Master = 1; D_Door = 1; V_Vibration = 0; #100; M_Master = 1; D_Door = 1; V_Vibration = 1; #800; M_Master = 0; D_Door = 1; V_Vibration = 1; #100;

end endmodule

S-ar putea să vă placă și