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 

Unbound Variable

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



Joined: 02 Oct 2015
Posts: 5

PostPosted: Sun Oct 04, 2015 6:32 pm    Post subject: Unbound Variable Reply with quote

Hi all,

I'm trying static elaboration for a simple circuit but I keep encountering the error T0004 Unbound variable `SemaforoFSM.bsv'. Any invaluable advice is much appreciated.

My code:
Code:
package SemaforoFSM;


interface I_SemaforoFSM;
    method Action in_i_reset(Bit#(1) p_i_reset);
    method Action in_tempo(Int#(32) p_tempo);
    method Bit#(1) out_o_vermelho();
    method Bit#(1) out_o_amarelo();
    method Bit#(1) out_o_verde();
    method Bit#(1) out_o_azul1();
    method Bit#(1) out_o_azul2();
endinterface: I_SemaforoFSM

typedef enum { VERDE, AMARELO, VERMELHO, AZUL1, AZUL2, FORKSEMAFORO, JOINSEMAFORO } State deriving(Bits,Eq);

(* synthesize *)
module mkSemaforoFSM(I_SemaforoFSM);
   

    Reg#(State) state <- mkReg(VERDE);

    Reg#(Bit#(1)) i_reset <- mkReg(0);
    Reg#(Int#(32)) tempo <- mkReg(0);
    Reg#(Bit#(1)) o_vermelho <- mkReg(0);
    Reg#(Bit#(1)) o_amarelo <- mkReg(0);
    Reg#(Bit#(1)) o_verde <- mkReg(0);
    Reg#(Bit#(1)) o_azul1 <- mkReg(0);
    Reg#(Bit#(1)) o_azul2 <- mkReg(0);

    (* descending_urgency = "verde, amarelo, vermelho, azul1, azul2, forksemaforo, joinsemaforo" *)

    rule verde (state == VERDE);
if (tempo == 20) state <= FORKSEMAFORO;
o_azul1 <= 0;
o_azul2 <= 0;
o_verde <= 1;
o_amarelo <= 0;
o_vermelho <= 0;
tempo <= 20;
    endrule

    rule amarelo (state == AMARELO);
if (tempo == 5) state <= VERMELHO;
o_azul1 <= 0;
o_azul2 <= 0;
o_verde <= 0;
o_amarelo <= 1;
o_vermelho <= 0;
tempo <= 5;
    endrule

    rule vermelho (state == VERMELHO);
if (tempo == 15) state <= VERDE;
o_azul1 <= 0;
o_azul2 <= 0;
o_verde <= 0;
o_amarelo <= 0;
o_vermelho <= 1;
tempo <= 15;
    endrule

    rule azul1 (state == AZUL1);
if (tempo == 8) state <= JOINSEMAFORO;
o_azul1 <= 1;
o_azul2 <= 0;
o_verde <= 0;
o_amarelo <= 0;
o_vermelho <= 0;
tempo <= 8;
    endrule

    rule azul2 (state == AZUL2);
if (tempo == 8) state <= JOINSEMAFORO;
o_azul1 <= 0;
o_azul2 <= 1;
o_verde <= 0;
o_amarelo <= 0;
o_vermelho <= 0;
tempo <= 8;
    endrule

    rule forkSemaforo (state == FORKSEMAFORO);
if (tempo == 10) state <= AZUL2;
if (tempo == 10) state <= AZUL1;
tempo <= 10;
    endrule

    rule joinSemaforo (state == JOINSEMAFORO);
if (tempo == 25) state <= AMARELO;
tempo <= 25;
    endrule


    method Action in_i_reset(Bit#(1) p_i_reset);
        i_reset <= p_i_reset;
    endmethod

    method Action in_tempo(Int#(32) p_tempo);
        tempo <= p_tempo;
    endmethod

    method Bit#(1) out_o_vermelho();
        return o_vermelho;
    endmethod

    method Bit#(1) out_o_amarelo();
        return o_amarelo;
    endmethod

    method Bit#(1) out_o_verde();
        return o_verde;
    endmethod

    method Bit#(1) out_o_azul1();
        return o_azul1;
    endmethod

    method Bit#(1) out_o_azul2();
        return o_azul2;
    endmethod


endmodule: mkSemaforoFSM

endpackage: SemaforoFSM


Back to top
View user's profile Send private message Send e-mail
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Mon Oct 05, 2015 10:22 am    Post subject: Re: Unbound Variable Reply with quote

What does the command line look like? Is it possible that you're accidentally giving the file name to the -g command:
Code:
# bsc -sim -g SemaforoFSM.bsv SemaforoFSM.bsv

The error message when you do that is T0004, which is unfortunately confusing (and I'll see if we can fix that).
Back to top
View user's profile Send private message
raphaelfribeiro



Joined: 02 Oct 2015
Posts: 5

PostPosted: Mon Oct 05, 2015 10:42 pm    Post subject: Reply with quote

It's done with this command:

# bsc -sim -g mkSemaforoFSM.bsv SemaforoFSM.bsv

Thank's!!
Back to top
View user's profile Send private message Send e-mail
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Tue Oct 06, 2015 9:45 am    Post subject: Reply with quote

Yes, you should remove the ".bsv" suffix from the module name and it should work:
Code:
# bsc -sim -g mkSemaforoFSM SemaforoFSM.bsv

In fact, since you specify "synthesize" in the source code, you don't need the -g flag at all. You can just do this:
Code:
# bsc -sim SemaforoFSM.bsv
Back to top
View user's profile Send private message
raphaelfribeiro



Joined: 02 Oct 2015
Posts: 5

PostPosted: Tue Oct 06, 2015 5:16 pm    Post subject: Reply with quote

Yes, I do without .bsv (mkSemaforoFSM).

Thank you!
Back to top
View user's profile Send private message Send e-mail
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