Alchitry Forums
Trouble with shift opertor (<<) - Printable Version

+- Alchitry Forums (https://forum.alchitry.com)
+-- Forum: Alchitry (https://forum.alchitry.com/forum-1.html)
+--- Forum: General Questions (https://forum.alchitry.com/forum-2.html)
+--- Thread: Trouble with shift opertor (<<) (/thread-481.html)



Trouble with shift opertor (<<) - gln - 10-26-2022

I'm using the CU board with the iCEcube2 toolchain. I have connected the board LEDs to the "out" output of this minimal module. When I add to the value of "outbfr" I can see the LEDs count up by one once a second. When I comment out that line and leave the line with the left shift then no LEDs are illuminated. Pressing the reset button illuminates the LEDs in the 10101010 pattern as specified in the init value (so the connection and the physical LEDs are fine). Any ideas?

module foo (
    input clk,  // clock
    input rst,  // reset
    output out[8]
  ) {

  .clk(clk){
     .rst(rst){
        dff outbfr[8](#INIT(8b10101010));
        dff main_clock_count[$clog2(50000000)];
      }
  }
 
  always {
    out = outbfr.q;
    main_clock_count.d = main_clock_count.q + 1;
    if (main_clock_count.q == 50000000) {
      outbfr.d = outbfr.q + 1; // works
      outbfr.d = outbfr.q << 1; //doesn't
      main_clock_count.d = 0;
    }
  }
}