Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Problem with operation

Reply
Thread Tools

Problem with operation

 
 
Chandru.Kundagol@gmail.com
Guest
Posts: n/a
 
      04-21-2006
I hav the follwoing simple code which does left shifting operation.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity counter is
port (
q: inout STD_LOGIC_VECTOR (3 downto 0);
clock: in STD_LOGIC;
reset: in STD_LOGIC;
en: in STD_LOGIC
);
end counter;


architecture counter of counter is
signal count:std_logic_vector(3 downto 0):="0000";
begin


process(clock,reset)
begin


if reset='0' then
count<="0000";
elsif(clock='1') then
if en='1' then


l1: for i in 1 to 3 loop
count(i)<=q(i-1);
end loop l1;
count(0)<='0';


else
count<=q;
end if;
end if;
q<=count; -- The q value is not getting updated with
the count
value.
end process;


end counter;


The problem with this code is that the q(port) value is not getting
updated with count value,though count gets updated.I did single step
execution,i see the statement q<=count being executed.I used the tool
Active HDL 4.2.PLEASE HELP....

 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      04-21-2006
Move the "q<=count;" statement outside of the process.

i.e..
process
.....
end process;

q<=count;

KJ

<> wrote in message
news: oups.com...
>I hav the follwoing simple code which does left shifting operation.
>
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_unsigned.all;
> entity counter is
> port (
> q: inout STD_LOGIC_VECTOR (3 downto 0);
> clock: in STD_LOGIC;
> reset: in STD_LOGIC;
> en: in STD_LOGIC
> );
> end counter;
>
>
> architecture counter of counter is
> signal count:std_logic_vector(3 downto 0):="0000";
> begin
>
>
> process(clock,reset)
> begin
>
>
> if reset='0' then
> count<="0000";
> elsif(clock='1') then
> if en='1' then
>
>
> l1: for i in 1 to 3 loop
> count(i)<=q(i-1);
> end loop l1;
> count(0)<='0';
>
>
> else
> count<=q;
> end if;
> end if;
> q<=count; -- The q value is not getting updated with
> the count
> value.
> end process;
>
>
> end counter;
>
>
> The problem with this code is that the q(port) value is not getting
> updated with count value,though count gets updated.I did single step
> execution,i see the statement q<=count being executed.I used the tool
> Active HDL 4.2.PLEASE HELP....
>



 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      04-22-2006
The other problem is that 'q' is defined to be a bi-directional signal but
nowhere in the architecture is 'q' ever set to a weak (and therefore
overridable) value such as 'Z'. In fact 'q' is always being actively driven
by 'counter' which means it really is an output only (VHDL type 'buffer'
since it is read from within the architecture as well). This implies that
there is no way to input anything into 'counter' to initialize 'q' at all.

If 'q' really does need to be bi-directional for some reason, then there has
to be some other control input signal that tells the entity when 'q' is an
input and when it's an output. When it's being used as an input than the
entity should be driving 'q <= (others => 'Z')'. The logic for loading
should also then look at this new input to tell it when it should be loading
from 'q' or when it should be shifting.

The other alternative is that there should simply be a 'd' input vector and
a 'q' output vector and data gets loaded from 'd'.

> entity counter is
> port (
> q: inout STD_LOGIC_VECTOR (3 downto 0);
> clock: in STD_LOGIC;
> reset: in STD_LOGIC;
> en: in STD_LOGIC
> );
> end counter;


KJ


 
Reply With Quote
 
Hilko
Guest
Posts: n/a
 
      04-24-2006
If you want to trigger your process with a rising slope of signal
"clock" then change the line
"elsif(clock='1') then" with "elsif rising_edge(clock) then"

Hilko

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      04-24-2006
Try

process (reset, clock) is
begin
if reset = '0' then
q <= (others => '0');
elsif rising_edge(clock) then
if en = '1' then
q <= q(2 downto 0) & '0';
end if;
end if;
end process;


No need for intermediate signal/variable.

Andy

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boolean operation and arithmetic operation Buzz Lightyear C++ 10 08-12-2009 01:27 PM
I/O operation, file operation behaviou raan C++ 2 08-16-2007 07:13 PM
Problem with shift operation Chandru.Kundagol@gmail.com VHDL 3 04-24-2006 02:55 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
Operation must use an updatable query - user problem Mr. x ASP .Net 1 11-06-2003 02:52 PM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57