Question

VERILOG Three Minute Alarm A three minute alarm can constructed with two counters and two comparators....

VERILOG

Three Minute Alarm

A three minute alarm can constructed with two counters and two comparators. The counter's have an enable input that must be 1 for the count to increment. The counters can be set to 0 with the reset port. The counter for seconds is connected to a comparator that looks for 59. This comparator should be used to enable the minute counter, and reset the second's counter. The minute counter is connected to a comparator looking for 3. Use behavioural Verilog for the comparators. The comparator connected to the minute counter should drive the threemin net.

module counter #(parameter N=4) (
output logic [N-1:0] count,
input logic clk, enable, reset );

// complete using behaviour verilog
endmodule

module alarm(
output logic [1:0] minutes,
output logic [5:0] seconds,
output logic threemin,
input logic clk, reset );

// complete using counter

endmodule

0 0
Add a comment Improve this question Transcribed image text
Answer #1

module seconds_counter #(parameter N=6)(output [N-1:0] count, input clk, enable, reset);

reg [N-1:0] r;

initial begin

r <= 6'd0;

end

always @ (posedge clk, enable, reset)

begin

if (reset)

r <= 6'd0;

else

if (enable)

r <= r + 1'b1;

end

assign count = r;

endmodule

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

module minute_counter #(parameter N=2)(output [N-1:0] count, input clk, enable, reset);

reg [N-1:0] r;

initial begin

r <= 6'd0;

end

always @ (posedge clk, enable, reset)

begin

if (reset)

r <= 6'd0;

else

if (enable)

r <= r + 1'b1;

end

assign count = r;

endmodule

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

module alarm ( output [1:0] minutes,

output [5:0] seconds,

output threemin,

input clk,

input reset);

wire reset_s, enable_m;

seconds_counter u0 (seconds, clk, enable, reset_s);

minute_counter u1 (minutes, clk, enable_m, reset);

