📄 lab_mc_driver_2.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: 9);
keep soft reset_delay in [400..511];
-- 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 [100..200]; -- 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 counter is used to control the times of the generation
!counter: uint(bits:9);
keep soft counter in [300..511];
//===================== 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; '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
//===============================================================
gen_counter: uint(bits:9);
keep soft gen_counter == 0;
mc_gen_and_drive() @mc_clk is {
wait [1];
--gen counter;
-- outf("\ncounter is %d", counter);
--while (gen_counter < counter) {
while TRUE {
-- gen mc_delay; if
'mc_reset_i' == 0 and 'mc_pwme_o' == 1 then { mc_speed_now += 1; } else if
'mc_reset_i' == 0 and 'mc_pwme_o' == 0 then { mc_speed_now -= 1; };
'mc_speed_now_i' = mc_speed_now;
'mc_target_speed_i' = mc_target_speed;
'mc_min_speed_i' = mc_min_speed;
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 [1];
-- wait [mc_delay];
gen_counter += 1;
outf("\ngen_counter = %d", gen_counter); if gen_counter == 0 then { break; };
};
-- if gen_counter >= 400 then { 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 + -