Task in systemverilog

Hi,
I have written code in systemverilog, in which I have a top module with inputs and outputs for a sram intrface.
write process I have written in task saving in another file and calling from main module… this code is perfectly executing in eda playground , but failing to synthesize in vivado 18 environment with errors as CLE, A,AD etc are not declared in write_ft313 task.

kindly help on how to resolve, as I need to put this code fpga to work.
Awaiting help
Thanking you

 
// this is top module 
`timescale 1ns / 1ns

module Proj1(INT,DREQ,A,CS_N,RD_N,WR_N,DACK,ALE_N,CLE,AD);
 
    input  INT;
    input   DREQ;
    output  logic CS_N;
    output reg RD_N;
    output reg [7:0] A;
    output reg  WR_N;
    output reg DACK;
    output reg   ALE_N;
    output reg CLE;
   inout [15:0] AD;
  reg [15:0] dout=0;
  reg [15:0] din=0;
   wire  INT;
   wire   DREQ;
   byte a;
   shortint b;
  shortint ad1;
  bit clk;
 `include "write_ft313.sv"
   initial clk = 0;
always #1 clk = ~clk;
  initial begin
  $dumpfile("dump.vcd");
  $dumpvars;
 // #10000 $finish;
end

  initial begin
    ad1=0;  
   a=8'hee;		//sample address
   b=16'haa;		// sample data
    dout=16'b0;
    RD_N=1;
    WR_N=0;
    end
    assign AD = RD_N ? dout : 16'bz; 
  always@ (posedge clk)
    write_ft313(a,b);
  //  read_ft313( a,b);
   
  endmodule    
// this is one more file named write-ft313.sv  
task   write_ft313( input byte a,  input shortint b);
 // always(@)
#1 assign CLE=1;
 #1 assign RD_N=1;
 #1 assign ALE_N=1;
 #1 assign CS_N =1;
 #1 assign WR_N=1;		//write enable
 #1 assign CS_N=0;
#1  assign A=a;
  
  #1 assign WR_N=0;		//write enable
  // #30 assign  AD=b;		// data to be written into the register
  #30;
    dout<=b;
  #10  assign WR_N=1;		//write enable
    // assign AD=0;
   dout<=16'b0; 
  #2 assign A=0;
  #30   assign CS_N =1;
 
  # 1 assign CS_N=0;
  
endtask
//endmodule

In reply to svkatwe:

What you’ve written is a behavioral model of an SRAM interface, which is fine for simulation, but it cannot be synthesized. So code like

#1 assign CLE=1;
#1 assign RD_N=1;
#1 assign ALE_N=1;
#1 assign CS_N =1;
#1 assign WR_N=1;

needs to be replaced with synthesizable counters.

In reply to sbellock:

. thank you for your valuable, i am trying to implement using following code, but failing to synthesize in task.

cnt=0;
always @(posedge clk)
cnt=cnt+1;

del=cnt[20];

and using
repeat(10)@(posedge clk)
x=1;

Please help me to solve this, i need to implement this functionality in task as I require it many times. in module it works fine , but not in task. kindly help me

In reply to svkatwe:

  1. You can’t put an always block inside a task.
  2. Within a clocked always block you want to use non-blocking assignments (cnt <= cnt + 1).
  3. repeat typically isn’t synthesizable, although it could be.