amd1416
Newbie level 5
Hi everyone,
I am designing a 4 bit up and down counter that when counting up has a programmable modulo value.
Here is my code for the whole counter with modulo but I keep getting errors that I don't know how to solve.
Here is the code for the 4 bit register used to control the modulo value:
here are the errors I get for the main code:
I am designing a 4 bit up and down counter that when counting up has a programmable modulo value.
Here is my code for the whole counter with modulo but I keep getting errors that I don't know how to solve.
Code VHDL - [expand] 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 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter4bit is port( mod_value: in std_logic_vector(0 to 3); clock: in std_logic; enable_count: in std_logic; reset: in std_logic; direction: in std_logic; output_counter: out std_logic_vector(0 to 3) ); end counter4bit; architecture structural of counter4bit is component register4bit is port( Din : in std_logic_vector(3 downto 0); en : in std_logic; clock : in std_logic; reset : in std_logic; Dout : out std_logic_vector(3 downto 0)); end component; signal dig, tmp: std_logic_vector(3 downto 0); begin mod1: register4bit port map (tmp(0) <= Dout(0), tmp(1) <= Dout(1),tmp(2) <= Dout(2),tmp(3) <= Dout(3), Din(0) <= mod_value(0), Din(1) <= mod_value(1), Din(2) <= mod_value(2), Din(3) <= mod_value(3), reset <= reset, clock <= clock, en < reset); process(Clock,Reset) begin if Reset='1' then dig <= "0000"; elsif ( rising_edge(clock)) then if (enable_count<='1' and direction<='0') then if dig <= "tmp(3)tmp(2)tmp(1)tmp(0)" then dig <= "0000"; else dig <= dig + 1; if (enable_count<='1' and direction<='1') then dig <= dig - 1; end if; end if; end if; end if; end process; output_counter <= dig; end structural;
Here is the code for the 4 bit register used to control the modulo value:
Code VHDL - [expand] 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 58 59 60 61 62 63 64 65 66 67 68 69 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.numeric_std.all; -- TOP VHDL design which implements a 8-bit Universal Shift Register entity register4bit is port ( Din : in std_logic_vector(3 downto 0); EN : in std_logic; Clock : in std_logic; Reset : in std_logic; Dout : out std_logic_vector(3 downto 0)); end entity register4bit; --// End of entity --// This is an architecture of 4-bits universal shift register architecture structural of register4bit is component D_flip_flop is port ( D : in std_logic; EN : in std_logic; Clock : in std_logic; Reset : in std_logic; Q : out std_logic); end component; begin U1: D_flip_flop port map(D => Din(0), EN => EN, Clock => Clock, Reset => Reset, Q=> Dout(0)); U2: D_flip_flop port map(D => Din(1), EN => EN, Clock => Clock, Reset => Reset, Q=> Dout(1) ); U3: D_flip_flop port map(D => Din(2), EN => EN, Clock => Clock, Reset => Reset, Q=> Dout(2) ); U4: D_flip_flop port map(D => Din(3), EN => EN, Clock => Clock, Reset => Reset, Q=> Dout(3) ); end structural; Here is the code for the d-type flip flop used to do the register: library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.numeric_std.all; -- TOP VHDL design which implements a 8-bit Universal Shift Register entity D_flip_flop is port ( D : in std_logic; EN : in std_logic; Clock : in std_logic; Reset : in std_logic; Q : out std_logic); end entity D_flip_flop; --// End of entity --// This is an architecture of 4-bits universal shift register architecture RTL of D_flip_flop is begin PROCESS ( Clock, Reset ) BEGIN IF Reset = '1' THEN Q <= '0'; ELSIF rising_edge(Clock) THEN Q <= D; END IF; END PROCESS; end RTL; -- End of architectural block
here are the errors I get for the main code:
Error (10482): VHDL error at counter4bit.vhd(29): object "Dout" is used but not declared
Error (10482): VHDL error at counter4bit.vhd(29): object "Din" is used but not declared
Error (10558): VHDL error at counter4bit.vhd(29): cannot associate formal port "Dout" of mode "out" with an expression
Error (10589): VHDL Port Map Aspect error at counter4bit.vhd(29): too many actuals for block "register4bit" with only 5 formals
Error (10784): HDL error at counter4bit.vhd(17): see declaration for object "register4bit"
Error: Quartus II 32-bit Analysis & Synthesis was unsuccessful. 5 errors, 1 warning
Error: Peak virtual memory: 361 megabytes
Error: Processing ended: Wed Mar 09 14:41:42 2016
Error: Elapsed time: 00:00:01
Error: Total CPU time (on all processors): 00:00:01
Error (293001): Quartus II Full Compilation was unsuccessful. 7 errors, 1 warning