0

i want to initialize my vectors from "0001" instead of "0000" default cause i'm doing an "automatic" 4 Bit multiplier and (x * 0) isn't useful, so I want to skip the "0000" value. Here is my Entity:

ENTITY multiplier IS
PORT (
    clk, rst : IN std_logic;
    q, r : INOUT std_logic_vector (3 DOWNTO 0)  := "0001"; -- this not work
    f : OUT std_logic_vector(7 DOWNTO 0)
); 
END multiplier;
2
  • 1
    'this not work' is not particularly descriptive (specific). Don't use mode inout ports here. Provide a Minimal, Complete, and Verifiable example. Commented Apr 29, 2017 at 17:08
  • How do you create a counter that starts from "0001" instead of "0000"? Commented Apr 29, 2017 at 18:01

1 Answer 1

4

Use intermediate signals

library ieee;
use ieee.std_logic_1164.all;

entity multiplier IS
    port (
        clk : in std_logic;
        rst : in std_logic;
        q : out std_logic_vector(3 downto 0);
        r : out std_logic_vector(3 downto 0);
        f : out std_logic_vector(7 downto 0)
    ); 
end entity;

architecture rtl of multiplier is
    use ieee.numeric_std.all;
    signal q_temp: unsigned(3 downto 0) := "0001"; -- or signed
    signal r_temp: unsigned(3 downto 0) := "0001"; -- or signed
begin
    [...your code...]
    q <= std_logic_vector(q_temp);
    r <= std_logic_vector(r_temp);
end architecture;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.