2014-11-08 4 views
-1

입니다ModelSim을 등록 그래서 내가 오류를 얻고 불법 오류

** 오류 : C : /Modeltech_pe_edu_10.3c/examples/HW6/alu.v (53) : 등록 연속의 왼쪽에 불법 할당

[할당 결과 = 32'd0;] 할당 문에 대한 이유는 무엇입니까? 나는 모든 코드 주위에서 문장의 클러스터를 움직여 보았고, 코드의 일부를 완전히 제거하면 작동하는 유일한 방법이다.

문제 내 테스트 벤치를 실행하는 데 필요한 것이 있습니다. 이 오류의 의미와 해결 방법에 대한 아이디어가 있습니까?

// 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

    module alu 
    (
     //-------------------------- 
     // Input Ports 
     //-------------------------- 
      input [31:0] operand0, 
     input [31:0] operand1, 
     input [3:0] control, 
     //-------------------------- 
     // Output Ports 
     //-------------------------- 
      output reg [31:0] result, 
     output   zero, 
     output  overflow 



    ); 
     //-------------------------- 
     // Bidirectional Ports 
     //-------------------------- 
     // < Enter Bidirectional Ports in Alphabetical Order > 
     // None 

     /////////////////////////////////////////////////////////////////// 
     // Begin Design 
     /////////////////////////////////////////////////////////////////// 


      assign result = 32'd0; 
     assign zero  = 1'b1; 
     assign overflow = 1'b0; 




    always @(*) 


    begin 
    case(control) 




    4'b0000: result = operand0 && operand1; 

    4'b0001: result = operand0 || operand1; 

    4'b0010: result = operand0^operand1; 

    4'b0011: result = !(operand0 || operand1); 

    4'b0100: result = operand0 + operand1; 

    4'b0110: result = operand0 - operand1; 

    4'b1000: result = operand0 < operand1; 

    4'b1001: result = operand0 << operand1; 

    4'b1010: result = operand0 >> operand1; 

    4'b1011: result = operand0 >>> operand1; 
    endcase 

    end 



    endmodule 

답변

0

첫째 : 유형 regassign 문에 할당 할 수 없습니다; 이것은 Verilog의 규칙입니다. "레지스터가 연속 할당의 왼쪽에 불법입니다"라는 말은 assign 문으로 레지스터를 할당 할 수 없음을 의미합니다. 왼쪽은 = 왼쪽에 있습니다.

두 번째 : reg 형식을 assign 문에 할당 할 수있는 경우에도 always 블록에 할당되는 result에 여러 드라이버가 할당됩니다. assign 문은 연속 드라이버이므로 다른 블록이 동일한 신호를 사용하더라도 신호에 항상 값을 적용합니다. 충돌이있는 경우 (예를 들어 1을 적용하고 다른 하나는 0을 적용) 결과는 'bx입니다.

해결 방법 : 라인을 제거하십시오. assign result = 32'd0;result은 조합 논리이며 초기 값이 필요하지 않습니다.

관련 문제