Advertisement
CHU2

Syntax

Jun 4th, 2024 (edited)
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 1.16 KB | Source Code | 0 0
  1. task taskname;
  2.    input s;
  3.    input logic [2:0] t;
  4.    output u;
  5.  
  6.     begin
  7.         // Task statements
  8.     end
  9. endtask
  10.  
  11. function [2:0] functionname;
  12.     input s;
  13.     integer t;
  14.     parameter u;
  15.     reg [2:0] v;
  16.  
  17.     begin
  18.         // Function statements
  19.         // Functions outputs assignments
  20.     end
  21. endfunction
  22.  
  23. task outputs;
  24.     input [2:0] s;
  25.     integer h = 0:
  26.     output t;
  27.  
  28.     begin
  29.         repeat (3) begin
  30.             t = h;     // Uses blocking to only works when every after delay only
  31.             t = t + 1;
  32.             #10;
  33.            
  34.             t <= s > 2'b10; // Uses non-blocking to simultaneously outputs this with the above output without waiting for the delay
  35.         end
  36.     end
  37. endtask
  38.  
  39. function [2:0] outputs;
  40.     input [2:0] s;
  41.  
  42.     begin
  43.         if (s[3] == 1'b1) begin // If statement to convert any even data and only outputs odd ones
  44.             outputs = ~s + 1'b1;
  45.         end
  46.         else begin
  47.             outputs = s;
  48.         end
  49.     end
  50. endfunction
  51.  
  52. always @(posedge clk) begin
  53.     outputs(3'b111);
  54. end
  55.  
  56. logic [2:0] result;
  57. always @(posedge clk) begin
  58.     result = outputs(data[2:0]);
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement