- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may start defining your message array like this:
reg [7:0] message [29:0] Then you can use simple indexing to access each character. Moreover I would recommend using a clock and synchronous logic. Infact, always @* implies a purely combinatorial behaviour: this is usually not recommended, especially in your case which is basically a clock-driven process.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page