Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Cannot transmit correct result consecutively

 
Thread Tools Search this Thread
Old 04-18-2007, 03:37 PM   #1
Default Cannot transmit correct result consecutively


I have a weird question here. When I test the transmission part, the
first transmission result is correct. But the second time, the
transmission result sent back are strange numbers instead of the
result expected. If I push the RESET button, and do again. It
transmits correct again. So I guess there is something wrong on the
RESET part. Then I commented the reset part of the program to see what
the difference is.
When I go to this part: When I comment the cnt:=(others=>'0') in the
RESET. Even I push the RESET button, it cannot get correct result. If
i remove the comment and try again. I push the RESET button, It get
the correct result. Actually when the program finishes the ·IF
COUNTRX= NumAllWord1 THEN·The cnt will be clear up to zero. It is
same to the reset function here. Why it did not get the correct
result? Or my understanding gets wrong about the use of Variable ?

countRX_inst: process(WRRAMCLK,RESET)
VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
RAM PORT A ADDA, 15 BITS
VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
for one cycle
begin
if (RESET = '1') then
cnt:=(OTHERS=>'0');
elsif WRRAMCLK'event and WRRAMCLK = '1' then
IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
DINA <= DATAIN; --read data from input-register in uart to
ram_input input register
WEA <= '1';
COUNTRX <= cnt;
cnt := cnt + "0000000000000001";
STAPPB <='0';
END IF;

IF COUNTRX= NumAllWord1 THEN
WEA <= '0';
COUNTRX <= (OTHERS=>'0');
cnt:=(OTHERS=>'0');
STAPPB <='1'ï¼›
END IF;
rd4 := rd3;
rd3 := rd2;
rd2 := rd1;
rd1 := readb; --delay "read" three cycles
end if;
END PROCESS;



ZHIQUAN
  Reply With Quote
Old 04-18-2007, 04:24 PM   #2
Pieter Hulshoff
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
ZHIQUAN wrote:
> countRX_inst: process(WRRAMCLK,RESET)
> VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
> RAM PORT A ADDA, 15 BITS
> VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
> for one cycle
> begin
> if (RESET = '1') then
> cnt:=(OTHERS=>'0');
> elsif WRRAMCLK'event and WRRAMCLK = '1' then
> IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
> DINA <= DATAIN; --read data from input-register in uart to
> ram_input input register
> WEA <= '1';
> COUNTRX <= cnt;
> cnt := cnt + "0000000000000001";
> STAPPB <='0';
> END IF;
>
> IF COUNTRX= NumAllWord1 THEN
> WEA <= '0';
> COUNTRX <= (OTHERS=>'0');
> cnt:=(OTHERS=>'0');
> STAPPB <='1'ï¼›
> END IF;
> rd4 := rd3;
> rd3 := rd2;
> rd2 := rd1;
> rd1 := readb; --delay "read" three cycles
> end if;
> END PROCESS;


What does STAPPB do? I presume DINA is your write port, WEA your write enable,
and COUNTRX your address port; is this correct? What generates readb exactly,
and how is this signal defined?

Regards,

Pieter Hulshoff


Pieter Hulshoff
  Reply With Quote
Old 04-18-2007, 07:42 PM   #3
ZHIQUAN
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively

Pieter Hulshoff wrote:
> ZHIQUAN wrote:
> > countRX_inst: process(WRRAMCLK,RESET)
> > VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
> > RAM PORT A ADDA, 15 BITS
> > VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
> > for one cycle
> > begin
> > if (RESET = '1') then
> > cnt:=(OTHERS=>'0');
> > elsif WRRAMCLK'event and WRRAMCLK = '1' then
> > IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
> > DINA <= DATAIN; --read data from input-register in uart to
> > ram_input input register
> > WEA <= '1';
> > COUNTRX <= cnt;
> > cnt := cnt + "0000000000000001";
> > STAPPB <='0';
> > END IF;
> >
> > IF COUNTRX= NumAllWord1 THEN
> > WEA <= '0';
> > COUNTRX <= (OTHERS=>'0');
> > cnt:=(OTHERS=>'0');
> > STAPPB <='1'ï¼›
> > END IF;
> > rd4 := rd3;
> > rd3 := rd2;
> > rd2 := rd1;
> > rd1 := readb; --delay "read" three cycles
> > end if;
> > END PROCESS;

