![Lattice Semiconductor LatticeMico32 Скачать руководство пользователя страница 51](http://html1.mh-extra.com/html/lattice-semiconductor/latticemico32/latticemico32_hardware-developer-user-manual_3843852051.webp)
U
SING
THE
L
ATTICE
M
ICO
S
YSTEM
S
OFTWARE
:
Performing HDL Functional Simulation of LatticeMico32 Platforms
LatticeMico32 Hardware Developer User Guide
45
/*----------------------------------------------------------------------
Clock & Reset
----------------------------------------------------------------------*/
initial begin
reset_n = 0;
#290; // delay 290 ns
reset_n = 1;
end
initial begin
clk_i = 0;
#20; // delay 20 ns
forever #(20) clk_i = ~clk_i; // toggle the clk_i signal every 20ns
end
/*----------------------------------------------------------------------
Trap "Exit" System Call to terminate simulation
----------------------------------------------------------------------*/
reg scall_m, scall_w;
always @(negedge clk_i)
begin
if (Platform_u.Platform_u.LM32.cpu.stall_m == 1'b0)
begin
scall_m <= Platform_u.Platform_u.LM32.cpu.scall_x &
Platform_u.Platform_u.LM32.cpu.valid_x;
scall_w <= scall_m & Platform_u.Platform_u.LM32.cpu.valid_m;
end
// System Call number is passed in r8, Exit System Call is call number 1
if (scall_w && (Platform_u.Platform_u.LM32.cpu.registers[8] == 1))
begin
$display("Program exited with code %0d.\n",
Platform_u.Platform_u.LM32.cpu.registers[1]);
-> done;
end
end
/*----------------------------------------------------------------------
Tasks to perform when simulation terminates
----------------------------------------------------------------------*/
always @(done)
$finish;
endmodule
Figure 20: Testbench File (Continued)