|
3 | 3 |
|
4 | 4 | This is the Silice main documentation.
|
5 | 5 |
|
6 |
| -When designing with Silice your code describes circuits. If not done already, I recommended to [watch the introductory video](https://www.youtube.com/watch?v=_OhxEY72qxI) (youtube) to get more familiar with this notion and what it entails. The video is slightly outdated in terms of what Silice can do, but still useful when getting started. |
| 6 | +When designing with Silice your code describes circuits. If not done already, I recommended to [watch the introductory video](https://www.youtube.com/watch?v=_OhxEY72qxI) (youtube) to get more familiar with this notion and what it entails. The video is slightly outdated in terms of what Silice can do, but still useful when getting started. Another more recent video that focuses on graphics applications and showcases new capabilities is [here](https://www.youtube.com/watch?v=XycwTFPDZ6w). |
7 | 7 |
|
8 | 8 | ## Table of content
|
9 | 9 |
|
@@ -2420,6 +2420,57 @@ For practical usage examples please refer to the [*Getting started* guide](../Ge
|
2420 | 2420 |
|
2421 | 2421 | New frameworks for additional boards [can be easily created](../frameworks/boards/README.md).
|
2422 | 2422 |
|
| 2423 | +## Lua pre-processor in frameworks |
| 2424 | +
|
| 2425 | +Frameworks can 'escape' Verilog to add [Lua preprocessor](#lua-preprocessor) instructions. |
| 2426 | +Beware that this happens before the Verilog file is parsed, so the Verilog syntax |
| 2427 | +does not influence these pre-processor lines. This is particularly the case |
| 2428 | +for comments. |
| 2429 | +
|
| 2430 | +For instance, consider the following framework file: |
| 2431 | +
|
| 2432 | +``` verilog |
| 2433 | +// This is a Verilog framework 'glue' file |
| 2434 | +
|
| 2435 | +// Next some Verilog defines, these are only seen by the FPGA/ASIC/simulation |
| 2436 | +// toolchain in the final compiled file. |
| 2437 | +`define ICEBREAKER 1 |
| 2438 | +`define ICE40 1 |
| 2439 | +`default_nettype none |
| 2440 | +// Next some lines escaping to the Lua preprocessor, these lines are visible |
| 2441 | +// to Silice at compile time, but are oblivious to the surrounding Verilog code. |
| 2442 | +$$ICEBREAKER = 1 |
| 2443 | +$$ICE40 = 1 |
| 2444 | +$$HARDWARE = 1 |
| 2445 | +// For instance consider the following |
| 2446 | +/* |
| 2447 | +$$VAR1 = 1 |
| 2448 | +*/ |
| 2449 | +// The comment around the $$ escaped line is invisible to Silice, so VAR1 is |
| 2450 | +// indeed defined in Silice! |
| 2451 | +// This is also true of something like this: |
| 2452 | +`ifdef NOT_DEFINED |
| 2453 | +$$VAR2 = 1 |
| 2454 | +`endif |
| 2455 | +// The variable VAR2 will be defined as seen by the preprocessor, even though |
| 2456 | +// NOT_DEFINED is not defined in the Verilog part. Again the Lua preprocessor |
| 2457 | +// executes before Verilog is parsed by the toolchain. |
| 2458 | +
|
| 2459 | +// Here are several possible ways to resolve this: |
| 2460 | +// 1) Use a Lua comment |
| 2461 | +$$ -- VAR3 = 3 |
| 2462 | +// ^^ this is a comment in the preprocessor language (Lua), the line is ignored |
| 2463 | +// 2) Use preprocessor conditions to disable multiple lines |
| 2464 | +$$ if false then |
| 2465 | +$$ VAR4 = 4 |
| 2466 | +$$ VAR5 = 5 |
| 2467 | +$$ end |
| 2468 | +// ^^ here the definition of VAR3 is skipped |
| 2469 | +// 3) Use a single line comment, this is properly taken into account by the |
| 2470 | +// framework parser, for convenience. |
| 2471 | +// $$ VAR6 = 6 |
| 2472 | +``` |
| 2473 | +
|
2423 | 2474 | ## VGA and OLED simulation
|
2424 | 2475 |
|
2425 | 2476 | The Silice verilator framework supports VGA and OLED display out of the box. For instance see the [VGA demos project](../projects/vga_demo/README.md).
|
|
0 commit comments