Re: [myhdl-list] Problems converting an integer assignment into VHDL
Brought to you by:
jandecaluwe
From: Norbo <Nor...@gm...> - 2012-10-11 09:24:48
|
Am 11.10.2012, 10:31 Uhr, schrieb Angel Ezquerra <ang...@gm...>: > Hi, > > I got an issue with conversion to VHDL, where MyHDL seems to do the > wrong thing (although most likely it's me who is doing it wrong). > > The problem is that MyHDL maps an integer assignment into an intbv > signal as a direct integer assignment in VHDL, instead of using a > to_unsigned conversion. > > That is, I got a signal declared as follows: > > signal s_my_signal: unsigned(29 downto 0); > > Then I do: > > s_my_signal.next = s_my_signal.max - 1 > > which in VHDL becomes: > > s_my_signal.next <= 1073741824 - 1; > > Which is wrong. Instead I expected it to be: > > s_my_signal.next <= to_unsigned(1073741824 - 1, 30); > Yup that causes problems. which is funny because if you write in the myhdl code: s_my_signal.next <= 1073741824 - 1; the result is: s_my_signal <= to_unsigned(1073741824 - 1, 30); or if you write: CONST_MAX=s_my_signal.max @always(clk.posedge) def ttt(): s_my_signal.next <= CONST_MAX - 1; which converts to: s_my_signal <= to_unsigned(1073741824 - 1, 30); if you write: s_my_signal.next = int(s_my_signal.max) - 1 it converts to: s_my_signal <= to_unsigned(1073741824 - 1, 30); or if you write: s_my_signal.next = intbv(s_my_signal.max) - 1 it converts to: s_my_signal <= to_unsigned(1073741824 - 1, 30); so it turns out that the converter doesn't recognise the "s_my_signal.max" as an const integer, but instead as a signal. This seems to be also the case for the simulator. e.g: In a combinatorical process this leads to a -> combinatorical loop error, when there is actually none. sigTest=Signal(intbv(0)[4:]) @always_comb def comb_setConst(): sigTest.next=int(sigTest.max)-1 leads to the error message: --myhdl.AlwaysCombError: signal (sigTest) used as inout in always_comb function argument but it could be written like this: sigTest=Signal(intbv(0)[4:]) maxvalue=sigTest.max @always_comb def comb_setConst(): sigTest.next=maxvalue-1 this would make the simulator core happy and would be fine if the sensitivity list is not empty!! greetings Norbert |