Question

Write 3-bit Gray code using jk-flip flop in verilog (behavioral code)

write 3-bit Gray code using jk-flip flop in verilog (behavioral code)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
module gray_counter(clk, rst, out);
 input clk, rst;
 output reg [3:0] out;

 reg q0, q1, q2; 
 reg [3:0] count; 

 always @ (posedge clk)
 begin
  if (rst)
   count = 4'b0;
   out = 4'b0;
  else
   count = count + 1'b1;
   q2 = count[3] ^ count[2];
   q1 = count[2] ^ count[1];
   q0 = count[1] ^ count[0];
   out = {count[3], q2, q1, q0};
 end
endmodule

I have attached an image also for your better understanding. Feel free to ask in case of any doubts.

3 010 2 001 1000 10X Jo map map map 101 110 0201 9 100 0 0 I K, map

Add a comment
Know the answer?
Add Answer to:
Write 3-bit Gray code using jk-flip flop in verilog (behavioral code)
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
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