TA的每日心情 | 开心 2018-9-15 10:23 |
---|
新手上路
- 积分
- 35
|
楼主 |
发表于 2018-10-29 17:14:44
|
显示全部楼层
- always@(posedge mii_tx_clk or negedge Rst_n)
- if(!Rst_n)begin
- mii_tx_data<=4'd0;
- end
- else begin
- case(cnt)
- 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15:
- mii_tx_data<=4'h5;
- 16:
- mii_tx_data<=4'hd;
- //目的MAC地址
- 17: mii_tx_data <=r_des_mac[43:40];
- 18: mii_tx_data <=r_des_mac[47:44];
- 19: mii_tx_data <=r_des_mac[35:32];
- 20: mii_tx_data <=r_des_mac[39:36];
- 21: mii_tx_data <=r_des_mac[27:24];
- 22: mii_tx_data <=r_des_mac[31:28];
- 23: mii_tx_data <=r_des_mac[19:16];
- 24: mii_tx_data <=r_des_mac[23:20];
- 25: mii_tx_data <=r_des_mac[11:8];
- 26: mii_tx_data <=r_des_mac[15:12];
- 27: mii_tx_data <=r_des_mac[3:0];
- 28: mii_tx_data <=r_des_mac[7:4];
- //源MAC地址
- 29: mii_tx_data <=r_src_mac[43:40];
- 30: mii_tx_data <=r_src_mac[47:44];
- 31: mii_tx_data <=r_src_mac[35:32];
- 32: mii_tx_data <=r_src_mac[39:36];
- 33: mii_tx_data <=r_src_mac[27:24];
- 34: mii_tx_data <=r_src_mac[31:28];
- 35: mii_tx_data <=r_src_mac[19:16];
- 36: mii_tx_data <=r_src_mac[23:20];
- 37: mii_tx_data <=r_src_mac[11:8];
- 38: mii_tx_data <=r_src_mac[15:12];
- 39: mii_tx_data <=r_src_mac[3:0];
- 40: mii_tx_data <=r_src_mac[7:4];
- //以太网帧类型/长度
- 41: mii_tx_data <=r_type_length[11:8];
- 42: mii_tx_data <=r_type_length[15:12];
- 43: mii_tx_data <=r_type_length[3:0];
- 44: mii_tx_data <=r_type_length[7:4];
- //发送数据
- 45: mii_tx_data <=fifo_rddata;
- //发送CRC 校验结果
- 46: mii_tx_data <=CRC_Result[31:28];
- 47: mii_tx_data <=CRC_Result[27:24];
- 48: mii_tx_data <=CRC_Result[23:20];
- 49: mii_tx_data <=CRC_Result[19:16];
- 50: mii_tx_data <=CRC_Result[15:12];
- 51: mii_tx_data <=CRC_Result[11:8];
- 52: mii_tx_data <=CRC_Result[7:4];
- 53: mii_tx_data <=CRC_Result[3:0];
- default:mii_tx_data<=4'd0;
- endcase
- end
- 这是以太网的发送部分代码,我发现每次都是在仿真时刻的最后赋值的,比如cnt为1时,实际上是在2时刻才赋值
- always@(posedge mii_rx_clk or negedge Rst_n)
- if(!Rst_n)
- leadcode<=64'h0000_0000_0000_0000;
- else begin
- case(cnt)
- 0:
- leadcode[59:56]<=mii_rx_data;
- 1:
- leadcode[63:60]<=mii_rx_data;
- 2:
- leadcode[51:48]<=mii_rx_data;
- 3:
- leadcode[55:52]<=mii_rx_data;
- 4:
- leadcode[43:40]<=mii_rx_data;
- 5:
- leadcode[47:44]<=mii_rx_data;
- 6:
- leadcode[35:32]<=mii_rx_data;
- 7:
- leadcode[39:36]<=mii_rx_data;
- 8:
- leadcode[27:24]<=mii_rx_data;
- 9:
- leadcode[31:28]<=mii_rx_data;
- 10:
- leadcode[19:16]<=mii_rx_data;
- 11:
- leadcode[23:20]<=mii_rx_data;
- 12:
- leadcode[11:8]<=mii_rx_data;
- 13:
- leadcode[15:12]<=mii_rx_data;
- 14:
- leadcode[3:0]<=mii_rx_data;
- 15:
- leadcode[7:4]<=mii_rx_data;
- default:leadcode<=leadcode;
- endcase
- end
- 这是以太网接收的部分代码,我发现是立即赋值的
复制代码
|
|