• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Always block

I am new to Lucid programming and i am testing different codes. (even though the build takes time)

I took the alchitry example with serial communication. One letter in and some code to send back the feed to the serial monitor.

In my example, the feedback is in the Always block. So here is the code i wrote in the always block.

always {
    reset_cond.in = ~rst_n; // input raw inverted reset signal
    rst = reset_cond.out;   // conditioned reset
    rx.rx = usb_rx;         // connect rx input
    usb_tx = tx.tx;         // connect tx output
    tx.new_data = rx.new_data;
    tx.data = rx.data + 1;
    tx.data = rx.data;         
    tx.block = 0;

What i am trying to do is "just" to send back 2 letters to the serial monitor, the original one (the user input) and one with the letter plus one. But i understood that the last line take preference in the always bloc, so the second line gets returned. The question how do i do that, so 2 letters is returned on input - move it out of the always block, but how?.

Next additional question would be the notion of a module, can that in other programming languages be considered as a procedure/function?


Henrik Smile
Hey Henrik,

For this you'll have to introduce some kind of state machine. See https://alchitry.com/roms-and-fsms

Forum Jump:

Users browsing this thread: 1 Guest(s)