Hello everyone, I am new to VHDL and I like it ! I have a question about usage of signals in VHDL, I have been told that it is more conenient to use signals to connects ports, instead of connecting ports directly. Now I wonder why is that ?! and how to do it a sequential process ? when should the value from the input port should be taken into the signals ? the signal passes the value to the output with the clock edge, so what about the input ?!! Thanks in advance Young
> I have been told that it is more conenient to use signals to connects > ports, instead of connecting ports directly. In my opinion only output ports are affected, because you cannot read back an out port. So given this short sample:
1 | entity runningLED is |
2 | Port ( |
3 | Clk : in STD_LOGIC; |
4 | LED : out STD_LOGIC_VECTOR(7 downto 0) |
5 | );
|
6 | end runningLED ; |
7 | |
8 | architecture Behavioral of runningLED is |
9 | signal LEDs : STD_LOGIC_VECTOR (7 downto 0) := "00000001"; |
10 | begin
|
11 | process begin |
12 | wait until rising_edge(clk); |
13 | if (LEDs="10000000") then -- this would not be possible on the output port "LED" |
14 | LEDs <= "00000001"; |
15 | else
|
16 | LEDs <= LEDs(6 downto 0) & '0'; |
17 | end if; |
18 | end process; |
19 | |
20 | LED <= LEDs; |
21 | end Behavioral; |
thanks so much for your reply. I don't understand why the LED <= LEDs; is not in the end of the process! the output port should take the value each clock, right ?! I believe it should be as a part of the process
If you put the assignment inside the process, you would have another flipflop generated. Here, this assignment is just connecting the output of the internal register, namely LEDs, which updates with each clock to the output of the entity. This is not different to put a wire between the output of an IC to the actual connector on the edge of your board. So, a combinatorial assignment without involving the clocked process is what you need in here.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.