Subscribe Us

Header Ads

Real Time alarm clock(Final)

go to part ---> part 1 part 2 part 3 part 4 part 5


Top Module





instantiate All module which we discuss earlier

RTL

//Top module alarm clock

 

 

module alarm_clock(clk,rst,fast_watch,alarm_button,time_button,key,sound_alarm,display_ms_hr,display_ms_min,display_ls_hr,display_ls_min);

 

input clk,rst,fast_watch,alarm_button,time_button;

input [3:0]key;

 

output [7:0]display_ms_hr,display_ms_min,display_ls_hr,display_ls_min;

output sound_alarm;

 

 

wire w1,w2,w3,w4,w5,w6,w7,w8;

wire [3:0]w10,w11,w12,w13,w14,w15,w16,w17,w18,w19,w20,w21;

 

TimingGen TG(clk,rst,w3,fast_watch,w1,w2);

controller AC(clk,rst,alarm_button,time_button,key,w2,w4,w5,w6,w7,w8,w3);

keyreg KR(clk,rst,key,w8,w10,w11,w12,w13);

counter Co(clk,rst,w1,w4,w10,w11,w12,w13,w14,w15,w16,w17);

alarmregister AR(clk,rst,w7,w10,w11,w12,w13,w18,w19,w20,w21);

displayDriver DD(w14,w16,w15,w17,w18,w20,w19,w21,w10,w12,w11,w13,w6,w5,sound_alarm,display_ms_hr,display_ms_min,display_ls_hr,display_ls_min);

 

endmodule

 

TEST BENCH

//alarm clocl test bench module alarm_clock_tb(); reg clk,rst,fast_watch,alarm_button,time_button; reg [3:0]key; wire sound_alarm; wire [7:0]display_ms_hr,display_ms_min,display_ls_hr,display_ls_min; alarm_clock AC(clk,rst,fast_watch,alarm_button,time_button,key,sound_alarm,display_ms_hr,display_ms_min,display_ls_hr,display_ls_min); initial begin clk=0; forever #5 clk=~clk; end task initialize(); begin {clk,rst,fast_watch,alarm_button,time_button,key}=0; end endtask task reset(); begin @(negedge clk) rst=1'b1; @(negedge clk) rst=1'b0; end endtask task fastW(input f); begin fast_watch=f; end endtask task a_button(input a); begin alarm_button=a; end endtask task t_button(input t); begin time_button=t; end endtask task Key(input [3:0]k); begin key=k; end endtask initial begin initialize; reset; fastW(1); Key(4'd0); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); Key(4'd9); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); Key(4'd3); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); Key(4'd0); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); t_button(1); @(negedge clk); t_button(0); //---------------------------------------------------------------------------------------------------------------- Key(4'd0); repeat(3) @(negedge clk); //9-30,09-40==10 min Key(4'd10); @(negedge clk); Key(4'd9); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); Key(4'd4); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); Key(4'd0); repeat(3) @(negedge clk); Key(4'd10); @(negedge clk); a_button(1); @(negedge clk); a_button(0); #(10*256*2); repeat(3000) @(negedge clk); $finish; end initial $monitor($time,"Input clk=%b,rst=%b,fast_watch=%b,alarm_button=%b,time_button=%b,key=%b Output display_ms_hr=%h,display_ms_min=%h,display_ls_hr=%h,display_ls_min=%h",clk,rst,fast_watch,alarm_button,time_button,key,sound_alarm,display_ms_hr,display_ms_min,display_ls_hr,display_ls_min); endmodule


--------------->Thank You Feel Free to comment your query and subscribe to our blog.

Post a Comment

1 Comments

  1. Amazing Blog!!! Keep writing blogs like this for our information, looking forward to read more blogs.

    Checkout complete details about B TECH Colleges in Noida with fee structure

    ReplyDelete