wzab / agwb

Support for automatic address map generation and address decoding logic for Wishbone connected hierachical systems
12 stars 6 forks source link

Incorrect code generated when the default value is set in the vector of control registers #64

Closed wzab closed 2 years ago

wzab commented 2 years ago

If somebody sets the default value to a bitfield in the vector of control registers, the initialization code is generated incorrectly. Many thanks to Esteban Rubio from CBM team for finding that bug. The problem may be recreated in the "test" demo design by setting the repetition count to "1" and adding a default value to one of the bitfields in X2 register in block1.xml:

  <creg name="X2" stb="1" reps="1">
    <field name="B1" width="1" desc="Start the operation" trigger="1" />
    <field name="B2" width="1" desc="Start the operation" default="0" />
    <field name="B3" width="1" desc="Start the operation" trigger="1" />....
  </creg>

Then we get the following error in GHDL compilation:

ghdl -a -g --work=general_cores -C  --std=93c --ieee=standard general-cores/modules/wishbone/wb_register/xwb_register.vhd
ghdl -a -g --work=agwb -C  --std=93c --ieee=standard gen/agwb_pkg.vhd
ghdl -a -g --work=agwb -C  --std=93c --ieee=standard gen/MAIN_const_pkg.vhd
ghdl -a -g --work=agwb -C  --std=93c --ieee=standard gen/SYS1_pkg.vhd
ghdl -a -g --work=agwb -C  --std=93c --ieee=standard gen/SYS1.vhd
gen/SYS1.vhd:44:60:error: can't match function call with type array type "ut_x2_array"
  signal int_X2_o : ut_X2_array(g_X2_size - 1 downto 0) := to_X2(std_logic_vector(to_unsigned(0,3))); -- Hex value: 0x0
                                                           ^
gen/SYS1.vhd:122:21:error: can't match function call with type array type "ut_x2_array"
        int_X2_o <= to_X2(std_logic_vector(to_unsigned(0,3))); -- Hex value: 0x0
                    ^
ghdl:error: compilation error

The problem does not occur if the number of repetitions (reps) is higher than 1.

wzab commented 2 years ago

The problem is probably fixed with commit https://github.com/wzab/agwb/commit/5413fc8ab58cb3ac19c61255dea22af90da42a71 (merged with https://github.com/wzab/agwb/commit/6a713b5de15576c1d87a5e4c1e1723870cff3d15 to the "updates_from_cbm" branch).