URL
https://opencores.org/ocsvn/ha1588/ha1588/trunk
Subversion Repositories ha1588
Compare Revisions
- This comparison shows the changes necessary to convert path
/ha1588/trunk/sim/top/ptp_drv_bfm
- from Rev 37 to Rev 38
- ↔ Reverse comparison
Rev 37 → Rev 38
/ptp_drv_bfm.c
1,5 → 1,5
/* |
* $ptp_drv_bfm.c |
* ptp_drv_bfm.c |
* |
* Copyright (c) 2012, BABY&HW. All rights reserved. |
* |
25,42 → 25,44
#include "../dpiheader.h" |
|
// define RTC address values |
#define RTC_CTRL 0x00000000 |
#define RTC_NULL_0x4 0x00000004 |
#define RTC_NULL_0x8 0x00000008 |
#define RTC_NULL_0xC 0x0000000C |
#define RTC_TIME_SEC_H_LOAD 0x00000010 |
#define RTC_TIME_SEC_L_LOAD 0x00000014 |
#define RTC_TIME_NSC_H_LOAD 0x00000018 |
#define RTC_TIME_NSC_L_LOAD 0x0000001C |
#define RTC_PERIOD_H_LOAD 0x00000020 |
#define RTC_PERIOD_L_LOAD 0x00000024 |
#define RTC_ACCMOD_H_LOAD 0x00000028 |
#define RTC_ACCMOD_L_LOAD 0x0000002C |
#define RTC_ADJNUM_LOAD 0x00000030 |
#define RTC_NULL_0x34 0x00000034 |
#define RTC_ADJPER_H_LOAD 0x00000038 |
#define RTC_ADJPER_L_LOAD 0x0000003C |
#define RTC_TIME_SEC_H_READ 0x00000040 |
#define RTC_TIME_SEC_L_READ 0x00000044 |
#define RTC_TIME_NSC_H_READ 0x00000048 |
#define RTC_TIME_NSC_L_READ 0x0000004C |
#define RTC_CTRL 0x00000000 |
#define RTC_NULL_0x4 0x00000004 |
#define RTC_NULL_0x8 0x00000008 |
#define RTC_NULL_0xC 0x0000000C |
#define RTC_TIME_SEC_H 0x00000010 |
#define RTC_TIME_SEC_L 0x00000014 |
#define RTC_TIME_NSC_H 0x00000018 |
#define RTC_TIME_NSC_L 0x0000001C |
#define RTC_PERIOD_H 0x00000020 |
#define RTC_PERIOD_L 0x00000024 |
#define RTC_ADJPER_H 0x00000028 |
#define RTC_ADJPER_L 0x0000002C |
#define RTC_ADJNUM 0x00000030 |
#define RTC_NULL_0x34 0x00000034 |
#define RTC_NULL_0x38 0x00000038 |
#define RTC_NULL_0x3C 0x0000003C |
// define RTC control values |
#define RTC_SET_CTRL_0 0x00 |
#define RTC_GET_TIME 0x01 |
#define RTC_SET_ADJ 0x02 |
#define RTC_SET_PERIOD 0x04 |
#define RTC_SET_TIME 0x08 |
#define RTC_SET_RESET 0x10 |
// define RTC data values |
#define RTC_SET_CTRL_0 0x0 |
#define RTC_GET_TIME 0x1 |
#define RTC_SET_ADJ 0x2 |
#define RTC_SET_PERIOD 0x4 |
#define RTC_SET_TIME 0x8 |
#define RTC_SET_RESET 0x10 |
#define RTC_ACCMOD_H 0x3B9ACA00 // 1,000,000,000 for 30bit |
#define RTC_ACCMOD_L 0x0 // 256 for 8bit |
#define RTC_PERIOD_H 0x8 // 8ns for 125MHz rtc_clk |
#define RTC_PERIOD_L 0x0 |
#define RTC_SET_PERIOD_H 0x8 // 8ns for 125MHz rtc_clk |
#define RTC_SET_PERIOD_L 0x0 |
// define RTC constant |
#define RTC_ACCMOD_H 0x3B9ACA00 // 1,000,000,000 for 30bit |
#define RTC_ACCMOD_L 0x0 // 256 for 8bit |
|
// define TSU address values |
#define TSU_CTRL 0x00000050 |
#define TSU_RXQUE_STATUS 0x00000054 |
#define TSU_TXQUE_STATUS 0x00000058 |
#define TSU_CTRL 0x00000040 |
#define TSU_RXQUE_STATUS 0x00000044 |
#define TSU_TXQUE_STATUS 0x00000048 |
#define TSU_NULL_0x4C 0x0000004C |
#define TSU_NULL_0x50 0x00000050 |
#define TSU_NULL_0x54 0x00000054 |
#define TSU_NULL_0x58 0x00000058 |
#define TSU_NULL_0x5C 0x0000005C |
#define TSU_RXQUE_DATA_HH 0x00000060 |
#define TSU_RXQUE_DATA_HL 0x00000064 |
70,12 → 72,12
#define TSU_TXQUE_DATA_HL 0x00000074 |
#define TSU_TXQUE_DATA_LH 0x00000078 |
#define TSU_TXQUE_DATA_LL 0x0000007C |
// define TSU data values |
#define TSU_SET_CTRL_0 0x0 |
#define TSU_GET_TXQUE 0x1 |
#define TSU_GET_RXQUE 0x4 |
#define TSU_SET_RXRST 0x8 |
#define TSU_SET_TXRST 0x2 |
// define TSU control values |
#define TSU_SET_CTRL_0 0x00 |
#define TSU_GET_TXQUE 0x01 |
#define TSU_SET_TXRST 0x02 |
#define TSU_GET_RXQUE 0x04 |
#define TSU_SET_RXRST 0x08 |
|
int ptp_drv_bfm_c(double fw_delay) |
{ |
83,23 → 85,15
unsigned int cpu_data_i; |
unsigned int cpu_data_o; |
|
// LOAD RTC PERIOD AND ACC_MODULO |
cpu_addr_i = RTC_PERIOD_H_LOAD; |
cpu_data_i = RTC_PERIOD_H; |
// LOAD RTC PERIOD |
cpu_addr_i = RTC_PERIOD_H; |
cpu_data_i = RTC_SET_PERIOD_H; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_PERIOD_L_LOAD; |
cpu_data_i = RTC_PERIOD_L; |
cpu_addr_i = RTC_PERIOD_L; |
cpu_data_i = RTC_SET_PERIOD_L; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_ACCMOD_H_LOAD; |
cpu_data_i = RTC_ACCMOD_H; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_ACCMOD_L_LOAD; |
cpu_data_i = RTC_ACCMOD_L; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_CTRL; |
cpu_data_i = RTC_SET_CTRL_0; |
cpu_wr(cpu_addr_i, cpu_data_i); |
129,39 → 123,39
do { |
cpu_addr_i = RTC_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & RTC_GET_TIME) == 0x0); |
|
cpu_addr_i = RTC_TIME_SEC_H_READ; |
cpu_addr_i = RTC_TIME_SEC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("\ntime: \n%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_SEC_L_READ; |
cpu_addr_i = RTC_TIME_SEC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_H_READ; |
cpu_addr_i = RTC_TIME_NSC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_L_READ; |
cpu_addr_i = RTC_TIME_NSC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
// LOAD RTC SEC AND NS |
cpu_addr_i = RTC_TIME_SEC_H_LOAD; |
cpu_addr_i = RTC_TIME_SEC_H; |
cpu_data_i = 0x0; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_TIME_SEC_L_LOAD; |
cpu_addr_i = RTC_TIME_SEC_L; |
cpu_data_i = 0x1; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_TIME_NSC_H_LOAD; |
cpu_addr_i = RTC_TIME_NSC_H; |
cpu_data_i = RTC_ACCMOD_H - 0xA; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_TIME_NSC_L_LOAD; |
cpu_addr_i = RTC_TIME_NSC_L; |
cpu_data_i = 0x0; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
174,15 → 168,15
cpu_wr(cpu_addr_i, cpu_data_i); |
|
// LOAD RTC ADJ |
cpu_addr_i = RTC_ADJNUM_LOAD; |
cpu_addr_i = RTC_ADJNUM; |
cpu_data_i = 0x100; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_ADJPER_H_LOAD; |
cpu_addr_i = RTC_ADJPER_H; |
cpu_data_i = 0x1; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
cpu_addr_i = RTC_ADJPER_L_LOAD; |
cpu_addr_i = RTC_ADJPER_L; |
cpu_data_i = 0x20; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
194,6 → 188,12
cpu_data_i = RTC_SET_ADJ; |
cpu_wr(cpu_addr_i, cpu_data_i); |
|
do { |
cpu_addr_i = RTC_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & RTC_SET_ADJ) == 0x0); |
|
// READ RTC SEC AND NS |
cpu_addr_i = RTC_CTRL; |
cpu_data_i = RTC_SET_CTRL_0; |
206,22 → 206,22
do { |
cpu_addr_i = RTC_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & RTC_GET_TIME) == 0x0); |
|
cpu_addr_i = RTC_TIME_SEC_H_READ; |
cpu_addr_i = RTC_TIME_SEC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("\ntime: \n%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_SEC_L_READ; |
cpu_addr_i = RTC_TIME_SEC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_H_READ; |
cpu_addr_i = RTC_TIME_NSC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_L_READ; |
cpu_addr_i = RTC_TIME_NSC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
262,7 → 262,7
do { |
cpu_addr_i = TSU_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & TSU_GET_RXQUE) == 0x0); |
|
cpu_addr_i = TSU_RXQUE_DATA_HH; |
293,22 → 293,22
do { |
cpu_addr_i = RTC_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & RTC_GET_TIME) == 0x0); |
|
cpu_addr_i = RTC_TIME_SEC_H_READ; |
cpu_addr_i = RTC_TIME_SEC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("\ntime: \n%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_SEC_L_READ; |
cpu_addr_i = RTC_TIME_SEC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_H_READ; |
cpu_addr_i = RTC_TIME_NSC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_L_READ; |
cpu_addr_i = RTC_TIME_NSC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
} |
335,7 → 335,7
do { |
cpu_addr_i = TSU_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & TSU_GET_TXQUE) == 0x0); |
|
cpu_addr_i = TSU_TXQUE_DATA_HH; |
366,22 → 366,22
do { |
cpu_addr_i = RTC_CTRL; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
//printf("%08x\n", (cpu_data_o & 0x1)); |
//printf("%08x\n", cpu_data_o); |
} while ((cpu_data_o & RTC_GET_TIME) == 0x0); |
|
cpu_addr_i = RTC_TIME_SEC_H_READ; |
cpu_addr_i = RTC_TIME_SEC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("\ntime: \n%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_SEC_L_READ; |
cpu_addr_i = RTC_TIME_SEC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_H_READ; |
cpu_addr_i = RTC_TIME_NSC_H; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
|
cpu_addr_i = RTC_TIME_NSC_L_READ; |
cpu_addr_i = RTC_TIME_NSC_L; |
cpu_rd(cpu_addr_i, &cpu_data_o); |
printf("%08x\n", cpu_data_o); |
} |
/ptp_drv_bfm.v
1,5 → 1,5
/* |
* $ptp_drv_bfm.v |
* ptp_drv_bfm.v |
* |
* Copyright (c) 2012, BABY&HW. All rights reserved. |
* |