Altera_Forum
Honored Contributor
11 years agolooping over a string character by character in Verilog
I'm attempting to send a string character by character over a serial port. I have the serial port down, but I don't quite see how to implement a changing index on a string...
Ideally, my module would take as input a clock counter (synced to the baud rate of my serial module), and based on that clock input send out a character. Here's what I have so far, which works, but it seems like there is a much better way of doing it.module sendString(
input wire clockInput,
output TxD_start,
output TxD_buffer
);
reg message = "Help! I'm trapped in an FPGA!";
reg tmpbuffer;
always @*
begin
if(clockInput==5'b00000)
begin
tmpbuffer <= message;
end
if(clockInput==5'b00001)
begin
tmpbuffer <= message;
end
//and so on, for the other clock cases
end
assign TxD_buffer = tmpbuffer;
assign TxD_start = 1;
endmodule