Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

5/2/2021 (B) Counter-Decoder Type Controllers Implement The... | Chegg.

com

  Textbook Solutions Expert Q&A Practice Study Pack 

Find solutions for your homework Search

home / study / engineering / electrical engineering / electrical engineering questions and answers / (b) counter-decoder type controllers impleme…

Question: (B) Counter-Decoder Type Controllers Implement the counter-… Post a question
Answers from our experts for your tough
homework questions
(1 bookmark)

RTL Verilog and Test Bench Enter question

Continue to post
9 questions remaining

Snap a photo from your


phone to post a question
We'll send you a one-time download
link

888-888-8888 Text me

By providing your phone number, you agree to receive a one-tim


automated text message with a link to get the app. Standard
messaging rates may apply.

My Textbook Solutions

Numerical... Numerical... Loose Leaf


for...
7th Edition 6th Edition 6th Edition

View all solutions

Show transcribed image text

Expert Answer

Anonymous answered this


Was this answer helpful? 0 0
573 answers

Verilog code:

//Verilog code
`timescale 1ns / 1ps

module RTL_FSM_VERILOG(
input clock,
input Stop,
output Out,

https://www.chegg.com/homework-help/questions-and-answers/b-counter-decoder-type-controllers-implement-counter-decoder-circuit-using-rtl-verilog… 1/4
5/2/2021 (B) Counter-Decoder Type Controllers Implement The... | Chegg.com
output [3:0] CountOut
 
); Textbook Solutions Expert Q&A Practice Study Pack 

//internal registers
//as we have 8 states , we need atleast 4 bits to store state value
reg [3:0] PS=4'd0; // PS => Present state, it is initialized to S0
wire [3:0] NS; //NS => Next

//D ip op for fsm


always @ (posedge clock)
PS <= NS;

//adder circuit => add's 1 to PS => PS1 = PS +1.


wire [3:0] PS1;
assign PS1 = PS + 4'd1;

//select NS based on Stop signal // 2 to 1 mux


assign NS = Stop ? PS : (PS == 4'd7) ? 4'd0: PS1;
// NS = PS when stop = 1
//else when stop = 0
// if PS = 7 then NS = 0.
// else NS = PS1

//output's
assign CountOut = PS; //state count
assign Out = ( PS == 4'b0010) ? 1'b1 : 1'b0; //Out = 1 only in state 2

endmodule
//code ends

test bench:

//Test bench
`timescale 1ns / 1ps

module TB_RTL_FSM_VERILOG();
reg clock;
reg Stop;
wire Out;
wire [3:0] CountOut;
//uut
RTL_FSM_VERILOG R1 (
.clock(clock),
.Stop(Stop),
.Out(Out),
.CountOut(CountOut)
);

//clock generation

initial begin
clock=1'b0; //50 MHz clock
forever #10 clock=!clock; //clock period=20ns
end

//stimulus

initial begin
Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
#15 Stop = 0;
#25 Stop = 1;
https://www.chegg.com/homework-help/questions-and-answers/b-counter-decoder-type-controllers-implement-counter-decoder-circuit-using-rtl-verilog… 2/4
5/2/2021 (B) Counter-Decoder Type Controllers Implement The... | Chegg.com
#15 Stop = 0;
 
#25 Stop = 1;
#15 Stop = 0;
Textbook Solutions Expert Q&A Practice Study Pack 

#20 $ nish;
end
endmodule
//test bench ends

//OUTPUT WAVEFORMS

***END

Make a comment in comment's section if you have any doubt.

please upvote if you are satis ed with the answer.

Comment


Up next for you in Electrical Engineering

RTL Verilog and Test Use LtSpice to get values


Bench

See more questions


for subjects you study

See answer See answer

Questions viewed by other students

Q: RTL Verilog, Verify circuit functionality Include design and test bench

A: See answer

Q: RTL Verilog and Test Bench

A: See answer 100% (1 rating)

Show more 

COMPANY

LEGAL & POLICIES

CHEGG PRODUCTS AND SERVICES

CHEGG NETWORK
https://www.chegg.com/homework-help/questions-and-answers/b-counter-decoder-type-controllers-implement-counter-decoder-circuit-using-rtl-verilog… 3/4
5/2/2021 (B) Counter-Decoder Type Controllers Implement The... | Chegg.com


CUSTOMERSERVICE Textbook Solutions Expert Q&A Practice Study Pack 

© 2003-2021 Chegg Inc. All rights reserved.

https://www.chegg.com/homework-help/questions-and-answers/b-counter-decoder-type-controllers-implement-counter-decoder-circuit-using-rtl-verilog… 4/4

You might also like