Error (10734): Verilog HDL error at SWSelector.v(13): selector is not a constant










0















Referring to my previous post:
Error (10482): VHDL error: object "select_vector" is used but not declared



I converted my code from VHDL to verilog, but I'm getting this error now:




(Error (10734): Verilog HDL error at SWSelector.v(13): selector is not
a constant),




Any suggestions how do I deal with it? There are 8 possibilities for selector switch which are coming from a decoder. So whenever the value of selector matches 3'b000, I want rq to be assigned to requests. Here is my code:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
if(selector == NUM)
begin
assign request[i] = rq[i];
end
else
begin
assign request[i]=0;
end
end
endgenerate
endmodule









share|improve this question
























  • Is there a reason why you're using generate?

    – Matthew Taylor
    Nov 13 '18 at 17:30






  • 2





    Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

    – toolic
    Nov 13 '18 at 18:48












  • @Serge VHDL does not stand for "Verilog HDL".

    – duskwuff
    Nov 13 '18 at 19:39











  • IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

    – user1155120
    Nov 13 '18 at 20:07
















0















Referring to my previous post:
Error (10482): VHDL error: object "select_vector" is used but not declared



I converted my code from VHDL to verilog, but I'm getting this error now:




(Error (10734): Verilog HDL error at SWSelector.v(13): selector is not
a constant),




Any suggestions how do I deal with it? There are 8 possibilities for selector switch which are coming from a decoder. So whenever the value of selector matches 3'b000, I want rq to be assigned to requests. Here is my code:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
if(selector == NUM)
begin
assign request[i] = rq[i];
end
else
begin
assign request[i]=0;
end
end
endgenerate
endmodule









share|improve this question
























  • Is there a reason why you're using generate?

    – Matthew Taylor
    Nov 13 '18 at 17:30






  • 2





    Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

    – toolic
    Nov 13 '18 at 18:48












  • @Serge VHDL does not stand for "Verilog HDL".

    – duskwuff
    Nov 13 '18 at 19:39











  • IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

    – user1155120
    Nov 13 '18 at 20:07














0












0








0








Referring to my previous post:
Error (10482): VHDL error: object "select_vector" is used but not declared



I converted my code from VHDL to verilog, but I'm getting this error now:




(Error (10734): Verilog HDL error at SWSelector.v(13): selector is not
a constant),




Any suggestions how do I deal with it? There are 8 possibilities for selector switch which are coming from a decoder. So whenever the value of selector matches 3'b000, I want rq to be assigned to requests. Here is my code:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
if(selector == NUM)
begin
assign request[i] = rq[i];
end
else
begin
assign request[i]=0;
end
end
endgenerate
endmodule









share|improve this question
















Referring to my previous post:
Error (10482): VHDL error: object "select_vector" is used but not declared



I converted my code from VHDL to verilog, but I'm getting this error now:




(Error (10734): Verilog HDL error at SWSelector.v(13): selector is not
a constant),




Any suggestions how do I deal with it? There are 8 possibilities for selector switch which are coming from a decoder. So whenever the value of selector matches 3'b000, I want rq to be assigned to requests. Here is my code:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
if(selector == NUM)
begin
assign request[i] = rq[i];
end
else
begin
assign request[i]=0;
end
end
endgenerate
endmodule






verilog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 19:53









user1155120

12.2k32227




12.2k32227










asked Nov 13 '18 at 17:16









Muhammad AtifMuhammad Atif

44




44












  • Is there a reason why you're using generate?

    – Matthew Taylor
    Nov 13 '18 at 17:30






  • 2





    Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

    – toolic
    Nov 13 '18 at 18:48












  • @Serge VHDL does not stand for "Verilog HDL".

    – duskwuff
    Nov 13 '18 at 19:39











  • IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

    – user1155120
    Nov 13 '18 at 20:07


















  • Is there a reason why you're using generate?

    – Matthew Taylor
    Nov 13 '18 at 17:30






  • 2





    Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

    – toolic
    Nov 13 '18 at 18:48












  • @Serge VHDL does not stand for "Verilog HDL".

    – duskwuff
    Nov 13 '18 at 19:39











  • IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

    – user1155120
    Nov 13 '18 at 20:07

















