Question about Hello World serial demo

General discussion about the Mojo
blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Question about Hello World serial demo

Post by blark » November 1st, 2013, 5:50 pm

Hey guys,

if I wanted to print the status of some of the FPGA pins as 1 or 0 instead of hello world, what change would I have to make to the Hello World demo?

I've tried to set a test input on PIN 1 and then just assign it to one of the characters of the message_rom but it doesn't seem to work, I think I'm missing something.

Thanks!

yabapolido
Posts: 17
Joined: October 21st, 2013, 5:11 pm

Re: Question about Hello World serial demo

Post by yabapolido » November 3rd, 2013, 6:23 pm

Hi,
I'm also a newbie, but I think that you can loose the rom code, and have something like this in pseudo-code:

Code: Select all

reg [7:0] temp;

assign tx_data = temp;
 
always @(posedge clk) begin
  new_tx_data = 1'b0;
  if (!tx_busy && button_pressed) begin
   new_tx_data = 1'b1;
	temp <= 8'b00110001 (binary for number 1)
  end
end
I'm also learning and playing around Hello World :) Added a new state to the FSM and also print msg when reset is pressed.
Or... don't loose the rom code, and have only 2 bytes in it for 0 and 1.
You call either rom address based on the button status.

blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Re: Question about Hello World serial demo

Post by blark » November 4th, 2013, 12:15 pm

Thanks for the help! Interesting. So this isn't like C where True = 1 and False = 0?

Say if I wanted to only transfer 1 bit, I couldn't just change one of the ROM bits like this:

Code: Select all

module message_rom (
    input clk,
    input test,
    input [3:0] addr,
    output [7:0] data
);
 
wire [7:0] rom_data [13:0];
 
assign rom_data[0] = test;
...
this is what I was originally trying to do. Of course, with test defined in the constraints file.. but I wasn't getting any value when pulling the pin low or high.. I was expecting to see 1 or 0.

Thanks again!

yabapolido
Posts: 17
Joined: October 21st, 2013, 5:11 pm

Re: Question about Hello World serial demo

Post by yabapolido » November 4th, 2013, 3:32 pm

Hi blark,
tx_data and rx_data have 8 bits, I don't know if it is possible to send just one bit.
Check the LED + VB example here at the forum, that should help too.

blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Re: Question about Hello World serial demo

Post by blark » November 4th, 2013, 4:41 pm

Ahhhhhh. Thanks, that's the piece I was missing. I was trying to send 1 bit to an 8 bit ... wire? These names are still confusing me. Heh.

Ok, my end goal here is to read an 8 bit data bus when it changes (and settles) and then spit out the value to serial. Basically I want to monitor what's on the bus while single stepping a processor for debug purposes.

blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Re: Question about Hello World serial demo

Post by blark » November 5th, 2013, 11:17 pm

Another question:

So I have 16 bit address (bus that is attached to the Mojo), and I want to print it out to the serial terminal when a button is pressed.... I'd like to the flexibility to be able to print the binary address and the hex address...

Is there an easy way/accepted way to convert from a 16 bit wire to send this stuff out via serial? I have been thinking about it a bit, and I thought I could build a rom with a lookup table that is 16 bites, and feed it 4 bits at time to convert to hex... is there a better way to do this?

thanks

yabapolido
Posts: 17
Joined: October 21st, 2013, 5:11 pm

Re: Question about Hello World serial demo

Post by yabapolido » November 6th, 2013, 7:43 am

Hi blark,
I have the same problem and still trying to figure it out.
I think we need shift registers, or a vector, or ram.
The data above 8 bits must be stored somewhere right?
Let me know if you find a solution. I'm reading about serial to parallel shift registers in hope to learn something :)

blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Re: Question about Hello World serial demo

Post by blark » November 6th, 2013, 11:53 am

Ooohh.. hrm, this is for strings, check out:

http://www.asic-world.com/systemverilog ... ypes3.html

Specifically...

Code: Select all

atoi()

Returns integer value of the decimal represenation in ASCII string.

atohex()

Returns hex value of the hex represenation in ASCII string.
I wonder if that can be used somehow.

blark
Posts: 12
Joined: October 16th, 2013, 12:21 pm

Re: Question about Hello World serial demo

Post by blark » November 7th, 2013, 8:32 pm

Here's hoping the embedded micro folks read this.

Please, can you guys do an extension to the hello world demo that includes input? For example, "hello what's your name: ___" and then echo the name back?

This example would be very very useful.

thanks

yabapolido
Posts: 17
Joined: October 21st, 2013, 5:11 pm

Re: Question about Hello World serial demo

Post by yabapolido » November 8th, 2013, 4:39 am

blark wrote:Here's hoping the embedded micro folks read this.

Please, can you guys do an extension to the hello world demo that includes input? For example, "hello what's your name: ___" and then echo the name back?

This example would be very very useful.

thanks
+1 on that :)
I'm studying Pipistrello echo example, but my Verilog skills are still very low :(

Post Reply