>
> What does STAPPB do? I presume DINA is your write port, WEA your write enable,
> and COUNTRX your address port; is this correct? What generates readb exactly,
> and how is this signal defined?


The signal STAPPB is used for triggering an application. Readb is
generated by the UART output.
>
> Regards,
>
> Pieter Hulshoff




ZHIQUAN
  Reply With Quote
Old 04-18-2007, 07:55 PM   #4
Andy
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
On Apr 18, 9:37 am, ZHIQUAN <threeinchn...@gmail.com> wrote:
> I have a weird question here. When I test the transmission part, the
> first transmission result is correct. But the second time, the
> transmission result sent back are strange numbers instead of the
> result expected. If I push the RESET button, and do again. It
> transmits correct again. So I guess there is something wrong on the
> RESET part. Then I commented the reset part of the program to see what
> the difference is.
> When I go to this part: When I comment the cnt:=(others=>'0') in the
> RESET. Even I push the RESET button, it cannot get correct result. If
> i remove the comment and try again. I push the RESET button, It get
> the correct result. Actually when the program finishes the ·IF
> COUNTRX= NumAllWord1 THEN·The cnt will be clear up to zero. It is
> same to the reset function here. Why it did not get the correct
> result? Or my understanding gets wrong about the use of Variable ?
>
> countRX_inst: process(WRRAMCLK,RESET)
> VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
> RAM PORT A ADDA, 15 BITS
> VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
> for one cycle
> begin
> if (RESET = '1') then
> cnt:=(OTHERS=>'0');
> elsif WRRAMCLK'event and WRRAMCLK = '1' then
> IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
> DINA <= DATAIN; --read data from input-register in uart to
> ram_input input register
> WEA <= '1';
> COUNTRX <= cnt;
> cnt := cnt + "0000000000000001";
> STAPPB <='0';
> END IF;
>
> IF COUNTRX= NumAllWord1 THEN
> WEA <= '0';
> COUNTRX <= (OTHERS=>'0');
> cnt:=(OTHERS=>'0');
> STAPPB <='1'ï¼›
> END IF;
> rd4 := rd3;
> rd3 := rd2;
> rd2 := rd1;
> rd1 := readb; --delay "read" three cycles
> end if;
> END PROCESS;


Simulation is your friend...

You'll find far more bugs faster if you simulate, rather than trying
to debug in the device itself.

Andy



Andy
  Reply With Quote
Old 04-18-2007, 08:17 PM   #5
ZHIQUAN
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
One more thing, does the simulation tool can take into account the
time delay?
Andy wrote:
> On Apr 18, 9:37 am, ZHIQUAN <threeinchn...@gmail.com> wrote:
> > I have a weird question here. When I test the transmission part, the
> > first transmission result is correct. But the second time, the
> > transmission result sent back are strange numbers instead of the
> > result expected. If I push the RESET button, and do again. It
> > transmits correct again. So I guess there is something wrong on the
> > RESET part. Then I commented the reset part of the program to see what
> > the difference is.
> > When I go to this part: When I comment the cnt:=(others=>'0') in the
> > RESET. Even I push the RESET button, it cannot get correct result. If
> > i remove the comment and try again. I push the RESET button, It get
> > the correct result. Actually when the program finishes the ·IF
> > COUNTRX= NumAllWord1 THEN·The cnt will be clear up to zero. It is
> > same to the reset function here. Why it did not get the correct
> > result? Or my understanding gets wrong about the use of Variable ?
> >
> > countRX_inst: process(WRRAMCLK,RESET)
> > VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
> > RAM PORT A ADDA, 15 BITS
> > VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
> > for one cycle
> > begin
> > if (RESET = '1') then
> > cnt:=(OTHERS=>'0');
> > elsif WRRAMCLK'event and WRRAMCLK = '1' then
> > IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
> > DINA <= DATAIN; --read data from input-register in uart to
> > ram_input input register
> > WEA <= '1';
> > COUNTRX <= cnt;
> > cnt := cnt + "0000000000000001";
> > STAPPB <='0';
> > END IF;
> >
> > IF COUNTRX= NumAllWord1 THEN
> > WEA <= '0';
> > COUNTRX <= (OTHERS=>'0');
> > cnt:=(OTHERS=>'0');
> > STAPPB <='1'ï¼›
> > END IF;
> > rd4 := rd3;
> > rd3 := rd2;
> > rd2 := rd1;
> > rd1 := readb; --delay "read" three cycles
> > end if;
> > END PROCESS;

