@@ -630,6 +630,7 @@ pub fn eval_const_assign(
630630 if let Some ( exprs) = exprs {
631631 let values = eval_array_literal_expressions ( context, r#type, exprs, token) ?;
632632 let id = context. insert_var_path ( path. clone ( ) , comptime) ;
633+ let array_limit = context. config . evaluate_array_limit ;
633634 let variable = Variable :: new (
634635 id,
635636 path. clone ( ) ,
@@ -638,6 +639,7 @@ pub fn eval_const_assign(
638639 values,
639640 context. get_affiliation ( ) ,
640641 & dst. token ,
642+ array_limit,
641643 ) ;
642644 context. insert_variable ( id, variable) ;
643645 } else {
@@ -667,6 +669,7 @@ pub fn eval_const_assign(
667669 value. trunc ( total_width) ;
668670 }
669671
672+ let array_limit = context. config . evaluate_array_limit ;
670673 let variable = Variable :: new (
671674 id,
672675 path. clone ( ) ,
@@ -675,6 +678,7 @@ pub fn eval_const_assign(
675678 vec ! [ value] ,
676679 context. get_affiliation ( ) ,
677680 & dst. token ,
681+ array_limit,
678682 ) ;
679683 context. insert_variable ( id, variable) ;
680684 }
@@ -709,14 +713,12 @@ pub fn eval_variable(
709713 let signed = comptime. r#type . signed ;
710714 let id = context. insert_var_path ( path. clone ( ) , comptime) ;
711715
712- let values = if let Some ( total_array) = r#type. total_array ( )
713- && let Some ( total_width) = r#type. total_width ( )
714- {
715- let mut values = vec ! [ ] ;
716- for _ in 0 ..total_array {
717- values. push ( Value :: new_x ( total_width, signed) ) ;
718- }
719- values
716+ // Every element starts as the same x-state template, so store it once;
717+ // the simulator replicates it across the full `r#type.total_array()` at
718+ // fill time. Const/param arrays with per-element literals go through
719+ // `eval_array_literal` instead and keep their Vec<Value> intact.
720+ let values = if let Some ( total_width) = r#type. total_width ( ) {
721+ vec ! [ Value :: new_x( total_width, signed) ]
720722 } else {
721723 vec ! [ ]
722724 } ;
@@ -729,6 +731,7 @@ pub fn eval_variable(
729731 context. insert_var_path_with_id ( path, id, comptime) ;
730732 }
731733
734+ let array_limit = context. config . evaluate_array_limit ;
732735 let variable = Variable :: new (
733736 id,
734737 path. clone ( ) ,
@@ -737,6 +740,7 @@ pub fn eval_variable(
737740 values,
738741 context. get_affiliation ( ) ,
739742 & token,
743+ array_limit,
740744 ) ;
741745 context. insert_variable ( id, variable) ;
742746}
@@ -1438,6 +1442,7 @@ pub fn build_for_statement(
14381442 } else {
14391443 vec ! [ ]
14401444 } ;
1445+ let array_limit = context. config . evaluate_array_limit ;
14411446 let variable = Variable :: new (
14421447 loop_var_id,
14431448 path,
@@ -1446,6 +1451,7 @@ pub fn build_for_statement(
14461451 values,
14471452 context. get_affiliation ( ) ,
14481453 & token,
1454+ array_limit,
14491455 ) ;
14501456 context. insert_variable ( loop_var_id, variable) ;
14511457
0 commit comments