






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to declare and instantiate components in vhdl, as well as the use of concurrent statements such as boolean equations, when-else conditional signal assignment, and if-then-else statements. It also covers the use of signals, constants, and data types in vhdl.
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!







entity entity_name is port ( [signal] identifier {, identifier}: [mode] signal_type {; [signal] identifier {, identifier}: [mode] signal_type}); end [entity] [entity_name];
entity register8 is port ( clk, rst, en: in std_logic; data: in std_logic_vector(7 downto 0); q: out std_logic_vector(7 downto 0); end register8;
entity entity-name is generic ( [signal] identifier {, identifier}: [mode] signal-type [:= static_expression] {; [signal] identifier {, identifier}: [mode] signal_type [:= static_expression] } ); port ( [signal] identifier {, identifier}: [mode] signal_type {; [signal] identifier {, identifier}: [mode] signal_type} ); end [entity] [entity_name] ;
entity register_n is generic ( width: integer := 8); port ( clk, rst, en: in std_logic; data: in std_logic_vector(width-1 downto 0); q: out std_logic_vector(width-1 downto 0)) end register_n;
architecture architecture_name of entity is type_declaration | signal _declaration | constant_declaration | component_declaration | alias_declaration | attribute_specification | subprogram_body begin {process_statement | concurrent_signal_assignment_statement | component_instantiation_statement | generate_statement end [architecture] [architecture_name];
architecture archregister8 of register8 is begin process (rst, clk) begin if (rst = ‘1’) then q <= (others => 0); elseif (clk’event and clk = ‘1’) then if (en = ‘1’) then q <= data; else q <= q; end if; end if; end process; end archregister8 ;
architecture archfsm of fsm is type state)type is (st0, st1, st2); signal state: state_type; signal y, z: std_logic; begin process begin wait until clk’ = ‘1’; case state is when st0 => state <= st1; y <= ‘1’; when st1 => state <= st2; z <= ‘1’; when others => state <= st3; y <= ‘0’; z <= ‘0’; end case ; end process ; end archfsm;
component component_name port ( [signal] identifier {, identifier}: [mode] signal_type {; [signal] identifier {, identifier}: [mode] signal_type] ); end component [component_name] ;
component register port ( c1k, rst, en: in std_logic ; data: in std_1ogic_vector(7 downto 0); q: out std_logic_vector(7 downto 0)); end component;
component component_name generic ( [ signal ] identifier {, identifier}: [mode] signal_type [: =static_expression] {; [ signal ] identifier {, identifier}: [mode] signal_type [ : =static_expression] ); port ( [ signal ] identifier {, identifier}: [mode] signal_type {; [ signal ] identifier {, identifier}: [mode] signal_type ); end component [component_name];
component register generic ( width: integer := 8 ); port ( clk, rst, en: in std_logic; data: in std_1ogic_vector(width-1 downto 0); q: out std_logic_vector (width-l downto 0)); end component ;
instantiation_label: component_name port map ( port_name => signal_name | expression | variable_name | open {, port_name => signal_name | expression | variable_name | open });
architecture archreg8 of reg8 is signal clock, reset, enable: std_logic; signal data-in, data-out: std_logic_vector(T downto 0); begin first_reg8: register port map ( clk => clock, rst => reset, en => enable, data => data_in, q => data_out); end archreg8 ;
Instantiation_label: Component_name generic map ( generic_name => signal_name | expression | variable_name | open {, generic_name => signal_name | expression | variable_name | open}) port map ( port_name => signal_name | expression | variable_name | open {, port_name => signal_name | expression | variable_name | open });
architecture archreg5 of reg5 is signal clock, reset, enable: std_logic; signal data_in, data_out: std_logic_vector(7 downto 0); begin first_reg5: register_n generic map (width => 5) --no semicolon here port map ( clk => clock , rst => reset, en => enable, data => data-in, q => data_out); end archreg5;
instantiation_label: component_name port map (signal_name | expression | variable_name | open {, signal_name | expression | variable_name | open});
architecture archreg8 of reg8 is signal clock, reset, enable: std_logic; signal data_in, data_out: std_logic_vector(7 downto 0); begin first_reg8: register port map (clock, reset, enable, data_in, data_out); end archreg8;
[process_label:] process (clock) begin if clock’event and clock = ‘1’ then --or rising_edge synchronous_signal_assignment_statement; end if; end process [process_label]; --------------------------or----------------------------- [process_label:] process begin wait until clock = ‘1’; synchronous_signal_assignment_statement; end process [process_label];
reg8_no_reset: process (clk) begin if clk’event and clk = ‘1’ then q <= data; end if; end process reg8_no_reset; ---------------------------or------------------------------------ reg8_no-reest: process begin wait until clock = ‘1’; q <= data; end process reg8_no_reset;
[process_label:] process (clock) begin if clock’event and clock = ‘1’ then if synch_reset_signal = ‘1’ then synchronous_signal_assignment_statement; else synchronous_signal_assignment_statement; end if; end if; end process [process_label];
reg8_sync_reset: process (clk) begin if clk’event and clk = ‘1’ then if sync_reset = ‘1’ then q <= “0000_0000”; else q <= data; end if; end if; end process;
[process_label:] process (reset, clock) begin if reset = ‘1’ then asynchronous_signal_assignment_statement; elsif clock’event and clock = ‘1’ then synchronous_signal_assignment_statement; end if; end process [process_label];
reg8_async_reset: process (asyn_reset, clk) begin if async_reset = ‘1’ then q <= (others => ‘0’); elsif clk’event and clk = ‘1’ then q <= data; end if; end process reg8_async_reset;
[process_label:] process (reset, preset, clock) begin if reset = ‘1’ then asynchronous_signal_assignment_statement; elsif preset = ‘1’ then asynchronous_signal_assignment_statement; elsif clock’event and clock = ‘1’ then synchronous_signal_assignment_statement; end if; end process [process_label];
reg8_async: process (asyn_reset, async_preset, clk) begin if async_reset = ‘1’ then q <= (others => ‘0’); elsif async_preset = ‘1’ then q <= (others => ‘1’); elsif clk’event and clk = ‘1’ then q <= data; end if; end process reg8_async;
[process_label:] process (reset, clock) begin if reset = ‘1’ then asynchronous_signal_assignment_statement; elsif clocl’event and clock = ‘1’ then if enable = ‘1’ then synchronous_signal_assignment_statement; else synchronous_signal_assignment_statement; end if; end if; end process [process_label];
reg8_sync_assign: process (rst, clk) begin if rst = ‘1’ then q <= (others => ‘0’); elsif clk’event and clk = ‘1’ then if enable = ‘1’ then q <= data; else q <= q; end if; end if; end process reg8_sync_assign;
signal x: bit;
... if x = ‘1’ then state <= idle; else state <= start; end if;
signal a: boolean;
... if x = ‘1’ then state <= idle; else state <= start; end if;
entity counter_n is generic ( width: integer := 8); port ( clk, rst, in std_logic; count: out std_logic_vector(width-1 downto 0)); end counter_n;
... process(clk) begin if (rst = ‘1’) then count <= 0; elsif (clk’event and clk = ‘1’) then count <= count +1; end if; end process;
architecture archfsm of fsm is type state_type is (st0, st1, st2); signal state: state_type; signal y, z: std_logic; begin process begin wait until clk’event = ‘1’; case state is when st0 => state <= st2; y <= ‘1’; z <= ‘0’; when st1 => state <= st3; y <= ‘1’; z <= ‘1’; when others => state <= st0; y <= ‘0’; z <= ‘0’; end case; end process; end archfsm;
architecture archloopstuff of loopstuff is signal data: std_logic_vector(3 downto 0); signal result: std_logic; begin process (data) variable tmp: std_logic; begin tmp := ‘1’; for i in a’range downto 0 loop tmp := tmp and data(i); end loop; result <= tmp; end process; end archloopstuff;
Signal x, data, enable: std_logic;
...
x <= data when enable = ‘1’ else ‘Z’;
Signal x, data, enable: std_ulogic;
... x <= data when enable = ‘1’ else ‘Z’;
signal mux: std_logic_vector (7 downto 0)
... if state = address or state = ras then mux <= dram_a; else mux <= (others => ‘Z’); end if;
variable a, b, c: integer range 0 to 255;
... a <= - (b+2);
signal count: integer range 0 to 255;
... count <= count+1;
signal a, b: bit_vector(4 downto 0); signal c: integer range 0 to 4;
... a<=b sll c;
signal a, b: integer range 0 to 255; signal agtb: std_logic;
... if a >=b then agtb <= ‘1’; else agtb <=’0’;
signal a, b, c:std_logic;
... a<=b and c;