Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
PLS Verilog.pdf
Скачиваний:
18
Добавлен:
23.08.2013
Размер:
239.7 Кб
Скачать

Verilog

4.1.4. Repetitive or bit slice structure

When using always blocks, repetitive or bit slice structure can also be described using the "for" statement or the "repeat" statement. Figures 38a and 38b give an example of a 8 bits adder described with such statements.

The "for" statement is supported for constant bounds, stop test condition using operators <, <=, > or >= and next step computation falling in one of the following specifications: <var> = <var> + step or <var> = <var> - <step> (where <var> is the loop variable and <step> is a constant value).

The "repeat" statement is only supported for constant values.

module EXAMPLE ( A, B, CIN, SUM, COUT); input [0:7] A, B;

input CIN; output [0:7] SUM; output COUT; reg [0:7] SUM; reg COUT;

reg [0:8] C; integer I;

always @(A or B or CIN) begin

C[0] = CIN;

for (I = 0 ; I <= 7 ; I = I+1) begin

SUM[I] = A[I] ^ B[I] ^ C[I];

C[I+1] = (A[I]&B[I])|(A[I]&C[I])|(B[I]&C[I]); end

COUT = C[8];

end endmodule

Figure 38a: 8 bit adder described with a "for" statement

Verilog - 18

Соседние файлы в предмете Электротехника