Forum Discussion
Altera_Forum
Honored Contributor
15 years agoVHDL problem?
QUESTION:
Develop a VHDL model for an accumulator that calculates the sum of a sequence of fixed-point numbers. Each input number is signed with 4 pre-binary-point and 12 post-binary-point bits. The accumulated sum has 8 pre-binary-point and 12 post-binary-point bits. A new number arrives at the input during a clock cycle when the data_en control input is 1. The accumulated sum is cleared to 0 when the reset control input is 1. Both control inputs are synchronous. DOUBT: I want to ask how to insert the first input and second input as it using the pre and post numbers? How to store the value for the first input for awhile before it add the second input? The output will light up using LED at the board that we assign it by ourselves. library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; entity accumulator is port (clk,reset, data_en : in std_logic; data_in : in signed(15 downto 0); data_out : out signed(19 downto 0) ); end entity accumulator; architecture rtl of accumulator is signal sum, new_sum :signed(19 downto 0); begin new_sum <= sum + resize(data_in, sum'length); reg:process (clk) is begin if rising_edge(clk) then if reset = '1' then sum <= (others => '0'); elsif data_en = '1' then sum <= new_sum; end if; end if; end process reg; data_out <= sum; end architecture rtl; -KYRA-:)17 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- You can do this by passing first 10 bits during clock high and another 10 bits during clock low. --- Quote End --- can i know what is the suitable code to do the passing bits process? - Altera_Forum
Honored Contributor
--- Quote Start --- based on code above,there is up until 20-bits,but on the DE2 usb blaster board,there is only enough for up until 10-bits.can i know how to re-make the code so it will synchronize with the pins available on the board? --- Quote End --- You can do this by passing first 10 bits during clock high and another 10 bits during clock low. - Altera_Forum
Honored Contributor
based on code above,there is up until 20-bits,but on the DE2 usb blaster board,there is only enough for up until 10-bits.can i know how to re-make the code so it will synchronize with the pins available on the board?
- Altera_Forum
Honored Contributor
--- Quote Start --- for store the value for the first input for a while before it add the second input, is stored in a register --- Quote End --- It will be stored in sum. It wont change until the next data value arrives - Altera_Forum
Honored Contributor
i wanna ask how to store value in register and synchronize it with usb blaster?what is the code to be use in the programing?i search through the internet but can't understand it..hope anybody can help asap,,,
- Altera_Forum
Honored Contributor
for store the value for the first input for a while before it add the second input, is stored in a register
- Altera_Forum
Honored Contributor
i dont understand your questions. The code you posted does what the question asks.