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 

Error bsc: (G0028)

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler)
View previous topic :: View next topic  
Author Message
ruizdelgado



Joined: 18 Jun 2018
Posts: 1

PostPosted: Fri Mar 08, 2019 7:43 pm    Post subject: Error bsc: (G0028) Reply with quote

Hello,
I'm learning to design hardware with bluespec.
I am using the following version of the compiler of Bluespec: Compiler, version 2017.03.beta1 (build 35049, 2017-03-16).
I am designing an adder / subtractor circuit of "w" bits.
this is the code of my program AlunN.bsc:
//half adder
function Bit#(2) ha(Bit#(1) a, Bit#(1) b);
Bit#(1) s = a ^ b;
Bit#(1) c = a & b;
return {c,s};
endfunction

// full adder
function Bit#(2) fa(Bit#(1) a, Bit#(1) b, Bit#(1) c_in);
let x = ha(a, b);
let y = ha(x[0], c_in);
let c_out = x[1] | y[1];
return {c_out, y[0]};
endfunction

// n bits adder
function Bit#(TAdd#(w,1)) addN(Bit#(w) x, Bit#(w) y, Bit#(1) c0);
Bit#(w) s = 0;
Bit#(TAdd#(w,1)) c;
c[0] = c0;
let valw = valueOf(w);
for (Integer i = 0 ; i < valw ; i = i+1) begin
let cs = fa(x[i], y[i], c[i]);
c[i+1] = cs[1];
s[i] = cs[0];
end
return {c[valw],s};
endfunction

// N-bit RC adder/subtractor
// returns a - b is isSub==1 and a + b otherwise
function Bit#(TAdd#(w,1)) addSubN(Bit#(w) a, Bit#(w) b, Bit#(1) isSub);
Bit#(TAdd#(w,1)) ret;
case (isSub)
0: ret=addN(a,b,0);
1: ret=addN(a,~b,1); // "b" en complemt1 + "1" a c0_in pasa a complemento a 2 "b"
endcase
return ret;
endfunction

and this is the testbench code TbAlu.bsv:

import AluN ::*;
// test-bench
module mkTb (Empty);
rule truthtable;
Bit#(3) astb;
astb=addSubN(2'b11,2'b01,1'b0);
$display ("a=3,","b=1","issub=0","astb=%0d",astb);
astb=addSubN(2'b11,2'b01,1'b1);
$display ("a=3,","b=1","issub=1","astb=%0d",astb[1:0]);
$finish(0);
endrule
endmodule: mkTb

when simulating the circuit with bluesim I get the following message from the compiler:
bsc -sim -g mkTb TbAlu.bsv

Error: "AluN.bsv", line 19, column 22: (G0028)
`c[2]' uses uninitialized value (the position shown is the object's
declaration). If this error is unexpected, please consult KPNS #32.
During elaboration of the body of rule `truthtable' at "TbAlu.bsv", line 4,
column 9.
During elaboration of `mkTb' at "TbAlu.bsv", line 3, column 8.
Error: "AluN.bsv", line 19, column 22: (G0028)
`c[1]' uses uninitialized value (the position shown is the object's
declaration). If this error is unexpected, please consult KPNS #32.
During elaboration of the body of rule `truthtable' at "TbAlu.bsv", line 4,
column 9.
During elaboration of `mkTb' at "TbAlu.bsv", line 3, column 8.
Error: "AluN.bsv", line 19, column 22: (G0028)
`c[2]' uses uninitialized value (the position shown is the object's
declaration). If this error is unexpected, please consult KPNS #32.
During elaboration of the body of rule `truthtable' at "TbAlu.bsv", line 4,
column 9.
During elaboration of `mkTb' at "TbAlu.bsv", line 3, column 8.
Error: "AluN.bsv", line 19, column 22: (G0028)
`c[1]' uses uninitialized value (the position shown is the object's
declaration). If this error is unexpected, please consult KPNS #32.
During elaboration of the body of rule `truthtable' at "TbAlu.bsv", line 4,
column 9.
During elaboration of `mkTb' at "TbAlu.bsv", line 3, column 8.

is telling me that the variable "c" of the addN function is not initialized correctly. In my case I only have initialized c [0] = 0 (the remainder c [1], c [2] does not have an initial value assigned).

Do I have to always initialize the rest of the values of this variable? ,
Is there any way for the compiler to infer it for me?

there is another way to express the parametric adder to solve de problem

thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler) 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