OK, so ... i attatched the Testbench and a startingpoint for the
fivebit.vhd description.
The only data which is stored in this description are the bits in the
register:
1 | signal data: std_logic_vector(4 downto 0):=(others => '0');
|
The output is directly connected to the content of the register:
then we use a clocked process, so everything is triggered with the
rising edge of clock:
1 | process begin
|
2 | wait until rising_edge(clock);
|
3 | .
|
4 | .
|
5 | .
|
6 | end process;
|
The reset "res" is synchron with the clock, read as "if res = '1' and a
rising edge of clk happens" then the reset is executed. asynchron reset
should not be used in modern FPGAs.
After the reset there is the MUX which can be written as many
1 | if SEL = "001" then data <= whatever_you_like;
|
2 | elsif SEL = "010" then data <= whatever_you_like;
|
3 | else data <= whatever_you_like;
|
4 | end if;
|
it can also be written like
1 | case SEL is
|
2 | when "001" => data <= whatever_you_like;
|
3 | when "010" => data <= whatever_you_like;
|
4 | when others => data <= whatever_you_like;
|
5 | end case;
|
The "when others" case is mandatory. in the fivebit.vhd i used if ..
else description.
I wrote the first 4 entrys:
1 | if SEL = "000" then data <= (others => '0'); --Reset
|
2 | elsif SEL = "001" then data <= INP; --Parallel loading
|
3 | elsif SEL = "010" then data <= '0' & data(4 downto 1); --Right shift
|
4 | elsif SEL = "011" then data <= data(3 downto 0) & '0'; --Left shift
|
the rest is left for you. circular right/left shift is like normal
right/left shift but with the bit falling out at one end shifted in the
other end again.
I still don't really understand what should happen to the bits in the
register with 1s or 2s complement selected. And with normal right/left
shift this
1 | elsif SEL = "010" then data <= '0' & data(4 downto 1);
|
shifts right, and the leftmost bit is filled with '0'. Is this how it
shold be or should the leftmost bit be for example a new bit from the
input?
like data <= INP(0) & data(4 downto 1) or so ...