Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Help needed in Control Unit VHDL

Reply
Thread Tools

Help needed in Control Unit VHDL

 
 
DanielGoh DanielGoh is offline
Junior Member
Join Date: Oct 2010
Posts: 1
 
      10-16-2010
Hello, currently I am VHDL code for Control Unit (CU) for GCD Calculator. Here is my code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity CU is
port(clk, reset, start, Eq, Lt : in std_logic;
y : buffer std_logic;
CtrlVec : out std_logic_vector (6 downto 0);
done : out std_logic);
end CU;

architecture CU_arch of CU is
type state is (S0,S1);
signal PS, NS : std_logic;

begin
y <= PS; --- ERROR!!!
STATE_REG:
process(clk, reset) begin
if (reset = '1') then PS <= S0;
elsif (clk'event and clk = '0') then PS <= NS;
end if;
end process STATE_REG;

NS_LOGIC:
process (PS, start, Eq) begin
case PS is
when S0 => if start = '1' then NS <= S1; else NS <= S0; end if;
when S1 => if Eq = '1' then NS <= S0; else NS <= S1; end if;
end case;
end process NS_LOGIC;

OUTPUT_LOGIC:
process (PS, start, Eq, Lt) begin
CtrlVec <= (others => '0'); done <= 0;
case PS is
when S0 => if start = '1' then CtrlVec <= "0111100"; end if;
when S1 => if Eq = '1' then done <= '1'; CtrlVec <= "1000000";
elsif Lt = '1' then CtrlVec <= "0000100";
else CtrlVec <= "0010011";
end if;
end case;
end process OUTPUT_LOGIC;
end CU_arch;


My problem is: How to make the PS as output? I have to display the output y and y should be PS. Thanks!
 
Reply With Quote
 
 
 
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 153
 
      10-16-2010
I'm seeing these errors:

- You're assigning values of type 'state' to 'PS' and 'NS', but you declared them as std_logic
- You're assiging 0 to done -- probably a typo, it should be '0' (note the quotes)

To fix the problem of assigning PS to y, you can use these ideas:

- Using an constant array describing the mapping
Code:
-- in declaration area
type state_mapping is array(state) of std_logic;
constant mapping : state_mapping := (S0 => '0', S1 => '1');

-- in implementation area
y <= mapping(PS);
Or, when you find you need more complicated mappings, use a function,
Code:
-- in declaration area
function mapping(s : state) return std_logic is
begin
  case s is
    when S0 => return '0';
    when S1 => return '1';
  end case;
end;

-- in implementation area
y <= mapping(PS);
 
Reply With Quote
 
 
 
 
soonph87 soonph87 is offline
Junior Member
Join Date: Oct 2010
Posts: 2
 
      10-17-2010
hi, error still exists saying that PS does not agree with its usage as "state" type.
 
Reply With Quote
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 153
 
      10-17-2010
You have to declare PS as having type 'state' instead of 'std_logic'
 
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
User Friendly Easy To Install Unit For Voip Like Vonage Unit SuggestionsPlease? Heidy UK VOIP 1 06-22-2007 09:53 AM
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
unit--, a unit test framework for C++ VvanN C++ 5 04-28-2006 10:01 AM
connect a source unit with an S-Video connection to a receiving unit that has an RCA composite video connection ? worth it ? OCZ Guy DVD Video 6 08-01-2004 05:44 PM
Connect a source unit DVD with an S-Video connection to a receiving unit TV that has an RCA composite video connection Worth it. OCZ Guy Computer Information 0 07-31-2004 12:29 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