How to write vectors in VHDL

OP #3901177
Rate this post
• ▲ useful
▼ not useful
I would like to ask, how can I write vectors in VHDL.

Below I have written the VHDL code in Integers, But I am having 
difficulties in writing it as Vectors?

The equation I am working with to find the correct answer from Waveform 
is:

FX= A0 +A1x +A2^x2 +A3^x3
1
ENTITY Polynomial1 IS
2
PORT ( clk, res : IN BIT;
3
ai, x : IN INTEGER:=0; 
4
fx : OUT INTEGER:=0);
5
END Polynomial1;
6
ARCHITECTURE bhv OF Polynomial1 IS SIGNAL reg : INTEGER:=0;
7
BEGIN
8
PROCESS
9
BEGIN
10
WAIT UNTIL (clk'EVENT AND clk = '1');
11
IF res = '1' THEN reg <= 0; 
12
ELSE reg <= x * (ai + reg);
13
END IF;
14
END PROCESS;
15
fx <= reg + ai; 
16
END bhv;



I have had a go at Vectors with assumable bits:

1
ENTITY Polynomial1 IS
2
PORT ( clk, reset : IN STD_LOGIC;
3
a0, a1, a2, a3 : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
4
x : IN  STD_LOGIC_VECTOR (1 DOWNTO 0);
5
fx: OUT  STD_LOGIC_VECTOR(8 DOWNTO 0)) ;
6
END Polynomial1;

I would like to apologies if i have made any format mistakes.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.