Is there a reason why you're using generate?

– Matthew Taylor
Nov 13 '18 at 17:30





Is there a reason why you're using generate?

– Matthew Taylor
Nov 13 '18 at 17:30




2




2





Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

– toolic
Nov 13 '18 at 18:48






Replace the whole module with: assign request = (selector == 3'b000) ? rq : 81'b0;

– toolic
Nov 13 '18 at 18:48














@Serge VHDL does not stand for "Verilog HDL".

– duskwuff
Nov 13 '18 at 19:39





@Serge VHDL does not stand for "Verilog HDL".

– duskwuff
Nov 13 '18 at 19:39













IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

– user1155120
Nov 13 '18 at 20:07






IEEE Std 1800-2017 27.3 Generate construct syntax "Generate schemes are evaluated during elaboration of the design. Although generate schemes use syntax that is similar to behavioral statements, it is important to recognize that they do not execute at simulation time. They are evaluated at elaboration time, and the result is determined before simulation begins. Therefore, all expressions in generate schemes shall be constant expressions, deterministic at elaboration time. For more details on elaboration, see 3.12." Your generate statement can't contain dynamic conditional elaboration.

– user1155120
Nov 13 '18 at 20:07













1 Answer
1






active

oldest

votes


















0














Since your if-statement is in a generate, you're asking the tool to pre-evaluate what selector is set to in order to figure out selecter == NUM evaluates to, but your tool doesn't know because it's a signal, not a parameter.



You want to use the generate to create an always block that you can check the value of selector in, like so:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
always @* begin
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
end
endgenerate
endmodule


Or, as toolic said, you can use a ternary and an assign.



Edit:



Without generate:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;

integer i;
always @* begin
for(i=0;i<7;i=i+1)
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
endmodule





share|improve this answer

























  • Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

    – Muhammad Atif
    Nov 14 '18 at 19:09











  • Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

    – Charles Clayton
    Nov 15 '18 at 0:03











  • See my edit for an example.

    – Charles Clayton
    Nov 15 '18 at 15:05











  • so basically, I need to use it under an always block... thanks... that helped me a lot…

    – Muhammad Atif
    Nov 16 '18 at 18:59










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286356%2ferror-10734-verilog-hdl-error-at-swselector-v13-selector-is-not-a-constant%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Since your if-statement is in a generate, you're asking the tool to pre-evaluate what selector is set to in order to figure out selecter == NUM evaluates to, but your tool doesn't know because it's a signal, not a parameter.



You want to use the generate to create an always block that you can check the value of selector in, like so:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
always @* begin
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
end
endgenerate
endmodule


Or, as toolic said, you can use a ternary and an assign.



Edit:



Without generate:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;

integer i;
always @* begin
for(i=0;i<7;i=i+1)
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
endmodule





share|improve this answer

























  • Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

    – Muhammad Atif
    Nov 14 '18 at 19:09











  • Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

    – Charles Clayton
    Nov 15 '18 at 0:03











  • See my edit for an example.

    – Charles Clayton
    Nov 15 '18 at 15:05











  • so basically, I need to use it under an always block... thanks... that helped me a lot…

    – Muhammad Atif
    Nov 16 '18 at 18:59















0














Since your if-statement is in a generate, you're asking the tool to pre-evaluate what selector is set to in order to figure out selecter == NUM evaluates to, but your tool doesn't know because it's a signal, not a parameter.



You want to use the generate to create an always block that you can check the value of selector in, like so:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
always @* begin
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
end
endgenerate
endmodule


Or, as toolic said, you can use a ternary and an assign.



Edit:



Without generate:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;

integer i;
always @* begin
for(i=0;i<7;i=i+1)
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
endmodule





share|improve this answer

























  • Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

    – Muhammad Atif
    Nov 14 '18 at 19:09











  • Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

    – Charles Clayton
    Nov 15 '18 at 0:03











  • See my edit for an example.

    – Charles Clayton
    Nov 15 '18 at 15:05











  • so basically, I need to use it under an always block... thanks... that helped me a lot…

    – Muhammad Atif
    Nov 16 '18 at 18:59













0












0








0







Since your if-statement is in a generate, you're asking the tool to pre-evaluate what selector is set to in order to figure out selecter == NUM evaluates to, but your tool doesn't know because it's a signal, not a parameter.



You want to use the generate to create an always block that you can check the value of selector in, like so:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
always @* begin
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
end
endgenerate
endmodule


Or, as toolic said, you can use a ternary and an assign.



Edit:



Without generate:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;

integer i;
always @* begin
for(i=0;i<7;i=i+1)
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
endmodule





share|improve this answer















Since your if-statement is in a generate, you're asking the tool to pre-evaluate what selector is set to in order to figure out selecter == NUM evaluates to, but your tool doesn't know because it's a signal, not a parameter.



You want to use the generate to create an always block that you can check the value of selector in, like so:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;
generate
genvar i;
for(i=0;i<7;i=i+1)
begin: label
always @* begin
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
end
endgenerate
endmodule


Or, as toolic said, you can use a ternary and an assign.



Edit:



Without generate:



module SWSelector(
input [7:0] rq,
input [2:0] selector,
output reg [7:0] request
);
localparam NUM=3'b000;

integer i;
always @* begin
for(i=0;i<7;i=i+1)
if(selector == NUM)
request[i] = rq[i];
else
request[i]=0;
end
endmodule






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 15:05

























answered Nov 13 '18 at 22:12









Charles ClaytonCharles Clayton

7,78075387




7,78075387












  • Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

    – Muhammad Atif
    Nov 14 '18 at 19:09











  • Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

    – Charles Clayton
    Nov 15 '18 at 0:03











  • See my edit for an example.

    – Charles Clayton
    Nov 15 '18 at 15:05











  • so basically, I need to use it under an always block... thanks... that helped me a lot…

    – Muhammad Atif
    Nov 16 '18 at 18:59

















  • Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

    – Muhammad Atif
    Nov 14 '18 at 19:09











  • Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

    – Charles Clayton
    Nov 15 '18 at 0:03











  • See my edit for an example.

    – Charles Clayton
    Nov 15 '18 at 15:05











  • so basically, I need to use it under an always block... thanks... that helped me a lot…

    – Muhammad Atif
    Nov 16 '18 at 18:59
















Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

– Muhammad Atif
Nov 14 '18 at 19:09





Thanks for the help. Is it possible to use for loop without generate…? Because I dont even know why I am using generate! I just googled it and found that for loop has to be written under generate.. without generate for loop cannot be written.

– Muhammad Atif
Nov 14 '18 at 19:09













Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

– Charles Clayton
Nov 15 '18 at 0:03





Yes you can have a for loop without a generate, if you swap the for and the always block and get rid of the generate and rename the genvar and integer, that would work.

– Charles Clayton
Nov 15 '18 at 0:03













See my edit for an example.

– Charles Clayton
Nov 15 '18 at 15:05





See my edit for an example.

– Charles Clayton
Nov 15 '18 at 15:05













so basically, I need to use it under an always block... thanks... that helped me a lot…

– Muhammad Atif
Nov 16 '18 at 18:59





so basically, I need to use it under an always block... thanks... that helped me a lot…

– Muhammad Atif
Nov 16 '18 at 18:59



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286356%2ferror-10734-verilog-hdl-error-at-swselector-v13-selector-is-not-a-constant%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo