?? lab_mc_driver2.e
字號:
File: lab_mc_driver.e
<'
unit lab_mc_driver_u { -- Define the driver as a unit
//===================== Below are definitions ===================
// define event, variables for generation
//===============================================================
event mc_clk is rise('mc_clk_i')@sim;
-- this is the delay between the generations
!mc_delay: uint(bits: 9);
-- This value will be the input of the dut
!mc_input: uint(bits: 24);
keep mc_input[15:8] >= mc_input[7:0];
-- This counter is used to control the times of the generation
!counter: uint(bits:7);
keep soft counter in [30..100];
//===================== Below are constrains for generation =====
// do a one-cycle reset at the beginning of the simulation
//===============================================================
-- control the generation value
-- keep soft mc_delay == select {
-- 10: 1;
-- 20: 2;
-- 30: 501;
-- };
-- keep soft mc_input == select {};
//===================== Below is initial reset===================
// do a one-cycle reset at the beginning of the simulation
//===============================================================
-- This reset will be called at the beginning of the simulation
mc_reset_init() @mc_clk is {
'mc_reset_i' = 1;
wait [1];
'mc_reset_i' = 0;
};
//===================== Below are generation and driver =========
// generate input and drive it to dut
//===============================================================
gen_counter: uint(bits:7);
keep soft gen_counter == 0;
mc_gen_and_drive() @mc_clk is {
wait [1];
gen counter;
outf("\ncounter is %b", counter);
while (gen_counter < counter) {
gen mc_delay; -- gen mc_input; if 'mc_reset_i' == 1 then { gen mc_input; } else if
'mc_reset_i' == 0 and 'mc_pwme_o' == 1 then { mc_input[23:16] += 1; } else if
'mc_reset_i' == 0 and 'mc_pwme_o' == 0 then { mc_input[23:16] -= 1; };
--'mc_reset_i' = mc_input[24:24];
'mc_speed_now_i' = mc_input[23:16];
'mc_target_speed_i' = mc_input[15:8];
'mc_min_speed_i' = mc_input[7:0];
outf("\ndrive input into signal %b at %d", mc_input, sys.time);
wait [mc_delay];
--outf("\nafter %d cycles, current counter is %d at %d.",mc_delay, gen_counter, sys.time);
gen_counter += 1;
};
stop_run();
};
//===================== Below are starting of TCMs ==============
// start initial reset and gen_and_drive methods
//===============================================================
run() is also {
-- at the beginning of the simulation, do a reset
start mc_reset_init();
start mc_gen_and_drive();
};
};
'>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -