Визуальная электроника

Именованные блоки

Блоки могут именоваться добавлением : имя_блока после ключевого слова begin. Именованные блоки могут быть запрещены использованием инструкции disable.

Пример ­ именованные блоки

Verilog Code:
  1. // This code find the lowest bit set
  2. module named_block_disable();
  3.  
  4. reg [31:0] bit_detect;
  5. reg [5:0] bit_position;
  6. integer i;
  7.  
  8. always @ (bit_detect)
  9. begin : BIT_DETECT
  10. for (i = 0; i < 32 ; i = i + 1) begin
  11. // If bit is set, latch the bit position
  12. // Disable the execution of the block
  13. if (bit_detect[i] == 1) begin
  14. bit_position = i;
  15. disable BIT_DETECT;
  16. end else begin
  17. bit_position = 32;
  18. end
  19. end
  20. end
  21.  
  22. // Testbench code here
  23. initial begin
  24. $monitor(" INPUT = %b MIN_POSITION = %d", bit_detect, bit_position);
  25. #1 bit_detect = 32'h1000_1000;
  26. #1 bit_detect = 32'h1100_0000;
  27. #1 bit_detect = 32'h1000_1010;
  28. #10 $finish;
  29. end
  30.  
  31. endmodule

В примере выше, BIT_DETECT ­ именованный блок, который запрещается сразу, как только будет определено положение бита.