Jun 24, 2013 #1 S sujithad Newbie level 2 Joined Jun 24, 2013 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 14 Hi I have an array of 512 entries each entry being 1024 bits size. rand bit [1023:0] entry_rand [512]; I want to constraint randomize such that each entry is non-zero but only few bits in the entry are set. Eg: Out of 1024 bit, I need only 5 bits be set to 1 & others be 0. Can anyone help me how to write constraint for this? constraint entry_rand_c { foreach (entry_rand) { } } Thanks =sd
Hi I have an array of 512 entries each entry being 1024 bits size. rand bit [1023:0] entry_rand [512]; I want to constraint randomize such that each entry is non-zero but only few bits in the entry are set. Eg: Out of 1024 bit, I need only 5 bits be set to 1 & others be 0. Can anyone help me how to write constraint for this? constraint entry_rand_c { foreach (entry_rand) { } } Thanks =sd
Jun 26, 2013 #2 D dave_59 Advanced Member level 3 Joined Dec 15, 2011 Messages 838 Helped 365 Reputation 734 Reaction score 360 Trophy points 1,353 Location Fremont, CA, USA Activity points 7,369 Re: Question on constraint randomizing an array in systemverilog Code: constraint entry_rand_c { foreach (entry_rand[i]) $countones(entry_rand[i])==5; } See https://electronics.stackexchange.com/questions/36512/system-verilog-constraints
Re: Question on constraint randomizing an array in systemverilog Code: constraint entry_rand_c { foreach (entry_rand[i]) $countones(entry_rand[i])==5; } See https://electronics.stackexchange.com/questions/36512/system-verilog-constraints
Jun 26, 2013 #3 S sujithad Newbie level 2 Joined Jun 24, 2013 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 14 Re: Question on constraint randomizing an array in systemverilog Hi Dave, Thanks. But when run on IUS, I get this error *E: A 'system task/function call' cannot be used within a constraint expression. Is there a workaround for this? dave_59 said: Code: constraint entry_rand_c { foreach (entry_rand[i]) $countones(entry_rand[i])==5; } See https://electronics.stackexchange.com/questions/36512/system-verilog-constraints Click to expand...
Re: Question on constraint randomizing an array in systemverilog Hi Dave, Thanks. But when run on IUS, I get this error *E: A 'system task/function call' cannot be used within a constraint expression. Is there a workaround for this? dave_59 said: Code: constraint entry_rand_c { foreach (entry_rand[i]) $countones(entry_rand[i])==5; } See https://electronics.stackexchange.com/questions/36512/system-verilog-constraints Click to expand...
Jun 26, 2013 #4 mrflibble Advanced Member level 5 Joined Apr 19, 2010 Messages 2,720 Helped 679 Reputation 1,360 Reaction score 652 Trophy points 1,393 Activity points 19,551 Re: Question on constraint randomizing an array in systemverilog sujithad said: Thanks. But when run on IUS, I get this error *E: A 'system task/function call' cannot be used within a constraint expression. Is there a workaround for this? Click to expand... Read **broken link removed** that is down for SQL maintenance at the moment. One can only hope they are upgrading to MariaDB.
Re: Question on constraint randomizing an array in systemverilog sujithad said: Thanks. But when run on IUS, I get this error *E: A 'system task/function call' cannot be used within a constraint expression. Is there a workaround for this? Click to expand... Read **broken link removed** that is down for SQL maintenance at the moment. One can only hope they are upgrading to MariaDB.