D
Doug Miller
Guest
I'm looking for suggestions for improving the brevity and clarity of my
testbenches when I'm simulating software initialization and interrupt
handling over a microprocessor bus. Currently, I use a pair of processes
such as the following:
bus_simplifier: process(addr,din,op)
begin
if (op = write) then
reg_write <= '1';
reg_read <= '0';
reg_en <= '1';
reg_addr <= addr;
reg_data <= din;
elsif (op = read) then
-- etc....
elsif (op = nop) then
-- etc....
end if;
end process;
up_stim: process
variable up_stim_initflag : std_logic := '0';
begin
if (up_stim_initflag = '0') then
-- Startup conditions
op <= nop;
int_vector <= (others => 'U');
wait until reset='1';
wait until reset='0';
-- Read from register
wait until up_clk='1'
wait for 0.1 ns;
addr <= "X"FC000000";
op <= read;
wait for UP_CLK_PERIOD;
op <= nop;
wait for UP_CLK_PERIOD;
-- Read and write lots more registers...
up_stim_initflag :='1'; -- Set flag so initialization code only
executes once
end if; -- end of initialization
-- Start of interrupt processing
wait until interrupt = '1';
-- Read and write lots of registers to imitate software interrupt
processing
end process;
Can anyone suggest a better way to encapsulate and compact this in a better
way? Ideally, I'd like to reduce the 7 lines below the "--Read from
register" line to a single line, while still making the address, data and
operation type easily readable, so that when I need to initialize lots of
registers, I can write it efficiently.
Thanks,
Doug Miller
testbenches when I'm simulating software initialization and interrupt
handling over a microprocessor bus. Currently, I use a pair of processes
such as the following:
bus_simplifier: process(addr,din,op)
begin
if (op = write) then
reg_write <= '1';
reg_read <= '0';
reg_en <= '1';
reg_addr <= addr;
reg_data <= din;
elsif (op = read) then
-- etc....
elsif (op = nop) then
-- etc....
end if;
end process;
up_stim: process
variable up_stim_initflag : std_logic := '0';
begin
if (up_stim_initflag = '0') then
-- Startup conditions
op <= nop;
int_vector <= (others => 'U');
wait until reset='1';
wait until reset='0';
-- Read from register
wait until up_clk='1'
wait for 0.1 ns;
addr <= "X"FC000000";
op <= read;
wait for UP_CLK_PERIOD;
op <= nop;
wait for UP_CLK_PERIOD;
-- Read and write lots more registers...
up_stim_initflag :='1'; -- Set flag so initialization code only
executes once
end if; -- end of initialization
-- Start of interrupt processing
wait until interrupt = '1';
-- Read and write lots of registers to imitate software interrupt
processing
end process;
Can anyone suggest a better way to encapsulate and compact this in a better
way? Ideally, I'd like to reduce the 7 lines below the "--Read from
register" line to a single line, while still making the address, data and
operation type easily readable, so that when I need to initialize lots of
registers, I can write it efficiently.
Thanks,
Doug Miller