Hello everyone. I'm new to Verilog. I want to convert a parallel data to serial, but without success. What are the bullshit and flaws in my code?
----- TOP------------------
`timescale 1ns / 1ps
module Serializer(
input wire clk,
input wire [7:0] in_data,
input wire valid_data,
output reg out_data
);
reg [7:0] temp_data;
always @(posedge clk)
begin
temp_data <= in_data;
if(valid_data == 1)
begin
temp_data <= {1'b0, temp_data[7:1]};
out_data <= temp_data[0];
end
end
endmodule
-----TESTBENCH-------------
`timescale 1ns / 1ps
module tb_serializer();
reg tb_clk = 1'b0;
reg [7:0] tb_in_data = 8'b01010011;
reg tb_valid_data =1'b1;
wire tb_out_data ;
//Clock
always begin
tb_clk = ~tb_clk;
#5;
end
//Testbench Connection
Serializer DUT(
.clk(tb_clk),
.in_data(tb_in_data),
.valid_data(tb_valid_data),
.out_data(tb_out_data)
);
//Serializer
initial begin
#200;
tb_in_data = 8'b11001111;
end
endmodule