>
> Simulation is your friend...
>
> You'll find far more bugs faster if you simulate, rather than trying
> to debug in the device itself.
>
> Andy




ZHIQUAN
  Reply With Quote
Old 04-18-2007, 09:44 PM   #6
Andy
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
On Apr 18, 2:17 pm, ZHIQUAN <threeinchn...@gmail.com> wrote:
> One more thing, does the simulation tool can take into account the
> time delay?
>
> Andy wrote:
> > On Apr 18, 9:37 am, ZHIQUAN <threeinchn...@gmail.com> wrote:
> > > I have a weird question here. When I test the transmission part, the
> > > first transmission result is correct. But the second time, the
> > > transmission result sent back are strange numbers instead of the
> > > result expected. If I push the RESET button, and do again. It
> > > transmits correct again. So I guess there is something wrong on the
> > > RESET part. Then I commented the reset part of the program to see what
> > > the difference is.
> > > When I go to this part: When I comment the cnt:=(others=>'0') in the
> > > RESET. Even I push the RESET button, it cannot get correct result. If
> > > i remove the comment and try again. I push the RESET button, It get
> > > the correct result. Actually when the program finishes the ·IF
> > > COUNTRX= NumAllWord1 THEN·The cnt will be clear up to zero.. It is
> > > same to the reset function here. Why it did not get the correct
> > > result? Or my understanding gets wrong about the use of Variable ?

>
> > > countRX_inst: process(WRRAMCLK,RESET)
> > > VARIABLE cnt : std_logic_vector(15 DOWNTO 0):=(OTHERS=>'0'); --
> > > RAM PORT A ADDA, 15 BITS
> > > VARIABLE rd1,rd2,rd3,rd4: std_logic:='0'; --delay the read signal
> > > for one cycle
> > > begin
> > > if (RESET = '1') then
> > > cnt:=(OTHERS=>'0');
> > > elsif WRRAMCLK'event and WRRAMCLK = '1' then
> > > IF rd4 = '0' and rd3 = '1' and rd2 = '1' and rd1 ='1' then
> > > DINA <= DATAIN; --read data from input-register in uart to
> > > ram_input input register
> > > WEA <= '1';
> > > COUNTRX <= cnt;
> > > cnt := cnt + "0000000000000001";
> > > STAPPB <='0';
> > > END IF;

>
> > > IF COUNTRX= NumAllWord1 THEN
> > > WEA <= '0';
> > > COUNTRX <= (OTHERS=>'0');
> > > cnt:=(OTHERS=>'0');
> > > STAPPB <='1'ï¼›
> > > END IF;
> > > rd4 := rd3;
> > > rd3 := rd2;
> > > rd2 := rd1;
> > > rd1 := readb; --delay "read" three cycles
> > > end if;
> > > END PROCESS;

>
> > Simulation is your friend...

>
> > You'll find far more bugs faster if you simulate, rather than trying
> > to debug in the device itself.

>
> > Andy


Typical RTL code for synthesis will simulate with "cycle accurate"
timing; in other words, outputs will occur within a few deltas after
the clock that generated them.

You can run post-synthesis or post-routed netlists through simulation
with full timing too, but these take longer to run (gate level models
are not nearly as efficient to simulate as well written RTL).

If you suspect a timing problem, make sure your timing constraints are
accurate, and run a static timing analysis in your P&R tool to find
most of those problems first.

