?? testbench.vhd
字號:
msel(1) := PSEL(2) or PSEL(3) or PSEL(6) or PSEL(7) or PSEL(10) or PSEL(11) or PSEL(14) or PSEL(15);
msel(2) := PSEL(4) or PSEL(5) or PSEL(6) or PSEL(7) or PSEL(12) or PSEL(13) or PSEL(14) or PSEL(15);
msel(3) := PSEL(8) or PSEL(9) or PSEL(10) or PSEL(11) or PSEL(12) or PSEL(13) or PSEL(14) or PSEL(15);
mint := conv_integer(clean(msel));
PRDATAMUX <= PRDATA(mint);
end process;
--------------------------------------------------------------------------------
-- The APB Models, one per active slot
UM: for i in 0 to PARA_APB_SDEPTH-1 generate
UMOD: APBModel
generic map ( ID => i,
DEBUG => PARA_DEBUG,
AWIDTH => PARA_APB_AWIDTH,
DWIDTH => PARA_APB_DWIDTH
)
port map ( PCLK => PCLK,
PRESETN => PRESETN,
PENABLE => PENABLE,
PWRITE => PWRITE,
PSEL => PSEL(i),
PADDR => PADDR,
PWDATA => PWDATA,
PRDATA => PRDATA(i),
PREADY => PREADY
);
end generate;
--------------------------------------------------------------------------------
-- Monitor IO_OUT for test conditions
process(IO_OUT,IOSWITCH,IOWAITIN,INTACT)
begin
if IOSWITCH='0' then
IO_IN <= IO_OUT(PARA_IIWIDTH-1 downto 0);
else
IO_IN(0) <= INTACT;
IO_IN(1) <= IOWAITIN;
end if;
end process;
process(PCLK,PRESETN)
variable status : integer;
variable icount : integer;
variable wcount : integer;
begin
if PRESETN='0' then
FINISHED <= FALSE;
INTREQ <= '0';
ICOUNT :=0;
WCOUNT := 0;
IOWAITIN <= '0';
IOSWITCH <= '0';
STATUSSTR <= "FAIL";
elsif PCLK'event and PCLK='1' then
status := conv_integer(IO_OUT(7 downto 0));
if INITDONE='1' then
icount := icount +1;
end if;
case status is
when 249 => -- Switch IO_IO to monitor outputs, and assert WAITTST for 10 clocks
IOSWITCH <= '1';
if IOSWITCH='0' then
WCOUNT := 40;
printf("Info: IO_IN now monitoring test signals");
end if;
when 250 => -- Switch IO to normal mode
IOSWITCH <= '0';
if IOSWITCH='1' then
printf("Info: IO_IN now monitoring IO_OUT");
end if;
when 251 => if INTREQ='0' then
printf("Info: ABC Asserting Interrupt Request");
INTREQ <= '1';
end if;
when 252 => INTREQ <= '0';
when 253 => if not FINISHED then
printf("Info: ABC Indicated that it has completed");
STATUSSTR <= "OKAY";
FINISHED <= TRUE;
end if;
when 254 => printf("################################################################");
printf("Error: ABC Indicated that it had an error condition");
assert FALSE
report "APB Error Detected"
severity ERROR;
when others =>
end case;
if WCOUNT>0 then
IOWAITIN <= '1';
WCOUNT := WCOUNT -1;
else
IOWAITIN <= '0';
end if;
CYCLES <= icount;
if icount= 4000 then
printf("################################################################");
printf("################################################################");
assert FALSE
report "Error: Simulation RUN To Long"
severity ERROR;
end if;
end if;
end process;
--------------------------------------------------------------------------------
-- The Test Sequence
process
variable ERRORS : integer;
begin
STOPCLK <= FALSE;
PRESETN <= '0';
ERRORS := 0;
wait for 1 ns;
printf("################################################################");
printf("CoreABC VHDL Testbench v2.3 1 March 2007");
printf("(c) Actel IP Engineering");
printf(" ");
if (PARA_TESTMODE=0 ) then
printf(" ");
printf("Testbench is being run with TESTMODE set to 0 enabling the User Instructions");
printf("Operation of the testbench will be unpredictable");
printf("Note. A memory image file may be created by typing do makehex.do at the ModelSim Prompt");
printf(" ");
assert FALSE
report "Restart if required using run -all"
severity WARNING;
end if;
if (INSMODE=2 and FAMILY/=17 ) then
printf(" ");
assert FALSE
report "Attempting to run in NVM mode in non Fusion Family - Reverting to hard mode"
severity WARNING;
end if;
printf("Configuration (TM:%d) ",fmt(PARA_TESTMODE));
case PARA_TESTMODE is
when 0 => printf(" Configuration as set by CoreConsole");
when 1 => printf(" Small 8 bit");
when 2 => printf(" Small 16 bit");
when 3 => printf(" Small 32 bit");
when 4 => printf(" Complete 8 bit");
when 5 => printf(" Complete 16 bit");
when 6 => printf(" Complete 32 bit");
when 11 => printf(" Fully Configured 8 Bit Configuration");
when 12 => printf(" Fully Configured 16 Bit Configuration");
when 13 => printf(" Fully Configured 32 Bit Configuration");
when 14 => printf(" Small 8 Bit Configuration with call");
when 15 => printf(" Small 8 Bit Configuration no call and 1 slot");
when 16 => printf(" Example for controlling CoreAI");
when 20 to 31 => printf(" Corner case builds");
when others => printf("Not a configured core ");
assert FALSE report "Unexpected testmode" severity FAILURE;
end case;
printf(" Family : %d" ,fmt(PARA_FAMILY));
printf(" ID : %d" ,fmt(PARA_ID));
printf(" APB Address Width: %d" ,fmt(PARA_APB_AWIDTH));
printf(" APB Data Width: %d " ,fmt(PARA_APB_DWIDTH));
printf(" APB Slots: %d " ,fmt(PARA_APB_SDEPTH));
printf(" IO In Width: %d " ,fmt(PARA_IIWIDTH));
printf(" IO Flag Width: %d " ,fmt(PARA_IFWIDTH));
printf(" IO Out Width: %d " ,fmt(PARA_IOWIDTH));
printf(" Instructions: %d " ,fmt(2**PARA_ICWIDTH));
if PARA_INSMODE=0 then
printf(" Instruction held in Tiles ");
elsif PARA_INSMODE=1 then
printf(" Instruction held in RAM ");
elsif PARA_INSMODE=2 then
printf(" Instruction held in NVM ");
end if;
printf(" Stack Depth: %d " ,fmt(2**PARA_STWIDTH));
printf(" Loop Counter Size %d" ,fmt(2**PARA_ZRWIDTH));
printf(" OR instruction %s" ,fmt(tostr(PARA_EN_OR)));
printf(" AND instruction %s" ,fmt(tostr(PARA_EN_AND)));
printf(" XOR instruction %s" ,fmt(tostr(PARA_EN_XOR)));
printf(" ADD instruction %s" ,fmt(tostr(PARA_EN_ADD)));
printf(" INC instruction %s" ,fmt(tostr(PARA_EN_INC)));
printf(" SHL instruction %s" ,fmt(tostr(PARA_EN_SHL)));
printf(" SHR instruction %s" ,fmt(tostr(PARA_EN_SHR)));
printf(" CALL instruction %s" ,fmt(tostr(PARA_EN_CALL)));
printf(" MULT instruction %s" ,fmt(tostr(PARA_EN_MULT)));
printf(" PUSH instruction %s" ,fmt(tostr(PARA_EN_PUSH)));
printf(" IOREAD instruction %s" ,fmt(tostr(PARA_EN_IOREAD)));
printf(" IOWRT instruction %s" ,fmt(tostr(PARA_EN_IOWRT)));
printf(" Accumulator RAM operations %s",fmt(tostr(PARA_EN_ALURAM)));
printf(" Indirect APB operations %s",fmt(tostr(PARA_EN_INDIRECT)));
printf(" ACM lookup %s" ,fmt(tostr(PARA_EN_ACM)));
printf(" Multiplexer Mode %d" ,fmt(PARA_EN_DATAM));
printf(" Storage Registers %s " ,fmt(tostr(PARA_EN_RAM)));
if PARA_EN_INT=1 then
printf(" Interrupt Enabled ISR at %04x" ,fmt(PARA_ISRADDR));
else
printf(" Interrupt Disabled");
end if;
printf(" ");
case SET_DEBUG is
when 0 => printf(" DEBUG forced off by the testbench");
when 1 => printf(" DEBUG forced on by the testbench");
when others =>
end case;
if SET_TM>=0 then
printf(" TESTMODE set to %d by the testbench",fmt(SET_TM));
end if;
printf(" ");
checksetup(APBsetupX);
wait for 400 ns;
if ENABLE_HEXFILE then
wait for (10 * 2**PARA_ICWIDTH) * 1 ns;
end if;
wait until PCLK='0';
printf("Releasing Reset and letting core operate");
printf(" ");
PRESETN <= '1';
wait until FINISHED;
STOPCLK <= TRUE;
printf(" ");
printf("################################################################");
printf("Tests Complete TM=%d SP=%d CY=%d %s",fmt(PARA_TESTMODE)&fmt(SET_PROG)&fmt(CYCLES)&fmt(statusstr));
printf("");
printf("################################################################");
wait;
end process;
end test;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -