For a lab I have to design a 1-hot-counter, which goes through four states. The state variables are Y3-Y0.
I wrote the VHDL code and it seems to work fine under the condition that I clear first. The simulation doesnt work until the point in time where I bring the clear high.
entity mycount is
Port ( CLR,C1,C0,CLK : in std_logic;
Z1,Z0,UP,DN,MT : out std_logic;
Y3,Y2,Y1,Y0 : buffer std_logic);
end mycount;
architecture Behavioral of mycount is
begin
process(CLK,CLR)
begin
if(CLR='1') then
Y3<='0';
Y2<='0';
Y1<='0';
Y0<='1';
elsif (rising_edge(CLK)) then
Y3<=(Y2 AND NOT C1 AND C0) OR (Y0 AND C1 AND NOT C0) OR (Y3 AND (C1 XNOR C0));
Y2<=(Y1 AND NOT C1 AND C0) OR (Y3 AND C1 AND NOT C0) OR (Y2 AND (C1 XNOR C0));
Y1<=(Y0 AND NOT C1 AND C0) OR (Y2 AND C1 AND NOT C0) OR (Y1 AND (C1 XNOR C0));
Y0<=(Y3 AND NOT C1 AND C0) OR (Y1 AND C1 AND NOT C0) OR (Y0 AND (C1 XNOR C0));
end if;
Z1<= Y3 or Y2;
Z0<= Y3 or Y1;
UP<= NOT C1 AND C0;
DN<= C1 AND NOT C0;
MT<= C1 XNOR C0;
end process;
end Behavioral;
So what Im not quite sure how to do is set the initial state variables (to tell it to start in state 0001 for example). Whats the syntax in VHDL for that?
I wrote the VHDL code and it seems to work fine under the condition that I clear first. The simulation doesnt work until the point in time where I bring the clear high.
entity mycount is
Port ( CLR,C1,C0,CLK : in std_logic;
Z1,Z0,UP,DN,MT : out std_logic;
Y3,Y2,Y1,Y0 : buffer std_logic);
end mycount;
architecture Behavioral of mycount is
begin
process(CLK,CLR)
begin
if(CLR='1') then
Y3<='0';
Y2<='0';
Y1<='0';
Y0<='1';
elsif (rising_edge(CLK)) then
Y3<=(Y2 AND NOT C1 AND C0) OR (Y0 AND C1 AND NOT C0) OR (Y3 AND (C1 XNOR C0));
Y2<=(Y1 AND NOT C1 AND C0) OR (Y3 AND C1 AND NOT C0) OR (Y2 AND (C1 XNOR C0));
Y1<=(Y0 AND NOT C1 AND C0) OR (Y2 AND C1 AND NOT C0) OR (Y1 AND (C1 XNOR C0));
Y0<=(Y3 AND NOT C1 AND C0) OR (Y1 AND C1 AND NOT C0) OR (Y0 AND (C1 XNOR C0));
end if;
Z1<= Y3 or Y2;
Z0<= Y3 or Y1;
UP<= NOT C1 AND C0;
DN<= C1 AND NOT C0;
MT<= C1 XNOR C0;
end process;
end Behavioral;
So what Im not quite sure how to do is set the initial state variables (to tell it to start in state 0001 for example). Whats the syntax in VHDL for that?
