在handelc中直接调用verilog模块

来源:互联网 发布:网络推广和seo 编辑:程序博客网 时间:2024/05/17 04:23

在handelc中可以直接调用verilog,vhdl,edif的现成模块,在这只说一下调用verilog模块的方法

Handel-C code
set clock = external "D17";                                                                                                   
unsigned 4 x;                                                                                                                 
interface verilog_component  
                                                                                                 

          (unsigned 4 return_val)     //verilog模块中的输出的接口,接口名称要与模块中的一致                                                                                          
     verilog_component_instance
          (unsigned 1 clk = __clock,   //  verilog模块中的输入接口
          unsigned 4 sent_value = x) 
          with {busformat = "B_I"};                                                                                           
void main(void)  //main函数
{
    unsigned 4 y;
    y = verilog_component_instance.return_val; // 从verilog模块中读数据。
    x = y;                                                                  // 向Verilog 模块中写数据
}



Verilog code  下边的代码就是被handelc调用的verilog文件中的模块代码
The Verilog module will need an interface like this to be compatible with the Handel-C:


module verilog_component(clk, sent_value_0, sent_value_1, sent_value_2, 
    sent_value_3, return_val_0, return_val_1, 
    return_val_2, return_val_3);
    input clk; 
    input sent_value_0;
    input sent_value_1;
    input sent_value_2;
    input sent_value_3;
    output return_val_0;
    output return_val_1;
    output return_val_2;
    output return_val_3;
  
endmodule