在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 6735|回复: 6

[求助] SystemVerilog program 能不能定义在 module里?

[复制链接]
发表于 2012-12-29 12:28:16 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 semiliu 于 2012-12-29 12:35 编辑

初学SV, 根据RLM 尝试着把program定义在module里。结果编译失败。如果把program定义移动到module外,编译成功。根据LRM "Program blocks can be nested within modules or interfaces." ,program可以定义在module里,错在了哪里?





  1. Error-[SE] Syntax error
  2.   Following verilog source has syntax error :
  3.   "sv_program.sv", 8: token is 'program'
  4.     program automatic test();
  5.            ^
  6.   System verilog  keyword 'program' is not expected to be used in this
  7.   context.


复制代码






  1. `timescale 1ns/100ps


  2. module top;
  3.   reg clk;

  4.   program automatic test();
  5.     initial begin
  6.       for(int j=0; j!=3; j++) begin
  7.         int k = j;
  8.         fork
  9.           $write("j = %0d\n",j);
  10.           $write("k = %0d\n",k);
  11.         join_none
  12.       end
  13.     end
  14.   endprogram

  15.   initial begin
  16.     $display("Hello World");
  17.   end

  18.   test t();
  19. endmodule


复制代码
 楼主| 发表于 2012-12-29 20:24:54 | 显示全部楼层
用Mentor的工具compile没有问题。但是VCS 会报错。
发表于 2013-1-7 16:56:35 | 显示全部楼层
他们是同级别的!
发表于 2013-1-11 21:51:05 | 显示全部楼层
module和program是同一级别的,把program的定义从module里面拎出来,在module里面例化一个test就ok了,就像例化一个子模块一样。
发表于 2013-12-21 12:11:15 | 显示全部楼层
可以的

`define DIS "hello,world,%d,%h",'h8,5'd15
module test2;
   reg clk;
  
program automatic test;
  
  class cov;
    rand bit[4:0] port;
  
  
  endclass

  
  
  cov cov1;
   
    covergroup  portcov;
      coverpoint cov1.port{
        bins port[]={[0]};
      bins other[]=default;
      }
    endgroup
  
  portcov portcovsample;
   
  initial begin
   
   
    portcovsample=new();
    cov1=new();
    repeat(1000) begin
      assert(cov1.randomize());
      $display("port is %d",cov1.port);  
      portcovsample.sample();
    end
  
  end
  

  
    initial begin

$display(`DIS);
  
  
    repeat(1000) begin
      #10;
      $display("good");
      $stop;
    end
  
  end
  
endprogram
endmodule
发表于 2014-9-23 15:07:35 | 显示全部楼层
学习了~~~~
发表于 2018-12-7 00:09:46 | 显示全部楼层
thank
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-22 09:40 , Processed in 0.018617 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表