module test(CLK,STB,DATA,DOUT);
input CLK,STB,DATA;
output[7:0] DOUT;
reg[7:0] DOUT;
reg[7:0] shifter;
reg[7:0] bufferreg;
reg datacoming;
reg[2:0] count;
//initialize
initial
begin
count = 0;
datacoming = 0;
bufferreg = 8'b11111111;
end
always @(posedge CLK)
begin
if(STB == 1)
datacoming = 1;
else
begin
if(count == 1)
begin
datacoming = 0;
end
else
datacoming = 1;
end
if(datacoming == 1)
begin
shifter <= shifter << 1;
shifter[0] <= DATA;
count = count + 1;
if(count == 0)
begin
bufferreg = shifter;
end
end
DOUT = bufferreg;
end
endmodule
ÕâÊdzÌÐò£¬Ö÷ҪĿµÄÊǽ«8λÒÆλ¼Ä´æÆ÷ÿ´Î²É¼¯µÄÊý¾Ý·Åµ½Ò»¸ö»º³å¼Ä´æÆ÷£¬È»ºóÊä³ö¡£
STBµÄÖ÷Òª×÷ÓÃÊDZêÖ¾Êý¾ÝÖ¡µÄ¿ªÊ¼£¬ÔÚbit0³ÖÐøÒ»¸öʱÖÓÖÜÆÚ£¨¸ßµçƽ£©£¬ÆäËüµÄÐźŴó¼Ò¶¼ÄÜ¿´¶®µÄ£¬µ«ÎÒ·ÂÕæ³öÀ´È´ÓÐÎÊÌ⣬´ó¼ÒÄÜ¿´Ò»ÏÂÊÇÄijöÎÊÌâÁËÂð£¿Ð»Ð»£¡
¸½¼þΪʱÐòͼ
±¾Îĺ¬ÓÐÀ´×ÔÂÛ̳µÄ¸½¼þ»òͼƬ:[QQ½ØͼδÃüÃû.jpg]£¬µã»÷²é¿´ÔÌû¸½¼þ¡£