Altera_Forum
Honored Contributor
9 years agoParallel VHDL
Hi all,
Q1. I cam across this nice piece of code for a parallel barrel shifter from a book. I could barely understand it at first so I am wondering what level of expertise is this code at. Are there any particular tools that can convert diagrams or some sort of instructions into compact and effective code like this one or is it just experience that gets one there? If the latter, what is the methodology to write code like this for other particular situations, like a multiplier for example?library ieee;
use ieee.std_logic_1164.all;
entity barrel is port(
in0 : in std_logic_vector(15 downto 0);
s : in std_logic_vector(3 downto 0);
y : out std_logic_vector(15 downto 0));
end barrel;
architecture rtl of barrel is
constant n : integer := 16;
constant m : integer := 4;
type arytype is array(m downto 0) of std_logic_vector (n-1 downto 0);
signal intsig, left, pass : arytype;
signal zeros : std_logic_vector(n -1 downto 0);
begin
zeros <= (others => '0');
intsig(0) <= in0;
muxgen : for j in 1 to m generate
pass(j) <= intsig(j-1);
left(j) <= intsig(j-1)(n-2**(j-1)-1 downto 0) & zeros(2**(j-1)-1 downto 0);
intsig(j)<= pass(j) when s(j-1) = '0' else left(j);
end generate;
y <= intsig(m);
end rtl; Q2. I am designing a small cpu with vhdl. I am simulating the whole project in Modelsim and since I have the instructions loaded onto the memory wired to the cpu, i don't require a testbench necessarily. I am struggling though trying to figure out if all is working as should be as there are couple of signals and things going on. I added signals to a list window but wasn't of much use as I cannot open it with excel. Do you guys use any techniques to automate testing other than a testbench? Something that verifies each step? Looking forward for your ideas...