差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
| eee:fpga:assignment [2026/08/15 12:53] – 移除 - 外部编辑 (未知日期) 127.0.0.1 | eee:fpga:assignment [2026/08/15 12:54] (当前版本) – 已恢复为旧版 (2026/08/15 12:53) xiaobenmao | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== Assignment ====== | ||
| + | |||
| + | There are 2 types of assignment: | ||
| + | |||
| + | * Blocking assignment '' | ||
| + | * Non-blocking assignment ''< | ||
| + | |||
| + | They have different Verilog simulation semantics, which affects how a hardware description behaves and can cause simulation results to differ from the intended synchronous hardware behavior. In simulator, blocking assignment behaves like the programming language, the first line complete first (and blocking the next line to execute), then is the second line. While the the non-blocking assignment get ready all new values first, and then update all together. | ||
| + | |||
| + | For example, considering below program | ||
| + | |||
| + | <code verilog top.v [enable_line_numbers=" | ||
| + | module top ( | ||
| + | input wire sw, | ||
| + | output wire led1, | ||
| + | output wire led2, | ||
| + | output wire led3 | ||
| + | // output wire led4 // no hardware available | ||
| + | ); | ||
| + | |||
| + | reg a; | ||
| + | reg b; | ||
| + | reg c; | ||
| + | reg d; | ||
| + | |||
| + | initial begin | ||
| + | a = 1; | ||
| + | b = 0; | ||
| + | c = 1; | ||
| + | d = 0; | ||
| + | end | ||
| + | |||
| + | always @ (posedge sw) begin | ||
| + | a = b; | ||
| + | b = a; | ||
| + | end | ||
| + | |||
| + | always @ (posedge sw) begin | ||
| + | c <= d; | ||
| + | d <= c; | ||
| + | end | ||
| + | |||
| + | assign led1 = a; | ||
| + | assign led2 = b; | ||
| + | assign led3 = c; | ||
| + | // assign led4 = d; // no hardware available | ||
| + | |||
| + | endmodule | ||
| + | </ | ||
| + | |||
| + | The pair '' | ||
| + | |||
| + | - a=1, b=0. Initial condition. | ||
| + | - a=0, b=0. When sentence '' | ||
| + | - a=0, b=0. When sentence '' | ||
| + | |||
| + | The pair '' | ||
| + | |||
| + | - c=1, d=0. Initial condition. | ||
| + | - c=1, d=0. c'=0, d'=1. Before '' | ||
| + | - c=0, d=1. Once at '' | ||
| + | |||