Professional Documents
Culture Documents
BhagyasreeKV BRN46 Codingtest
BhagyasreeKV BRN46 Codingtest
BRN 46
CODING TEST
1. Write Verilog RTL code and TB to generate N bit gray code counter.
1.RTL CODE
module gray_code
# (parameter N = 4)
( input clk,
input rstn,
reg [N-1:0] q;
if (!rstn) begin
q <= 0;
out <= 0;
q <= q + 1;
`ifdef FOR_LOOP
end
`else
`endif
end
end
endmodule
2.Test Bench
module tb;
parameter N = 4;
reg clk;
reg rstn;
gray_ctr u0 ( .clk(clk),
.rstn(rstn),
.out(out));
initial begin
rstn <= 1;
$finish;
end
endmodule