assign reset_s = (seconds == 6'd59) ? 1'b1 : 1'b0 ;

assign enable_m = reset_s;

assign threemin = (minutes == 2'd3) ? 1'b1 : 1'b0 ;

endmodule

//////////////////////////////////////////////////////////////////////////

File Edit View Add Fomat Tools Boolomarkcs Window Help Wave-Default Msgs 00001 St0 Stl alarm/dk 60 mjenable m ti 51139050 ps 5900 ps Cursor 1 15800 ps to 17800 ps slarmminutes O Type here to search wヨ 116/2018

Add a comment
Know the answer?
Add Answer to:
VERILOG Three Minute Alarm A three minute alarm can constructed with two counters and two comparators....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Register File Consider the following register file, that provide one write port and two read ports....

    Register File Consider the following register file, that provide one write port and two read ports. A register is updated on the positive edge on the clock if dw=1. Data is written to rd. The two read ports are: rn and rm. typedef logic [15:0] reg16_t; typedef logic [2:0] reg_sel_t; module reg_file( output reg16_t rn, rm, input reg16_t rd, input reg_sel_t n, m, d, input logic dw, reset, clk ); Use behavioural Verilog to implement reg_file. module reg_file( output reg16_t...

  • Im building a clock using HDL system verilog and I need help implementing this instantiation meth...

    Im building a clock using HDL system verilog and I need help implementing this instantiation method. Basically what happens is in the top module ClockCounter, positive clock edges are counted and passed into module timer using instantiation. Once the counter reaches MaxCount (59), a carry is generated which increments the minute clock. Once the minute clock reaches 59, another carry is generated which increments the hour clock. In module timer() below, I need help figuring out what variables in each...

  • Please explain what he verilog code does: module lab7_2_3( input clk, input Enable, input Clear, input...

    Please explain what he verilog code does: module lab7_2_3( input clk, input Enable, input Clear, input Load, output [3:0] Q, reg [3:0] count,      wire cnt_done );             assign cnt_done = ~| count;     assign Q = count;     always @(posedge clk)          if (Clear)              count <= 0;          else if (Enable)          if (Load | cnt_done)          count <= 4'b1010; // decimal 10          else          count <= count - 1; Endmodule

  • Can anyone solve this? i dont understand? verilog 1. (30 pts) Design a mod-6 counter. A...

    Can anyone solve this? i dont understand? verilog 1. (30 pts) Design a mod-6 counter. A mod-6 counter updates its output per clock rising edge according to the following sequence: 000, 001, 010, 011, 100, 101 (then repeat the pattern....). en is enable control (synchronous high active), resetn is reset control (asynchronous low active signal to reset counting sequence to 000) Complete the following Verilog code: en module mod6(clock, resetn, en, z); zI2:0] clock resetn Endmodule

  • How do I change these modules so that the communication is bidirectional (inout)? I'm simply not ...

    How do I change these modules so that the communication is bidirectional (inout)? I'm simply not sure how to modify the code. I know i need to add an inout port but I don't know how to do it. I have watched multiple tutorials but I can't figure it out. module mem( input logic clk, we , // write enable bit, active low input logic [n-1:0] in , input logic [m-1:0] addr , output logic [n-1:0] out ) ; parameter...

  • How do I change these modules so that the communication is bidirectional (inout)? I'm simply not...

    How do I change these modules so that the communication is bidirectional (inout)? I'm simply not sure how to modify the code. I know i need to add an inout port but I don't know how to do it. I have watched multiple tutorials but I can't figure it out. module mem( input logic clk, we , // write enable bit, active low input logic [n-1:0] in , input logic [m-1:0] addr , output logic [n-1:0] out ) ; parameter...

  • Consider the circuit in Figure 1. It is a 4-bit (QQ2Q3) synchronous counter which uses four T-typ...

    Consider the circuit in Figure 1. It is a 4-bit (QQ2Q3) synchronous counter which uses four T-type flip-flops. The counter increases its value on each positive edge of the clock if the Enable signal is asserted. The counter is reset to 0 by setting the Clear signal low. You are to implement an 8-bit counter of this type Enable T Q Clock Clear Figure 1. 4-bit synchronous counter (but you need to implement 8-bit counter in this lab) Specific notes:...

  • Problem: Design a clocked synchronous state machine with two inputs A, and B, and a single...

    Problem: Design a clocked synchronous state machine with two inputs A, and B, and a single output Z that is 1 is: .A had the same value at each of the two previous clock ticks, or B has been 1 since the last time that the first condition was true. In-Lab 1. 2. 3. 4. For the finite state machine (FSM), identify the minimum number of states required Draw the state transition diagram Complete the state transition table Derive the...

  • Given the following verilog code, draw the corresponding state diagram for it. module mysterious (input reset,...

    Given the following verilog code, draw the corresponding state diagram for it. module mysterious (input reset, clk, TB, TA, output reg [1:0] LB, LA); reg [1:0] cstate, nstate; parameter S0 = 2'b00; parameter S1 = 2'b01; parameter S2 = 2'b10; parameter S3 = 2'b11; parameter grn = 2'b00; parameter ylw = 2'b01; parameter rd = 2'b10; // state register always @ (posedge clk, posedge reset) begin if (reset) cstate <= S0; else cstate <= nstate; end // next state logic...

  • I need help writing a test bench for the following Verilog code module CU(IE, WE, WA,...

    I need help writing a test bench for the following Verilog code module CU(IE, WE, WA, RAE, RAA, RBE, RBA, ALU,                SH, OE, start, clk, reset, Ng5); //nG5 denotes (N>5);    input start, clk, reset;    output IE, WE, RAE, RBE, OE;    output [1:0] WA, RAA, RBA, SH;    output [2:0] ALU;       input wire Ng5;    reg [1:0] state;    reg [1:0] nextstate;    parameter S0 = 3'b000;    parameter S1 = 3'b001;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT