Thread: [myhdl-list] always_comb from a change in Signal list does not get triggered
Brought to you by:
jandecaluwe
From: Günter D. <dan...@we...> - 2008-06-13 09:53:02
Attachments:
test_pipe.py
|
Hi, I am trying to create a word wide shift register and the output register is connected with an always_comb to the output signal of the function. Now this always_comb gets only triggered one time, even so I see the output register signal change during the shift operation. This is my code: def pipe(clk,en,din, dout, N,width): pipe = [Signal(intbvSigned(width)) for i in range(N)] print "N: ", N @always(clk.posedge) def rtl1(): if en: for i in downrange(N,1): print "i: %d"% i pipe[i].next = pipe[i-1] pipe[0].next = din print "pipe: %s"% pipe @always_comb def rtl2(): print "pipe[N-1]: %d"% pipe[N-1] dout.next = pipe[N-1] return instances() I attached the test bench for it. Running the test bench will fill the pipe with values and print the output dout. I changed the code so that the pipe memory has only N-1 entries and dout being the Nth register, which worked fine. I just would like to know what I am doing wrong so that the always_comb gets not triggered anymore? BTW, in the above example I am using a convenience function to create a signed intbv instance: ------------------------------------------------------ def intbvSigned(width, value=0): max = 2**(width-1) min = -max r = intbv(value, min, max) return r Thanks for any help. Guenter |
From: Thomas T. <tho...@de...> - 2008-06-13 10:37:31
|
Günter Dannoritzer wrote: > This is my code: > > def pipe(clk,en,din, dout, N,width): > > pipe = [Signal(intbvSigned(width)) for i in range(N)] > > print "N: ", N > > @always(clk.posedge) > def rtl1(): > if en: > for i in downrange(N,1): > print "i: %d"% i > pipe[i].next = pipe[i-1] > pipe[0].next = din > print "pipe: %s"% pipe > > > @always_comb > def rtl2(): > print "pipe[N-1]: %d"% pipe[N-1] > dout.next = pipe[N-1] > > > return instances() > > I changed the code so that the pipe memory has only N-1 entries and dout > being the Nth register, which worked fine. I just would like to know > what I am doing wrong so that the always_comb gets not triggered anymore? I think this is a bug in myhdl. BTW, some related comments/questions: > for i in downrange(N,1): > pipe[i].next = pipe[i-1] The following should also work: for i in range(1,N): pipe[i].next = pipe[i-1] It will not override, the current value because you write to the next-attribute. In your simple example you could put the dout.next = pipe[N-1] inside the rtl1 generator so you don't need rtl2 (you probably know it, your code might be a simplification). Also in this simple case. Is there something bad about the following code, using a @always instead of @always_comb ? @always(clk.posedge) def rtl2(): Have a nice weekend, Thomas -- Thomas Traber DESY, MDI Notkestrasse 85 D-22603 Hamburg, Germany email: tho...@de... phone: +49 40 8998 4246 |
From: Günter D. <dan...@we...> - 2008-06-13 11:34:22
|
Thomas Traber wrote: > Günter Dannoritzer wrote: > ... >> >> I changed the code so that the pipe memory has only N-1 entries and dout >> being the Nth register, which worked fine. I just would like to know >> what I am doing wrong so that the always_comb gets not triggered anymore? > > I think this is a bug in myhdl. OK, that is good to know that I did not use it in a wrong way. > > BTW, some related comments/questions: > > > for i in downrange(N,1): > > pipe[i].next = pipe[i-1] > > The following should also work: > > for i in range(1,N): > pipe[i].next = pipe[i-1] > > It will not override, the current value because you write to the > next-attribute. Good point. Did not think about that. > > > In your simple example you could put the > dout.next = pipe[N-1] > inside the rtl1 generator so you don't need rtl2 (you probably know it, > your code might be a simplification). Yes, but that will delay dout by one clock cycle, which I did not want to have. But replacing pipe[N-1] by dout should make it work. Have a nice weekend too. Guenter |
From: Jan D. <ja...@ja...> - 2008-06-20 08:52:51
|
Günter Dannoritzer wrote: > Hi, > > I am trying to create a word wide shift register and the output register > is connected with an always_comb to the output signal of the function. > Now this always_comb gets only triggered one time, even so I see the > output register signal change during the shift operation. > > This is my code: > > def pipe(clk,en,din, dout, N,width): > > pipe = [Signal(intbvSigned(width)) for i in range(N)] > > print "N: ", N > > @always(clk.posedge) > def rtl1(): > if en: > for i in downrange(N,1): > print "i: %d"% i > pipe[i].next = pipe[i-1] > pipe[0].next = din > print "pipe: %s"% pipe > > > @always_comb > def rtl2(): > print "pipe[N-1]: %d"% pipe[N-1] > dout.next = pipe[N-1] > > > return instances() > > > > I attached the test bench for it. Running the test bench will fill the > pipe with values and print the output dout. > > I changed the code so that the pipe memory has only N-1 entries and dout > being the Nth register, which worked fine. I just would like to know > what I am doing wrong so that the always_comb gets not triggered anymore? always_comb doesn't understand lists of signals, or any composite type that would contain signals for that matter. It only can handle signals with a plain name in the code. Handling composite types such as lists of signals raises many question e.g. about efficiency. Also, this is certainly a construct that people will expect to be convertible - which raises many question on itself. Obviously the current situation were you are not warned is not OK. But I think the best thing to do is explicity check for the types that you can use and give an error otherwise, and ask people to use an explicit "always" to control exactly what they want. BTW, in this case you wouldn't need an "always_comb" block at all, you could just write: dout = pipe[N-1] to make dout and "alias" of the last pipe signal. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Kaboutermansstraat 97, B-3000 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |