Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let's say you have a LED matrix like this: <img src="https://i.stack.imgur.com/LHccj.png" alt="LED matrix schematic"></p> <p>To answer not your question, but your comment about " if u can at least show me how to make the blinking LED i will be grateful :)", we can do as this:</p> <pre><code>module blink (input wire clk, /* assuming a 50MHz clock in your trainer */ output wire anode, /* to be connected to RC7 */ output wire cathode); /* to be connected to RB7 */ reg [24:0] freqdiv = 25'h0000000; always @(posedge clk) freqdiv &lt;= freqdiv + 1; assign cathode = 1'b0; assign anode = freqdiv[24]; endmodule </code></pre> <p>This will make the top left LED to blink at a rate of 1,4 blinks per second aproximately.</p> <p>This other example will show a running dot across the matrix, left to right, top to down:</p> <pre><code>module runningdot (input wire clk, /* assuming a 50MHz clock in your trainer */ output wire [7:0] anodes, /* to be connected to RC0-7 */ output wire [7:0] cathodes); /* to be connected to RB0-7 */ reg [23:0] freqdiv = 24'h0000000; always @(posedge clk) freqdiv &lt;= freqdiv + 1; wire clkled = freqdiv[23]; reg [7:0] r_anodes = 8'b10000000; reg [7:0] r_cathodes = 8'b01111111; assign anodes = r_anodes; assign cathodes = r_cathodes; always @(posedge clkled) begin r_anodes &lt;= {r_anodes[0], r_anodes[7:1]}; /* shifts LED left to right */ if (r_anodes == 8'b00000001) /* when the last LED in a row is selected... */ r_cathodes &lt;= {r_cathodes[0], r_cathodes[7:1]}; /* ...go to the next row */ end endmodule </code></pre> <p>Your snake game, if using logic and not an embedded processor, is way much complicated than these examples, but it will use the same logic principles to drive the matrix.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload