bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

compilation issue

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
flashdisk



Joined: 29 May 2012
Posts: 56

PostPosted: Wed Nov 14, 2012 4:18 pm    Post subject: compilation issue Reply with quote

hey,

here is my code that is not compiling and I get the following :

Code:


ERROR:"Pdiv3.bsv",line 11..
Rule 'div1' uses method that conflict in parallel:
mi.write(...)
and
mi.write(...)


here is my code:
Code:

import Pmult3::*;
import Pdiv3::*;
import Vector::*;

(* synthesize *)

module mkTbPmult3();

    Ifc_Pmult3 ifc_pmult3 <- mkPmult3;

    Ifc_Pdiv3 ifc_pdiv3 <- mkPdiv3;

    Reg#(Bit#(16)) state <- mkReg(0);

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

    rule step0(state == 0);
           
        Bit#(106) x = 'b11110000000000000000000000000000000000000000000000000;
        Bit#(106) y = 'b11000000000000000000000000000000000000000000000000000;
        ifc_pmult3.mult1(x,y);
        ifc_pdiv3.div1(x,y);
        state <= 1;

    endrule

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

    rule step1(state == 1);

        Bit#(11)  exp1= 'b11;
        Bit#(11)  exp2= 'b01;         
        $display("Result for mult is %b", ifc_pmult3.mult2);
        $display("The final exp for mult is %b", ifc_pmult3.exp(exp1, exp2));
        $display("Result for div is %b", ifc_pdiv3.div2);
        $display("The final exp for div is %b", ifc_pdiv3.exp(exp1, exp2));
        $finish;

    endrule

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

endmodule



and here is the calculation that is done :
Code:


interface Ifc_Pdiv3;

method Action div1(Bit#(106) x, Bit#(106) y);
method Bit#(53) div2();
method Bit#(11) exp(Bit#(11) exp1, Bit#(11) exp2);

endinterface

(* synthesize *)

module mkPdiv3(Ifc_Pdiv3);

    Reg#(Bit#(154)) result<-mkReg(0);

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

    method Action div1(Bit#(106) x, Bit#(106) y);

        Bit#(154) mi='b10000000000000000000000000000000000000000000000000000;
        Bit#(154) cons_two='b100000000000000000000000000000000000000000000000000;
        for(int i=0;i<6;i=i+1)
        begin
            Bit#(154) y_mi=(extend(y)<<4*i)*mi;
            Bit#(154) y_mi_2=(y_mi>>(51+4*i))>>1;
            cons_two= cons_two<<4;
            Bit#(154) y_mi_2_2=cons_two-y_mi_2;
            Bit#(154) y_mi_2_2_mi=y_mi_2_2*(mi<<4); 
            Bit#(154) new_mi=y_mi_2_2_mi>>(53+4*i);
            mi=new_mi;
        end
        Bit#(154) x_ext=extend(x)<<24;
        result<= mi*x_ext;

    endmethod

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

    method  Bit#(53) div2();

        if(result[153]==0)
            return (result<<1)[153:101];
        else
            return result[153:101];

    endmethod

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

    method Bit#(11) exp(Bit#(11) exp1, Bit#(11) exp2);

        if(result[153]==1)   
            return exp1-exp2;
        else
            return exp1-exp2-1;

    endmethod

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

endmodule

[/code]
Back to top
View user's profile Send private message
hadar_agam



Joined: 10 May 2007
Posts: 38

PostPosted: Wed Nov 14, 2012 9:38 pm    Post subject: Reply with quote

Usually you'd get this kind of error when you try to invoke two conflicting methods in parallel (from the same rule or action method). For example: when you try to do two "enq" to the same fifo from the same rule.

It seems like you pasted the wrong code, since it's complaining about the update to "mi", while mi is defined as a simple variable (and not a module which has a "write" method).
Back to top
View user's profile Send private message Visit poster's website
flashdisk



Joined: 29 May 2012
Posts: 56

PostPosted: Thu Nov 15, 2012 4:32 am    Post subject: Reply with quote

sorry,I pasted the right code but in the new one mi is defined as reg(bit) instead of bit() so it really has a write and a read function which are implicit
so what to do to solve this problem?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP