delay_mode

Consider the following example, test.v, which includes an instantiated module that simulates explicit delays on certain gates.

`timescale 1ns/1ps
module delay(in, out1, out2, out3, out4, transport, inertial);
input in;
output out1, out2, out3, out4, transport;
output inertial;
reg transport;
wire inertial;
always @in
begin
transport <= #10 in;
end
assign #10 inertial = in;

not#0 g1(out1, in);
not#5 g2(out2, in);
not#10 g3(out3, in);
not g4(out4, in);

specify
( in => out4) = 4;
endspecify
endmodule

module wrapper;
reg IN;
wire OUT1, OUT2, OUT3, OUT4, TRANSPORT, INERTIAL;
delay inst(IN, OUT1, OUT2, OUT3, OUT4, TRANSPORT, INERTIAL);
initial begin
IN = 1’b0;
#50 IN = 1’b1;
#50 IN = 1’b0;
#50 $finish();
end
endmodule

To run this example in direct invocation mode, specify the following commands:

% xmvlog test.v
% xmelab -access +rwc wrapper
% xmsim -tcl -profile -input “@probe -screen *; run; exit” wrapper

Alternatively, to run this example in single-step xrun mode, specify the following:

% xrun -access +rwc -tcl -profile -input “@probe -screen *; run; exit” test.v

The HDL is coded such that this will result in the following waveform by default:

where,

g1 (out1) has zero delay
g2 (out2) has a distributed delay of 5 simulation time units
g3 (out3) has a distributed delay of 10 simulation time units
g4 (out4) has a path delay of 4 simulation time units
inertial and transport both have a delay of 10 simulation time units
The following table shows how the simulation delays are executed when you select one of the global delay modes:

unit delay
Adding -delay_mode unit to the xmelab or xrun command line converts all non-zero structural and continuous assignment delay expressions to a delay of one simulation time unit. This changes the inertial delay, as well as the delays on gates g2 and g3. The delay on gate g4 is ignored since it is a module path delay. The transport delay and the zero delay on gate g1 behave the same as when no delay mode is specified.

zero delay
Adding -delay_mode zero to the xmelab or xrun command line ignores all module path delay information, timing checks, and structural and continuous assignment delays coded in the HDL source. This changes the inertial delay, and the delays on gates g2, g3, and g4. Gate g1 is already a zero delay, and remains unchanged. The transport delay behaves the same as when no delay mode is specified.

distributed delay
Adding -delay_mode distributed to the xmelab or xrun command ignores specparam and module path specifications. Only gate g4 is ignored in this case since it is a module path delay. All other delay specifications will behave the same as when no global delay mode is specified.

path delay
Adding -delay_mode path to the xmelab or xrun command line uses the module path delay information in the HDL source and ignores all distributed delay specifications. This changes the inertial delay, and the delays on gates g1, g2, and g3. The transport delay and the module path delay on gate g4 behave the same as when no delay mode is specified.

punit delay
Adding -delay_mode punit to the xmelab or xrun command line ignores all timing checks and sets all path delays to simulate with the value of one simulation time unit. Only gate g4 is changed in this case since it is a module path delay. All other delay specifications will behave the same as when no delay mode is specified.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include "i2c.h" #include "stm32f10x.h" #include <math.h> //Keil library // ¶¨ÒåMPU6050ÄÚ²¿µØÖ· //**************************************** #define SMPLRT_DIV 0x19 //ÍÓÂÝÒDzÉÑùÂÊ£¬µäÐÍÖµ£º0x07(125Hz) #define CONFIG 0x1A //µÍͨÂ˲¨ÆµÂÊ£¬µäÐÍÖµ£º0x06(5Hz) #define GYRO_CONFIG 0x1b //ÍÓÂÝÒÇ×Լ켰²âÁ¿·¶Î§£¬µäÐÍÖµ£º0x18(²»×Լ죬2000deg/s) #define ACCEL_CONFIG 0x1c //¼ÓËÙ¼Æ×Լ졢²âÁ¿·¶Î§¼°¸ßͨÂ˲¨ÆµÂÊ£¬µäÐÍÖµ£º0x01(²»×Լ죬2G£¬5Hz) #define ACCEL_XOUT_H 0x3B #define ACCEL_XOUT_L 0x3C #define ACCEL_YOUT_H 0x3D #define ACCEL_YOUT_L 0x3E #define ACCEL_ZOUT_H 0x3F #define ACCEL_ZOUT_L 0x40 #define TEMP_OUT_H 0x41 #define TEMP_OUT_L 0x42 #define GYRO_XOUT_H 0x43 #define GYRO_XOUT_L 0x44 #define GYRO_YOUT_H 0x45 #define GYRO_YOUT_L 0x46 #define GYRO_ZOUT_H 0x47 #define GYRO_ZOUT_L 0x48 #define PWR_MGMT_1 0x6B //µçÔ´¹ÜÀí£¬µäÐÍÖµ£º0x00(Õý³£ÆôÓÃ) #define WHO_AM_I 0x75 //IICµØÖ·¼Ä´æÆ÷(ĬÈÏÊýÖµ0x68£¬Ö»¶Á) #define MPU6050_Addr 0xd0 //¶¨ÒåÆ÷¼þÔÚIIC×ÜÏßÖеĴӵØÖ·,¸ù¾ÝALT ADDRESSµØÖ·Òý½Å²»Í¬ÐÞ¸Ä #define SCL_H GPIOB->BSRR = GPIO_Pin_6 #define SCL_L GPIOB->BRR = GPIO_Pin_6 #define SDA_H GPIOB->BSRR = GPIO_Pin_7 #define SDA_L GPIOB->BRR = GPIO_Pin_7 #define SCL_read GPIOB->IDR & GPIO_Pin_6 #define SDA_read GPIOB->IDR & GPIO_Pin_7 void SDA_IOIN(void); void SDA_IOOUT(void); void I2C_delay(void); void delay5ms(void); u8 I2C_Start(void); void I2C_Stop(void); void I2C_Ack(void); void I2C_NoAck(void); u8 I2C_WaitAck(void); void I2C_SendByte(u8 SendByte) ; unsigned char I2C_RadeByte(void); void READ_MPU6050(void); u8 Single_Write(unsigned char SlaveAddress,unsigned char REG_Address,unsigned char REG_data); void GPIO_Configuration(void); void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); } unsigned char BUF[15]; //½ÓÊÕÊý¾Ý»º´æÇø char TX_DATA[4]; //ÏÔʾ¾Ý»º´æÇø short T_X,A_X,T_Y,A_Y,T_Z,A_Z,T_T; void SDA_IOOUT(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; // ¿ªÂ©Êä³ö GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // ×î¸ßÊä³öËÙÂÊ50MHz GPIO_Init(GPIOB, &GPIO_InitStructure); // Ñ¡ÔñC¶Ë¿Ú } void SDA_IOIN(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // ¸¡¿ÕÊäÈë GPIO_Init(GPIOB, &GPIO_InitStructure); // Ñ¡ÔñC¶Ë¿Ú } void Init_MPU6050() { // Single_Write(MPU6050_Addr,PWR_MGMT_1, 0x80); // delay5ms(); Single_Write(MPU6050_Addr,PWR_MGMT_1, 0x00); delay5ms(); //½â³ýÐÝÃß״̬ Single_Write(MPU6050_Addr,SMPLRT_DIV, 0x07); delay5ms();//²ÉÑùËÙÂÊΪ Single_Write(MPU6050_Addr,CONFIG, 0x06); delay5ms(); Single_Write(MPU6050_Addr,GYRO_CONFIG, 0x18); delay5ms(); //ÍÓÂÝÒǼì²â·¶Î§500¶È/Ãë Single_Write(MPU6050_Addr,ACCEL_CONFIG, 0x01); delay5ms(); //¼ÓËÙÆ÷¼ì²â·¶Î§4G GPIO_Configuration(); }; unsigned char Single_Write(unsigned char SlaveAddress, unsigned char REG_Address, unsigned char REG_data) //void { if(!I2C_Start())return 0; I2C_SendByte(SlaveAddress); //·¢ËÍÉ豸µØÖ·+дÐźÅ//I2C_SendByte(((REG_Address & 0x0700) >>7) | SlaveAddress & 0xFFFE);//ÉèÖøßÆðʼµØÖ·+Æ÷¼þµØÖ· // if(!I2C_WaitAck()){I2C_Stop(); return 0;} I2C_WaitAck(); I2C_SendByte(REG_Address); //ÉèÖõÍÆðʼµØÖ· I2C_WaitAck(); I2C_SendByte(REG_data); I2C_WaitAck(); I2C_Stop(); delay5ms(); return 1; } unsigned char Single_Read(unsigned char SlaveAddress,unsigned char REG_Address) { unsigned char REG_data; I2C_Start(); I2C_SendByte(SlaveAddress); //I2C_SendByte(((REG_Address & 0x0700) >>7) | REG_Address & 0xFFFE);//ÉèÖøßÆðʼµØÖ·+Æ÷¼þµØÖ· I2C_WaitAck(); I2C_SendByte((u8) REG_Address); //ÉèÖõÍÆðʼµØÖ· I2C_WaitAck(); I2C_Start(); I2C_SendByte(SlaveAddress+1); I2C_WaitAck(); REG_data= I2C_RadeByte(); I2C_NoAck(); I2C_Stop(); //return 1; return REG_data; } /******************************************************************************* * Function Name : I2C_delay * Description : Simulation IIC Timing series delay * Input : None * Output : None * Return : None ****************************************************************************** */ void I2C_delay(void) { u8 i=30; //ÕâÀï¿ÉÒÔÓÅ»¯ËÙ¶È £¬¾­²âÊÔ×îµÍµ½5»¹ÄÜдÈë while(i) { i--; } } void delay5ms(void) { int i=5000; while(i) { i--; } } /******************************************************************************* * Function Name : I2C_Start * Description : Master Start Simulation IIC Communication * Input : None * Output : None * Return : Wheather Start ****************************************************************************** */ u8 I2C_Start(void) { SDA_IOOUT(); SDA_H; SCL_H; I2C_delay(); if(!SDA_read)return 0; //SDAÏßΪµÍµçƽÔò×ÜÏßæ,Í˳ö SDA_L; I2C_delay(); if(SDA_read) return 0; //SDAÏßΪ¸ßµçƽÔò×ÜÏß³ö´í,Í˳ö SDA_L; I2C_delay(); SCL_L; return 1; } /******************************************************************************* * Function Name : I2C_Stop * Description : Master Stop Simulation IIC Communication * Input : None * Output : None * Return : None ****************************************************************************** */ void I2C_Stop(void) { SDA_IOOUT(); SCL_L; I2C_delay(); SDA_L; I2C_delay(); SCL_H; I2C_delay(); SDA_H; I2C_delay(); } /******************************************************************************* * Function Name : I2C_Ack * Description : Master Send Acknowledge Single * Input : None * Output : None * Return : None ****************************************************************************** */ void I2C_Ack(void) { SCL_L; I2C_delay(); SDA_L; I2C_delay(); SCL_H; I2C_delay(); SCL_L; I2C_delay(); } /******************************************************************************* * Function Name : I2C_NoAck * Description : Master Send No Acknowledge Single * Input : None * Output : None * Return : None ****************************************************************************** */ void I2C_NoAck(void) { SCL_L; I2C_delay(); SDA_H; I2C_delay(); SCL_H; I2C_delay(); SCL_L; I2C_delay(); } /******************************************************************************* * Function Name : I2C_WaitAck * Description : Master Reserive Slave Acknowledge Single * Input : None * Output : None * Return : Wheather Reserive Slave Acknowledge Single ****************************************************************************** */ u8 I2C_WaitAck(void) //·µ»ØΪ:=1ÓÐACK,=0ÎÞACK { SDA_IOIN(); SCL_L; I2C_delay(); SDA_H; I2C_delay(); SCL_H; I2C_delay(); if(SDA_read) { SCL_L; SDA_IOOUT(); I2C_delay(); return 0; } SCL_L; SDA_IOOUT(); I2C_delay(); return 1; } /******************************************************************************* * Function Name : I2C_SendByte * Description : Master Send a Byte to Slave * Input : Will Send Date * Output : None * Return : None ****************************************************************************** */ void I2C_SendByte( unsigned char SendByte) //Êý¾Ý´Ó¸ßλµ½µÍλ// { u8 i=8; while(i--) { SCL_L; I2C_delay(); if(SendByte&0x80) SDA_H; else SDA_L; SendByte<<=1; I2C_delay(); SCL_H; I2C_delay(); } SCL_L; } /******************************************************************************* * Function Name : I2C_RadeByte * Description : Master Reserive a Byte From Slave * Input : None * Output : None * Return : Date From Slave ****************************************************************************** */ unsigned char I2C_RadeByte(void) //Êý¾Ý´Ó¸ßλµ½µÍλ// { u8 i=8; u8 ReceiveByte=0; SDA_IOIN(); while(i--) { ReceiveByte<<=1; SCL_L; I2C_delay(); SCL_H; I2C_delay(); if(SDA_read) { ReceiveByte|=0x01; } } SCL_L; return ReceiveByte; } void READ_MPU6050(void) { BUF[0]=Single_Read(MPU6050_Addr,GYRO_XOUT_L); BUF[1]=Single_Read(MPU6050_Addr,GYRO_XOUT_H); T_X= (BUF[1]<<8)|BUF[0]; // T_X/=16.4; //¶ÁÈ¡¼ÆËãXÖá½ÇËÙ¶È BUF[2]=Single_Read(MPU6050_Addr,GYRO_YOUT_L); BUF[3]=Single_Read(MPU6050_Addr,GYRO_YOUT_H); T_Y= (BUF[3]<<8)|BUF[2]; // T_Y/=16.4; //¶ÁÈ¡¼ÆËãYÖá½ÇËÙ¶È BUF[4]=Single_Read(MPU6050_Addr,GYRO_ZOUT_L); BUF[5]=Single_Read(MPU6050_Addr,GYRO_ZOUT_H); T_Z= (BUF[5]<<8)|BUF[4]; // T_Z/=16.4; //¶ÁÈ¡¼ÆËãZÖá½ÇËÙ¶È BUF[6]=Single_Read(MPU6050_Addr,ACCEL_XOUT_L); BUF[7]=Single_Read(MPU6050_Addr,ACCEL_XOUT_H); A_X= (BUF[7]<<8)|BUF[6]; // A_X/=8192.0; //¶ÁÈ¡¼ÆËãXÖá¼ÓËÙ¶È BUF[8]=Single_Read(MPU6050_Addr,ACCEL_YOUT_L); BUF[9]=Single_Read(MPU6050_Addr,ACCEL_YOUT_H); A_Y= (BUF[9]<<8)|BUF[8]; // A_Y/=8192.0; //¶ÁÈ¡¼ÆËãYÖá¼ÓËÙ¶È BUF[10]=Single_Read(MPU6050_Addr,ACCEL_ZOUT_L); BUF[11]=Single_Read(MPU6050_Addr,ACCEL_ZOUT_H); A_Z= (BUF[11]<<8)|BUF[10]; // A_Z/=8192.0; //¶ÁÈ¡¼ÆËãZÖá¼ÓËÙ¶È BUF[12]=Single_Read(MPU6050_Addr,TEMP_OUT_L); BUF[13]=Single_Read(MPU6050_Addr,TEMP_OUT_H); T_T=(BUF[13]<<8)|BUF[12]; T_T = 35+ ((double) (T_T + 13200)) / 280;// ¶ÁÈ¡¼ÆËã³öÎÂ¶È }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值