2017-01-15 1 views
-1
module DSD_Project(flag0, flag1, hit0, hit1,room_counter,someone_inRoom,someone_Spying,hit0_LED, hit1_LED,echo0_LED, echo1_LED, anti_theft_output,reset_Antitheft_output,echo0, echo1, CLOCK_50,anti_theft, reset_Antitheft); 

    output reg hit0_LED = 1'b0; 
    output reg hit1_LED = 1'b0; 
    output reg echo0_LED = 1'b0; 
    output reg echo1_LED = 1'b0; 
    output reg flag0 = 1'b0; 
    output reg flag1 = 1'b0; 
    output reg hit0 = 1'b0; 
    output reg hit1 = 1'b0; 
    output reg room_counter = 1'b0; 
    output reg someone_inRoom = 1'b0; 
    output reg someone_Spying = 1'b0; 
    output reg anti_theft_output = 1'b0; 
    output reg reset_Antitheft_output = 1'b0; 
    input echo0; // input_signal from the sensor 1 
    input echo1;// input_signal from the sensor 2 
    input CLOCK_50; 
    input anti_theft ; //= 1'b0; // switch button 
    input reset_Antitheft; // = 1'b0; // push button 

    sensor s1(hit0, echo0) ; // , CLOCK_50); 
    sensor s2(hit1, echo1) ; // , CLOCK_50); 

    [email protected](posedge CLOCK_50) 
     begin   
      hit0_LED <= hit0; 
      hit1_LED <= hit1; 
      echo0_LED <= echo0; 
      echo1_LED <= echo1;  
     end 

    //anti_theft: seting and reseting the output 
    //[email protected](anti_theft) //or reset_Antitheft) 
     //begin 
      //anti_theft_output <= anti_theft ; 
      //reset_Antitheft_output <= reset_Antitheft ; 
     //end 

    [email protected](posedge hit0 or posedge hit1) 
     begin  
      if (hit0 == 1 && hit1== 0) 
       begin 
        flag0<= 1; 
        //flag1<= 0; 
        if(flag1==0) 
         begin 
          hit0=0; 
          room_counter <= room_counter +1 ; 
          someone_inRoom <=1 ; 
          if(anti_theft == 1) 
           someone_Spying <= 1; 
         end 
        else 
        flag1<=0;    
       end 
     else 
      begin 
       if ((hit0 == 0) && (hit1 == 1)) 
      begin 
        //flag0<=0; 
        flag1<=1; 
        if(flag0 == 0) 
         begin 
          hit1=0; 
          room_counter <= room_counter -1 ; 

          if(room_counter==0) 
           begin 
            someone_inRoom <=0 ; 
           end 
         end 
        else 
        flag0<=0; 
      end 
      end 
    end 
    [email protected](reset_Antitheft) 
    begin 
    if((anti_theft==1) && (someone_Spying == 1)) 
     begin 
      anti_theft_output <= 0 ; 
      someone_Spying <= 0 ; 
     end 
    end 
endmodule 


module sensor(hit, input_signal); //, CLOCK_50); 

    input input_signal; 
    output reg hit = 1'b0; 
    //reg [25:0] clock_counter; 

    [email protected](input_signal) // posedge CLOCK_50 || 
     begin 
      //if (clock_counter == 8_000_000) 
       begin    
        if (input_signal==1) 
         begin 
          hit <= 1;     
         end 
        else 
         begin 
          hit <= 0;  
         end   
       end 
      //else 
      // clock_counter <= clock_counter+1; 
     end  
endmodule 

ScreenShootエラー(10663):DSD_Project.vでのVerilog HDLポート接続エラー(34):出力またはポートinoutの "ヒット" の構造ネット表現に接続する必要がありますが、知っているだろうと

+0

コードをクリーンアップする必要があり、合成できません。合成するために、 'reg'は一つの' always'ブロックにのみ割り当てられなければなりません。組み合わせ論理にはブロッキングステートメント( '=')を割り当て、 'always @ *'(または同義語 'always @(*)')を使用する必要があります。シーケンシャルロジックは 'always @(posedge CLOCK_50)'にノンブロッキングステートメント( '<=')で割り当てる必要があります。 FPGAをお使いになる場合は、他の風変わりなブロック感度リストを避けるべきです。あなたは、櫛論理になる 'reg'にデフォルトファイルを与えるべきではありません。 'hit0'と' hit1'は 'wire'ネットでなければなりません。 – Greg

答えて

0

問題は、次の行である:sensor

sensor s1(hit0, echo0) ; // , CLOCK_50); 
sensor s2(hit1, echo1) ; // , CLOCK_50); 

、第一ポート、hitが出力されます。しかし、あなたは上記の行で指定され、regに接続しようとしている:

output reg hit0 = 1'b0; 
output reg hit1 = 1'b0; 

あなたはwire秒、ないreg sと、これらの信号を使用する必要があります。

+0

私はこれを試してみると、彼は私に、この行の左側にある「行番号」を変更しようとすると、「ヒット」が「reg」でなければならないというエラーを表示します。 –

+0

と私はそれを変更した場合..私は前にそれを試したように..すべてが停止される..私は "hit0、ヒット1"を使用している場合..私は別のエラーを与えます..私は本当に落ち込んでいる: ( –

+1

'hit0'と' hit1'はワイヤーでなければなりません - サブモジュールの出力で駆動され、 'always'ブロックではなく' hit'(内部センサー)は 'reg'でなければなりません。 – wilcroft

関連する問題