Also, a tool such as chip scope (xilinx), or whatever the equivalent
is for Altera, can help debug live in the device too. I've had the
most luck with those by using them to narrow down the simulation test
cases I needed to isolate the bug in the simulator. These are extra $
tools.

Lastly, you can route suspect internal signals out to spare IO pins
where they can be monitored with scopes or logic analyzers.

Debugging in the device using these last two methods can be helpful if
you don't have a good understanding of what the inputs to the device
are doing (making it difficult to write a simulation model for them).

Andy



Andy
  Reply With Quote
Old 04-19-2007, 01:25 PM   #7
Peter
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
> if (RESET = '1') then
> cnt:=(OTHERS=>'0');
> elsif WRRAMCLK'event and WRRAMCLK = '1' then


Hi,

have you forgot to reset some signals?
Only variable cnt is cleared by RESET, not WEA, COUNTRX etc.

/Peter



Peter
  Reply With Quote
Old 04-19-2007, 04:42 PM   #8
ZHIQUAN
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
Yeah, I reset many things. The previous codes are
if (RESET = '1') then
cnt:=(OTHERS=>'0');
--COUNTRX <=(OTHERS=>'0') ;
--rd1 := '0';
--rd2 := '0';
--rd3 := '0';
--WEA <= '0';
--DINA <= (OTHERS=>'0');
Actually IF COUNTRX= NumAllWord1 THEN WEA <= '0';
COUNTRX <= (OTHERS=>'0');
cnt:=(OTHERS=>'0'); STAPPB <='1';
END IF;
This part has already reset everything to zero and triggered an
application using signal STAPPB.
I cannot remove cnt:=(others=>'0') from 'reset' function; If I remove
'cnt', the transmission result are wrong even I reset it. But if I
keep it, it gets correct result every time I reset it. Others from the
'reset' function doesn't affect the result. That is a weird thing.

Peter wrote:
> > if (RESET = '1') then
> > cnt:=(OTHERS=>'0');
> > elsif WRRAMCLK'event and WRRAMCLK = '1' then

>
> Hi,
>
> have you forgot to reset some signals?
> Only variable cnt is cleared by RESET, not WEA, COUNTRX etc.
>
> /Peter




ZHIQUAN
  Reply With Quote
Old 04-20-2007, 07:48 AM   #9
Pieter Hulshoff
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
ZHIQUAN wrote:

> I have a weird question here. When I test the transmission part, the
> first transmission result is correct. But the second time, the
> transmission result sent back are strange numbers instead of the
> result expected.


Could you be a tad more specific on what you mean by "strange numbers"? As
far as I can tell, incorrect resetting of cnt could only result in a shift
of the bytes. Is that what you see, or are the bytes all scrambled up? Any
chance you could give us an example of input/output of your design?

Regards,

Pieter Hulshoff



Pieter Hulshoff
  Reply With Quote
Old 04-20-2007, 09:43 AM   #10
ZHIQUAN
 
Posts: n/a
Default Re: Cannot transmit correct result consecutively
I transmit 4 data 255,85,170,0. to a RAM and transmit back to Matlab.
First transmit is 255,85,170,0, Next one is
-255, 21760, -22016,0; Then -114,21760,-22016,0; Then -121,21760,
-22016,0

If I push the RESET button, it is 255,85,170,0 again

Thanks for your help.


Pieter Hulshoff wrote:
> ZHIQUAN wrote:
>
> > I have a weird question here. When I test the transmission part, the
> > first transmission result is correct. But the second time, the
> > transmission result sent back are strange numbers instead of the
> > result expected.

>
> Could you be a tad more specific on what you mean by "strange numbers"? As
> far as I can tell, incorrect resetting of cnt could only result in a shift
> of the bytes. Is that what you see, or are the bytes all scrambled up? Any
> chance you could give us an example of input/output of your design?
>
> Regards,
>
> Pieter Hulshoff




ZHIQUAN
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
3 times correct sleeve wrong DVD -oo0(GoldTrader)0oo- DVD Video 3 03-05-2007 04:22 AM
The 10 least politically correct movies ever Fred Goodwin, CMA DVD Video 109 08-10-2006 09:23 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46