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
HDL 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
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
The post HDL code to simulate 4-bit binary to gray converter appeared first on Techgeetam.com.