Altera_Forum
Honored Contributor
15 years agoHi ALL... I need help with the HDL code
Hi
Im a beginner in HDL. I am given an SPI serial to parallel register and the inputs are clk, en and the serial data.. The register converts the serial data to parallel. The parallel data can be upto 50 bits... And also I need to detect the edge of the clock for re-sync. So I have to give the enable as input to a flipflop and and the ff output with the en to get edge detector o/p. Please let me know whether my verilog code is correct. module MY_MOD( input DATA, input EN, input CLK, output [49:0] OUT, output EDGE_DETECT ); reg [49:0] tmp; reg [6:0] count; reg tmp1; //Read the serial data into a 75-bit register. Afterwards, convert it to parallel always @(posedge CLK) begin tmp1 = EN; if (SPI_EN == 0) begin count<=count+7'd1; tmp = {tmp[48:0], DATA}; end end assign OUT = tmp; assign EDGE_DETECT= EN & (!tmp1); endmodule Please suggest any change or corrections. Thanks a load in advance