HDL Code To Simulate 4-bit Binary To Gray Converter

By | November 29, 2017
Spread the love

HDL code to simulate 4-bit binary to gray converter

Aim- Simulate 4-bit binary to gray converter using HDL code.

Basics of 4-bit binary to gray converter

what is gray code?

A Gray Code represents binary encoded number constitutes a sequence of bits such that only one bit in the group changes from before and after.

To convert Binary to converter,

G3=B3, G2=B3^B2, G1=B2^B1, G0=B1^B0

Truth Table

simulate 4-bit binary to grayHDL Program to simulate 4-bit binary to gray converter

DOWNLOAD VERILOG PROGRAMS(SECURE DOWNLOAD)

Verilog Code

module bitogr(
input [3:0] b,
output [3:0] g);
assign g[3]=b[3];
assign g[2]=b[3]^b[2];
assign g[1]=b[2]^b[1];
assign g[0]=b[1]^b[0];
endmodule
Verilog Test Bench

module bitogr_tb;
reg [3:0] b;
wire [3:0] g;
bitogr uut (.b(b), .g(g) );
initial begin
b=0; #100;
b=1; #100;
b=2; #100;
b=3; #100;
b=4; #100;
b=5; #100;
b=6; #100;
b=7; #100;
b=8; #100;
b=9; #100;
b=10; #100;
b=11; #100;
b=12; #100;
b=13; #100;
b=14; #100;
b=15; #100;
endmodule
Output

simulate 4-bit binary to gray converter

 DOWNLOAD VERILOG PROGRAMS(SECURE DOWNLOAD)

Related Blogs

Basics of 4-bit binary to gray converter

Simulation of 4-bit binary to gray converter

HDL Programs

HDL code to simulate 4:1 Mux

HDL code to simulate 2:4 Decoder

HDL Code To Simulate All Logic Gates


Spread the love
Category: Electronics VHDL Lab Programming Tutorials Tags:

About Manojkumar M M

Manojkumar is a Digital Marketing Expert from Bangalore, India. He has got 3 years of experience in the field of Digital Marketing. He worked with many start-ups to help them in improving their Business Lead Generation through online. He blogs about digital marketing tips, technology updates, programming language tips at this blog Techgeetam.com. Contact me for any kind of help in the field of Digital Marketing. Mail Id - digimanoj98@gmail.com

Leave a Reply

Your email address will not be published.