Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem with Parameters in Verilog

Status
Not open for further replies.

VuTang

Newbie level 5
Joined
Oct 3, 2015
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
69
Hi all,
I'm designing a module in Verilog and need to use some parameters. For example, I have two parameters: 'a' and 'b' and the value of 'b' depend on 'a'. I use the folow code but It had not run yet.
Code:
localparam a = 9, b = 10;
initial 
 if (a = 1) b = 2;
 else if (a =2) b = 3;

Which verilog statement is suitable for this case?

Thank you very much
 

"if (a=1)" is a valid statement and will set a to 1. It is true, so b will be 2.
 

Oh, I'm sorry, this is my mistake when typing. In my module (design with Vivado-Xilinx):
Code:
parameter a = 9;
localparam b = 10;
initial 
     if (a == 1) b = 2,
     else (a == 2) b = 5;
and when I synthesis that module, I got a message: "[Synth 8-1727] cannot assign to non-variable b"
 

B is a localparam, and you already assigned it the value of 10.
 

B is a localparam, and you already assigned it the value of 10.

I've already assigned 10 for b, but when parameter 'a' is changed I want to update b's value. How can I do it?
 

I've already assigned 10 for b, but when parameter 'a' is changed I want to update b's value. How can I do it?
You can't parameters are constants, they are set at compile time.

But you can do something like this.

Code Verilog - [expand]
1
2
3
localparam b = (a == 1) ? b = 2
                        : (a == 2) ? b = 3
                                   : b = x;

 

Thanks for your answer, ads-see!
I follow your code and it works ok.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top