在handelc中直接調用verilog模塊

在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

發佈了18 篇原創文章 · 獲贊 12 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章