?? lab_mc_driver.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 resets
!reset_delay: uint(bits: 13);
keep soft reset_delay in [700..900]; -- this is the delay between the generations
!mc_delay: uint(bits: 9);
keep soft mc_delay in [0..5];
-- This value will be the input of the speed now !mc_speed_now: uint(bits: 13); keep soft mc_speed_now == 0; -- This value will be the input of the target speed !mc_target_speed: uint(bits: 13); --keep soft mc_target_speed in [500..700]; -- This value will be the input of the min speed !mc_min_speed: uint(bits: 13); --keep soft mc_min_speed in [50..100]; --keep mc_target_speed >= mc_min_speed; -- This value will be the changing of the speed now !speed_temp: uint(bits: 13); --keep soft speed_temp in [1..10];
-- This counter is used to control the times of the generation
!counter: uint(bits:15);
keep soft counter in [1000..2000];
-- counter gen_counter: uint(bits:15);
keep soft gen_counter == 0;
//===================== 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 {
gen reset_delay; while TRUE { gen mc_target_speed; gen mc_min_speed; gen speed_temp; 'mc_reset_i' = 1;
wait [1];
'mc_reset_i' = 0;
wait [reset_delay]; } };
//===================== Below are generation and driver =========
// generate input and drive it to dut
//===============================================================
mc_gen_and_drive() @mc_clk is {
wait [1];
gen counter;
outf("\ncounter is %d", counter);
while TRUE {
gen mc_delay; if
'mc_reset_i' == 0 and 'mc_pwme_o' == 1 then { mc_speed_now += speed_temp; } else if
'mc_reset_i' == 0 and 'mc_pwme_o' == 0 then { mc_speed_now -= speed_temp; }; 'mc_speed_now_i' = mc_speed_now;
'mc_target_speed_i' = mc_target_speed;
'mc_min_speed_i' = mc_min_speed;
gen_counter += 1;
outf("\n%d. drive into signal: speed now %d, target speed %d, min speed %d, at %d", gen_counter, mc_speed_now, mc_target_speed, mc_min_speed, sys.time);
wait [mc_delay];
if gen_counter >= counter then { break; };
};
outf("\n");
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 + -